Python 可视化Twitter中指定话题中Tweet的词汇频率
2024-09-29 16:53:05
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-7-8
@author: guaguastd
@name: plot_frequencies_words.py
''' if __name__ == '__main__':
#import json # import Counter
from collections import Counter # import search
from search import search_for_tweet # import visualize
from visualize import visualize_for_frequencies # 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) word_counts = sorted(Counter(words).values(), reverse=True)
visualize_for_frequencies(word_counts, "Word Rank", "Freq")
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 100
Length of statuses 196
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ3VhZ3Vhc3Rk/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
最新文章
- [收集]MVC3 HTML辅助方法集录
- spice server dpkg-buildpackage 打包编译备忘
- PHP文件的读取
- Python基于websocket实时通信的实现—GoEasy
- 资金归集率比率sql
- Delphi的属性Property
- 【C++】const
- Ubuntu上安装MongoDB(译)
- .Net 自己写个简单的 半 ORM (练手)
- 调试NodeJS应用
- Real-Rime Rendering (2) - 变换和矩阵(Translation and Matrics)
- cocos2d-x 几何绘制: DrawingPrimitives 和 CCDrawNode
- NLog 2.0.0.2000 使用实例
- mysql 只给更新表的某个字段的授权
- ModelAndView
- jmeter 使用jmeter 录制web脚本
- Windows Server 安装后无法使用无线与音频
- 汇编实现: C库常见函数,串操作指令作用
- clear session on close of browser jsp
- python+stomp+activemq