Python 对Twitter中指定话题的Tweet基本元素的频谱分析
2014-07-09 06:44
381 查看
CODE:
RESULT:
![](http://img.blog.csdn.net/20140709064059821?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ3VhZ3Vhc3Rk/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](http://img.blog.csdn.net/20140709064128166?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ3VhZ3Vhc3Rk/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
#!/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 search from search import search_for_tweet # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import twitter_login # get the twitter access api twitter_api = twitter_login() # import tweet from tweet import extract_tweet_entities while 1: query = raw_input('\nInput the query (eg. #MentionSomeoneImportantForYou, 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 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)" yLabel = "Number of items in bin" visualize_frequency_map(c.values(), sTitle, xLabel, yLabel)
RESULT:
相关文章推荐
- Python 对Twitter中指定话题的Tweet基本元素的频谱分析
- Python 可视化Twitter中指定话题中Tweet的词汇频率
- Python 可视化Twitter中指定话题中Tweet的词汇频率
- Python 对Twitter中指定话题的被转载Tweet数量的频谱分析
- Python 对Twitter中指定话题的被转载Tweet数量的频谱分析
- Python 查找Twitter中特定话题中最流行的10个转发Tweet
- Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的词汇多样性分析
- Python 提取Twitter特定话题中转载tweet的用户
- Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的频率分析
- Python 查找Twitter中特定话题中最流行(转载最多)的10个Tweet
- Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的词汇多样性分析
- Python中对Tuple之间排序时如何指定第几个元素为关键字排序的问题
- python将list连续元素和非连续元素分开转换为指定字符串
- Python 查找有序列表中指定元素所在位置
- Python中字符串连接、删除数组中指定元素、记录脚本运行时间
- python将list连续元素和非连续元素分开转换为指定字符串
- Python 从任意文本中提取Twitter的推文元素
- Python 获取Twitter话题 (API)
- Python 提取Twitter用户的Tweet
- python读取html中指定元素生成excle文件示例