Created
June 1, 2016 21:41
-
-
Save agusmakmun/640bfeea24928c1e68f74af7ef7892c8 to your computer and use it in GitHub Desktop.
medium_twitter_mining_7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
# get top ten entities | |
top_words = [item[0] for item in Counter(words).most_common()[:10]] | |
top_words_freq = [item[1] for item in Counter(words).most_common()[:10]] | |
top_screen_names = [item[0] for item in Counter(screen_names).most_common()[:10]] | |
top_screen_names_freq = [item[1] for item in Counter(screen_names).most_common()[:10]] | |
top_hashtags = [item[0] for item in Counter(hashtags).most_common()[:10]] | |
top_hashtags_freq = [item[1] for item in Counter(hashtags).most_common()[:10]] | |
# print the results as a table | |
pt = PrettyTable() | |
pt.add_column('Words',top_words) | |
pt.add_column('Frequency',top_words_freq) | |
pt.add_column('Screen Names',top_screen_names) | |
pt.add_column('Frequency',top_screen_names_freq) | |
pt.add_column('Hashtags',top_hashtags) | |
pt.add_column('Frequency',top_hashtags_freq) | |
print pt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment