diff --git a/__pycache__/dashboard.cpython-310.pyc b/__pycache__/dashboard.cpython-310.pyc index fa27820..7a0a862 100644 Binary files a/__pycache__/dashboard.cpython-310.pyc and b/__pycache__/dashboard.cpython-310.pyc differ diff --git a/dashboard.py b/dashboard.py index 7b8637f..fa975ac 100644 --- a/dashboard.py +++ b/dashboard.py @@ -2,6 +2,7 @@ from eca import * from eca.generators import start_offline_tweets import random +import re ## You might have to update the root path to point to the correct path ## (by default, it points to _static) @@ -21,6 +22,22 @@ def setup(ctx, e): def clip(lower, value, upper): return max(lower, min(value, upper)) + +# simple word splitter +pattern = re.compile('\W+') + +# sample stopword list, needs to be much more sophisticated +stopwords = ["volleyball", "football", "basketball", "baseball", "tennis", "cricket", "soccer", "rugby"] + + +def words(message): + result = pattern.split(message) + result = map(lambda w: w.lower(), result) + result = filter(lambda w: w in stopwords, result) + result = filter(lambda w: len(w) > 2, result) + return result + + @event('tweet') def generate_tweet(ctx, e): tweet = e.data @@ -28,7 +45,11 @@ def generate_tweet(ctx, e): # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) # emit to outside world emit('tweet', tweet) - + for w in words(tweet['text']): + emit('balk', { + 'action': 'add', + 'value': (str(w), 1) + }) # # chain event # fire('tweet', {'previous': tweet}, delay=0.05) diff --git a/dashboard_static/index.html b/dashboard_static/index.html index 6d0f1c3..54a6f1b 100644 --- a/dashboard_static/index.html +++ b/dashboard_static/index.html @@ -110,7 +110,8 @@
- Sports Popularity Chart + Sports Popularity Filter +
@@ -118,6 +119,7 @@ + @@ -128,6 +130,8 @@ block("#tweet").tweets({ memory: 20 }); + block('#balk').barchart(); + events.connect('balk', '#balk'); events.connect("tweet", "#tweet"); // // create a rolling chart block diff --git a/dashboard_static/style/style.css b/dashboard_static/style/style.css index 2046fc0..57726f1 100644 --- a/dashboard_static/style/style.css +++ b/dashboard_static/style/style.css @@ -133,6 +133,13 @@ body { font-weight: bold; } +.tweet-nickname:hover { + color: white; + text-decoration: underline; + font-weight: bold; +} + + .tweet-username { color: var(--main-light); text-decoration: none; diff --git a/demos/wordcloud.py b/demos/wordcloud.py index 5b59539..987fe12 100644 --- a/demos/wordcloud.py +++ b/demos/wordcloud.py @@ -16,7 +16,7 @@ def add_request_handlers(httpd): @event('init') def setup(ctx, e): # start the offline tweet stream - start_offline_tweets('data/bata_2014.txt', 'chirp', time_factor=100000) + start_offline_tweets('sports1.txt', 'chirp', time_factor=100000) ctx.words = {} # simple word splitter diff --git a/eca/__pycache__/arff.cpython-310.pyc b/eca/__pycache__/arff.cpython-310.pyc index dab7427..1516621 100644 Binary files a/eca/__pycache__/arff.cpython-310.pyc and b/eca/__pycache__/arff.cpython-310.pyc differ diff --git a/eca/__pycache__/generators.cpython-310.pyc b/eca/__pycache__/generators.cpython-310.pyc index 01498c6..155bc4d 100644 Binary files a/eca/__pycache__/generators.cpython-310.pyc and b/eca/__pycache__/generators.cpython-310.pyc differ