CODE:
#!/usr/bin/python #-*-Coding:utf-8-*-"Created on 2014-7-9@author:guaguastd@name:entities_frequency_map.py" if _ _name__ = = ' __main__ ': # import Counter from collections Import Counter # import visualize from visualize Import Visualize_frequency_map # pip install prettytable # from prettytable import prettytable # import Searc H from search import Search_for_tweet # import login, see http://blog.csdn.net/guaguastd/article/details/317 06155 from login Import Twitter_login # Get the twitter access API Twitter_api = Twitter_login () # import Tweets from tweets import extract_tweet_entities while 1:query = Raw_input (' \ninput the query (eg. #MentionSo Meoneimportantforyou, Exit to quit): ' If query = = ' exit ': print ' successfully exit! ' Break statuses = Search_for_tweet (twitter_api, query) Status_texts,screen_names,hashtags,words = Extract_tweet_entities (statUses) for the label, data in (' Word ', words), (' Screen Name ', screen_names), (' Hashtag ', hashtags)): # Build A frequency map for each set of data and plot the values c = Counter (data) stitle = label Xlabel = "Bins (number of times an item appeared)" Y Label = "Number of items in Bin" Visualize_frequency_map (C.values (), Stitle, Xlabel, Ylabel)
RESULT:
A spectral analysis of the basic elements of Python's tweet on a given topic in Twitter