Modified to work with classic or extended tweet format ('text' or 'full_text')
@@ -6,6 +6,7 @@ import sys
import json
import fileinput
+def main():
try:
from urllib import urlopen # Python 2
except ImportError:
@@ -21,7 +22,7 @@ for line in fileinput.input():
tweet = json.loads(line)
except:
pass
- for word in tweet['text'].split(' '):
+ for word in text(tweet).split(' '):
word = word.lower()
word = word.replace(".", "")
if len(word) < 3: continue
@@ -97,3 +98,11 @@ output = """<!DOCTYPE html>
""" % (wordcloud_js.decode('utf8'), json.dumps(words, indent=2))
sys.stdout.write(output)
+
+def text(t):
+ if 'full_text' in t:
+ return t['full_text']
+ return t['text']
+
+if __name__ == "__main__":
+ main()
