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 ...
随机推荐
- Shell实现循环执行curl向Solr导入json文件
#!/bin/bash for file in ./文件夹名/* do echo $file curl "http://IP:8983/solr/集合名/update?commit=true ...
- tomcat环境部署
环境说明 系统版本 CentOS 7.2 x86_64 软件版本 jdk-8u171 tomcat-8.0.27 1.tomcat介绍及软件包准备 Tomcat是Apache软件基金会 ...
- [Angular] Control the dependency lookup with @Host, @Self, @SkipSelf and @Optional
Very differently to AngularJS (v1.x), Angular now has a hierarchical dependency injector. That allow ...
- HTML5 Canvas 绘制库存变化折线 计算出库存周转率
<!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Type&quo ...
- html5学习整理-0311
整理一下今天所学的一些标签内容. 首先说一下DNS:全称Domain Name System,域名系统.是因特网上作为域名和IP地址相互映射的一个分布式数据库. URL协议:规定URL地址的格式,UR ...
- Docker默认存储路径修改
Docker默认存储路径: # docker info...... Data loop file: /var/lib/docker/devicemapper/devicemapper/data.... ...
- javascript入门系列演示·三种弹出对话框的用法实例
对话框有三种 1:只是提醒,不能对脚本产生任何改变: 2:一般用于确认,返回 true 或者 false ,所以可以轻松用于 if...else...判断 3: 一个带输入的对话框,可以返回用户填入的 ...
- 用JDOM读取XML文件
用JDOM读取XML文件需先用org.jdom.input.SAXBuilder对象的build()方法创建Document对象,然后用Document类.Element类等的方法读取所需的内容.IB ...
- Atitit.编程语言的基础句型and汉语英文比较
Atitit.编程语言的基础句型and汉语英文比较 1. 编程语言常见的句型1 1.1. Verb(obj)1 1.2. If then else1 1.3. For1 2. 英语中的五种基本句型结 ...
- [na]esxi6.5的vmware安装
安装exsi6.5(最新的软件见评论区) ,安装 ,激活(可选) ,浏览器登录(.5好像没客户端了,所以就用浏览器,挺方便的) 安装包和key包在网盘里: 链接:https://pan.baidu.c ...