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. mvn test 中文乱码

    有两种解决办法: 1.设置encoding:<argLine>-Dfile.encoding=UTF-8</argLine>,解决读取文件中的中文乱码问题 2.升级maven- ...

  2. Implementing DDD Reading - Strategic Design

    1. 概念篇 1.1 领域 广义上讲,领域即是一个组织所做的事情以及其中所包含的一切,也是组织的业务范围以及在其中所进行的活动.软件所讨论的领域即是这个组织的领域,应该是清晰明确的.不同的层面或粒度, ...

  3. 蓝鲸安装Agent

    1. APPO 所在机器(在 app 运行所在机器) 必须能通过 ssh 登陆到 Agent 机器2. Agent 所在机器可以访问到 zk 的端口3. 支持 Linux/Windows/AIX 操作 ...

  4. Java ActiveMQ队列模式案例

    创建Eclipse项目并运行 创建java project:ActiveMQ-5.14,新建lib文件夹 打开apache-activemq-5.14.0-bin\apache-activemq-5. ...

  5. No goals have been specified for this build 解决方案

    运行maven报错:[ERROR] No goals have been specified for this build. You must specify a valid lifecycle ph ...

  6. Java 多线程之 synchronized 和 volatile 的比較

    概述 在做多线程并发处理时,常常须要对资源进行可见性訪问和相互排斥同步操作.有时候,我们可能从前辈那里得知我们须要对资源进行 volatile 或是 synchronized 关键字修饰处理.但是,我 ...

  7. 可伸缩Web架构与分布式系统(2)

    开源软件近年来已变为构建一些大型网站的基础组件.并且伴随着网站的成长,围绕着它们架构的最佳实践和指导准则已经显露.这篇文章旨在涉及一些在设计大型网站时需要考虑的关键问题和一些为达到这些目标所使用的组件 ...

  8. MPTCP 源码分析(七) 拥塞控制

    简述      MPTCP的拥塞控制对TCP的拥塞控制的线性增加阶段进行了修改,而慢启动,快速重传. 快速恢复都没有改变.每条子路径拥有自己的cwnd,MPTCP的拥塞算法主要关心cwnd的改变.   ...

  9. Java 遍历一个对象的属性 将非空属性赋值给另一个对象

    //将origin属性注入到destination中 public <T> void mergeObject(T origin, T destination) { if (origin = ...

  10. pandas 绘图与滑窗

    #import nessary library before start import pandas as pd import numpy as np import matplotlib.pyplot ...