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. win7上搭建ruby开发环境

    1. 安装ruby 可使用windows下的ruby安装工具rubyinstaller来方便地安装ruby解释器,可以http://rubyinstaller.org/网站上下载得到.安装时,看清安装 ...

  2. 转:从零开始做app需要做的事情列表

    https://qdan.me/list/VaXl7N8emfv1ayWg 从零开始做App的Bootstrap 做一个App,需要很多东西. 不定期更新. 团队 工欲善其事,必先利其器. 需求管理 ...

  3. java 入门-helloWorld

    Java 教程 Java 是由Sun Microsystems公司于1995年5月推出的高级程序设计语言. Java可运行于多个平台,如Windows, Mac OS,及其他多种UNIX版本的系统. ...

  4. tcp/ip ---以太网和IEEE 802封装

    以太网 它是当今T C P / I P采用的主要的局域网技术.它采用一种称作C S M A / C D的媒体接入方法,其意思是带冲突检测的载波侦听多路接入(Carrier Sense, Multipl ...

  5. android自定义View&&简单布局&&回调方法

    一.内容描述 根据“慕课网”上的教程,实现一个自定义的View,且该View中使用自定义的属性,同时为该自定义的View定义点击事件的回调方法. 二.定义自定义的属性 在res/valus/ 文件夹下 ...

  6. cordova开发自己定义插件

    以下是自己定义cordova插件的基本入门.做插件的小白可以參考一下哈,兴许会更新插件的进阶博客,希望大家可以共同学习共同进步 1.环境搭建 cordova插件开发前须要安装一些软件和配置环境 1.1 ...

  7. PHP+Redis 实例 页面缓存

    前提分析! 上面的图,我分为了三个层级去做页面缓存,其实不一定要三个层面都实现的,如果你做了页面级的,项目初期是够了,作为接口级,基本可以解决很多吞吐量. 对于上面的三个层级,我用了同一个方法去做. ...

  8. mysql group by 与order by的实例分析(mysql分组统计后最大值)

    CREATE TABLE `test` ( `id` ) NOT NULL AUTO_INCREMENT, `name` ) CHARACTER SET latin1 DEFAULT NULL, `c ...

  9. ASP.NET MVC Razor 输出没有编码的HTML字符串

    Razor引擎之前要输出一段没有编码的字符串,只要@加变量名就可以了,Razor却不能这样,感觉是有点麻烦. 在Razor Beta 2以前的版本可以: @(new HtmlString(mystri ...

  10. codeforces Round #Pi (div.2) 567ABCD

    567A Lineland Mail题意:一些城市在一个x轴上,他们之间非常喜欢写信交流.送信的费用就是两个城市之间的距离,问每个城市写一封信给其它城市所花费的最小费用和最大的费用. 没什么好说的.直 ...