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)的频率分析的更多相关文章

  1. Python 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的词汇多样性分析

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-3 @author: guaguastd @name: tw ...

  2. Python 对新浪微博的博文元素 (Word, Screen Name)的频率分析

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-9 @author: guaguastd @name: we ...

  3. Python 新浪微博元素 (Word, Screen Name)词汇多样性

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-10 @author: guaguastd @name: w ...

  4. 通过遍历而非排序求最值 python list in 时间复杂度 列表元素存在性

    Write a function: def solution(A) that, given an array A of N integers, returns the smallest positiv ...

  5. python——删除列表中的元素

    在python中,删除列表元素的方法有三种,分别为remove(),del(),pop()函数 (1)remove() >>> name = ['小明','小华','小红','小李' ...

  6. python去除列表中重复元素的方法

    列表中元素位置的索引用的是L.index 本文实例讲述了Python去除列表中重复元素的方法.分享给大家供大家参考.具体如下: 比较容易记忆的是用内置的set 1 2 3 l1 = ['b','c', ...

  7. 如何在python列表中查找某个元素的索引

    如何在python列表中查找某个元素的索引 2019-03-15 百度上回复别人的问题,几种方式的回答: 1) print('*'*15,'想找出里面有重复数据的索引值','*'*15) listA ...

  8. Python+Selenium自动化-定位一组元素,单选框、复选框的选中方法

    Python+Selenium自动化-定位一组元素,单选框.复选框的选中方法   之前学习了8种定位单个元素的方法,同时webdriver还提供了8种定位一组元素的方法.唯一区别就是在单词elemen ...

  9. Python+Selenium自动化-定位页面元素的八种方法

    Python+Selenium自动化-定位页面元素的八种方法   本篇文字主要学习selenium定位页面元素的集中方法,以百度首页为例子. 0.元素定位方法主要有: id定位:find_elemen ...

随机推荐

  1. 多个客户端连接socket

    import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import ...

  2. hdu1698 Just a Hook (线段树区间更新 懒惰标记)

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  3. Drawing-Order-Of-meshes-and-sprites

    Sprite 和 Mesh Render 共存 [CanEditMultipleObjects] [CustomEditor(typeof(MeshRenderer))] public class M ...

  4. 查看tomcat启动文件都干点啥---catalina.bat

    在上一次查看tomcat启动文件都干点啥一文中,我们总结出,startup.bat文件的作用就是找到catalina.bat文件,然后把参数传递给它,在startup.bat中,调用catalina. ...

  5. 挖一挖C#中那些我们不经常使用的东西之系列(1)——ToDictionary,ToLookup

    这个系列我们看看C#中有哪些我们知道.可是又不知道怎么用.又或者懒得去了解的东西,比方这篇我们要介绍的toDictionary 和ToLookup. 从图中我们看到有四个ToXXX的方法,当中ToAr ...

  6. 2014哈商大ICPC/ACM校赛解题报告

    被debug邀请去參加校赛,哎,被虐..我对不起工大.. 由于本人不搞ACM,算法处于HelloWorld水准.. 虽然题目除了鸟不拉屎星人之外都非常水,但我能做到这个程度,全然是超水平发挥了.. 数 ...

  7. (一)Redis笔记——简介 、key 、数据类型

    1.  Redis是什么.特点.优势 Redis是一个开源的使用C语言编写.开源.支持网络.可基于内存亦可持久化的日志型.高性能的Key-Value数据库,并提供多种语言的API. 它通常被称为数据结 ...

  8. jumpserver-v0.5.0 应用图解

    一. Jumpserver启动 Python: 版本 3.6 1.1 启动Jumpserver 先进入Python虚拟环境 [root@localhost ~]# source /opt/py3/bi ...

  9. <转 >socket穿透代理代码(C++版)

    本文转自 http://blog.csdn.net/bodybo/article/details/7274865 写代码经常会遇到socket要通过代理连接服务器的情况,代理类型通畅有三种:HTTP. ...

  10. MATLAB 的通用命令

    MATLAB 的通用命令 1.MATLAB 的标点符号及其特殊功能. 2.MATLAB 的键盘按键及其特殊功能. ↑或者Ctrl+p:调用上一次的命令 ↓或者Ctrl+n:调用下一行的命令 ←或者Ct ...