Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的频率分析
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-7-2
@author: guaguastd
@name: tweet_frequency_analysis.py
''' if __name__ == '__main__': # import frequency
from frequency import frequency_analysis # 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)):
frequency_analysis(label, data, 10)
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 96
+--------------------------------+-------+
| Word | Count |
+--------------------------------+-------+
| #MentionSomeoneImportantForYou | 84 |
| RT | 49 |
| @paynashton | 13 |
| #mentionsomeoneimportantforyou | 12 |
| @gellystyles | 11 |
| @cuddlingxbrooks | 9 |
| @sickhorandiva | 9 |
| @cuddlingxbrooks: | 8 |
| so | 8 |
| @fratboyliamx | 7 |
+--------------------------------+-------+
+-----------------+-------+
| Screen Name | Count |
+-----------------+-------+
| paynashton | 18 |
| cuddlingxbrooks | 17 |
| gellystyles | 15 |
| sickhorandiva | 13 |
| SwaggyOnFire1 | 9 |
| TichaaAlves | 7 |
| wtvpottorff | 7 |
| idkdallasbae | 7 |
| ElenaBomerC | 7 |
| cuddings | 7 |
+-----------------+-------+
+-----------------------------------+-------+
| Hashtag | Count |
+-----------------------------------+-------+
| MentionSomeoneImportantForYou | 84 |
| mentionsomeoneimportantforyou | 12 |
| MentionSomeoneBeautiful | 1 |
| mentionyourinternetbestfriend | 1 |
| MentionSomeoneYouLoveAndCareAbout | 1 |
| BAMsingleOutTmrw | 1 |
+-----------------------------------+-------+ Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): exit
Successfully exit!
Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的频率分析的更多相关文章
- Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的词汇多样性分析
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-3 @author: guaguastd @name: tw ...
- Python 对新浪微博的博文元素 (Word, Screen Name)的频率分析
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-9 @author: guaguastd @name: we ...
- Python 新浪微博元素 (Word, Screen Name)词汇多样性
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-10 @author: guaguastd @name: w ...
- 通过遍历而非排序求最值 python list in 时间复杂度 列表元素存在性
Write a function: def solution(A) that, given an array A of N integers, returns the smallest positiv ...
- python——删除列表中的元素
在python中,删除列表元素的方法有三种,分别为remove(),del(),pop()函数 (1)remove() >>> name = ['小明','小华','小红','小李' ...
- python去除列表中重复元素的方法
列表中元素位置的索引用的是L.index 本文实例讲述了Python去除列表中重复元素的方法.分享给大家供大家参考.具体如下: 比较容易记忆的是用内置的set 1 2 3 l1 = ['b','c', ...
- 如何在python列表中查找某个元素的索引
如何在python列表中查找某个元素的索引 2019-03-15 百度上回复别人的问题,几种方式的回答: 1) print('*'*15,'想找出里面有重复数据的索引值','*'*15) listA ...
- Python+Selenium自动化-定位一组元素,单选框、复选框的选中方法
Python+Selenium自动化-定位一组元素,单选框.复选框的选中方法 之前学习了8种定位单个元素的方法,同时webdriver还提供了8种定位一组元素的方法.唯一区别就是在单词elemen ...
- Python+Selenium自动化-定位页面元素的八种方法
Python+Selenium自动化-定位页面元素的八种方法 本篇文字主要学习selenium定位页面元素的集中方法,以百度首页为例子. 0.元素定位方法主要有: id定位:find_elemen ...
随机推荐
- Android实战简易教程-第十枪(画廊组件Gallery有用研究)
Gallery组件用于拖拽浏览图片,以下我们就来看一下怎样实现. 一.实现Gallery 1.布局文件非常easy: <?xml version="1.0" encoding ...
- [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket错误解决方法总结
今天做一个特殊的业务处理,用JDBC连接SQLServer数据库载入驱动的时候,报例如以下错误: java.sql.SQLException: [Microsoft][SQLServer 2000 D ...
- jQuery--百度百科
JQuery是继prototype之后又一个优秀的Javascript库.它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, FF 1.5+, Safari 2.0+, Oper ...
- Linux下Jenkins+git+gradle持续集成环境搭建
Linux下Jenkins+git+gradle持续集成环境搭建 来源:IT165收集 发布日期:2014-08-22 21:45:50 我来说两句(0)收藏本文 一.项目介绍 和 linux ...
- <转>大白菜的后门
转自360论坛
- left与margin-left区别
left,right,top,bottom仅对于position:relative|absolute|fixed的元素有意义. <!DOCTYPE html PUBLIC "-//W3 ...
- 构建基于Javascript的移动web CMS入门——简单介绍
看到项目上的移动框架,网上寻找了一下,发现原来这些一開始都有. 于是,找了个演示样例開始构建一个移动平台的CMS--墨颀 CMS,方便项目深入理解的同一时候.也能够自己维护一个CMS系统. 构建框架 ...
- Subversion和TortoiseSVN安装与配置(转)
Subversion为版本控制软件的服务器端. TortoiseSVN为版本控制软件的客户端. 1.下载Subversion与TortoiseSVN. Subversion的地址:http://sub ...
- GTS、GCK,GSR全称
GTS:Global 3-state buffer delay 全局使能,三态 GCK:Global Clock buffer delay 全局时钟 GSR:Global set/reset bu ...
- iOS9编程GOGOGO:XCode7新变化
做一个关于栈视图 UIStackView的Demo,先看看XCode7的变化 关于StoryBoard: 启动画面由xib变为Storyboard StoryBoard引用: 如今能够在一个Story ...