Python 分析Twitter用户喜爱的推文
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-8-5
@author: guaguastd
@name: analyze_favorite_tweet.py
''' if __name__ == '__main__': # import json
#import json # import search
from search import search_for_tweet # import get_friends_followers_ids
from user import crawl_followers # import login, see http://blog.csdn.net/guaguastd/article/details/31706155
from login import twitter_login # import tweet
from tweet import analyze_favorites_tweet # get the twitter access api
twitter_api = twitter_login() # import twitter_text
import twitter_text 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)
ex = twitter_text.Extractor(statuses) screen_names = ex.extract_mentioned_screen_names_with_indices()
screen_names = [screen_name['screen_name']
for screen_name in screen_names] for screen_name in screen_names:
#print json.dumps(screen_names, indent=1)
analyze_favorites_tweet(twitter_api, screen_name)
RESULT:
Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): Core Python
Length of statuses 59
Number of favorites: 200 Common entities in favorites...
+--------+------------------------+
| Entity | Count |
+--------+------------------------+
| 72 | the |
| 72 | to |
| 57 | a |
| 56 | of |
| 53 | in |
| 44 | on |
| 37 | is |
| 36 | for |
| 34 | and |
| 29 | I |
| 28 | you |
| 24 | my |
| 21 | - |
| 21 | at |
| 19 | with |
| 17 | be |
| 17 | by |
| 15 | talk |
| 15 | are |
| 15 | from |
| 14 | The |
| 14 | this |
| 13 | can |
| 13 | that |
| 13 | snim2 |
| 12 | @snim2 |
| 12 | an |
| 11 | Python |
| 11 | your |
| 11 | about |
| 10 | it |
| 10 | was |
| 10 | all |
| 10 | ep14 |
| 9 | europython |
| 9 | now |
| 9 | or |
| 8 | via |
| 7 | A |
| 7 | Here |
| 7 | if |
| 7 | not |
| 7 | our |
| 7 | have |
| 7 | who |
| 7 | #ep14 |
| 7 | as |
| 6 | new |
| 6 | me |
| 6 | just |
| 6 | #europython |
| 6 | slides |
| 6 | & |
| 5 | concurrency |
| 5 | My |
| 5 | IPython |
| 5 | so |
| 5 | more |
| 5 | paper |
| 5 | also |
| 5 | most |
| 5 | see |
| 5 | available |
| 5 | video |
| 5 | write |
| 5 | out |
| 5 | piece |
| 5 | software |
| 4 | has |
| 4 | when |
| 4 | :) |
| 4 | Research |
| 4 | here: |
| 4 | take |
| 4 | If |
| 4 | being |
| 4 | code |
| 4 | what |
| 4 | help |
| 4 | really |
| 4 | For |
| 4 | some |
| 4 | up |
| 4 | python |
| 4 | This |
| 4 | based |
| 4 | will |
| 4 | You |
| 4 | he |
| 3 | Haskell |
| 3 | @europython |
| 3 | much |
| 3 | photo |
| 3 | #python |
| 3 | easy |
| 3 | post |
| 3 | own |
| 3 | #LGBT |
| 3 | papers |
| 3 | time |
| 3 | Our |
| 3 | Why |
| 3 | answer |
| 3 | first |
| 3 | one |
| 3 | open |
| 3 | than |
| 3 | ep2014 |
| 3 | get |
| 3 | LGBT |
| 3 | Gaza |
| 3 | read |
| 3 | Slides |
| 3 | presentation |
| 3 | large |
| 3 | learned |
| 3 | learn |
| 3 | don't |
| 3 | good |
| 3 | did |
| 3 | Thanks |
| 3 | like |
| 3 | tweets/second |
| 3 | his |
| 3 | wrote |
| 3 | please |
| 3 | Software |
| 3 | analysis |
| 3 | Here's |
| 3 | .. |
| 3 | An |
| 3 | great |
| 3 | use |
| 3 | | |
| 3 | EuroPython |
| 3 | you're |
| 3 | their |
| 3 | but |
| 3 | why |
| 3 | should |
| 3 | means |
| 3 | #ep2014 |
| 3 | keynote |
| 3 | day |
| 3 | know |
| 3 | because |
| 3 | Great |
| 2 | under |
| 2 | Amazon |
| 2 | Church |
| 2 | Group |
| 2 | aware |
| 2 | must |
| 2 | want |
| 2 | how |
| 2 | interview |
| 2 | after |
| 2 | things |
| 2 | feedback |
| 2 | over |
| 2 | them |
| 2 | Check |
| 2 | Shakira |
| 2 | got |
| 2 | messages |
| 2 | days |
| 2 | Please |
| 2 | Notebook |
| 2 | @parallellaboard |
| 2 | “Can |
| 2 | mine |
| 2 | Twisted |
| 2 | do |
| 2 | #concurrency |
| 2 | officially |
| 2 | w/ |
| 2 | John |
| 2 | said |
| 2 | never |
| 2 | I've |
| 2 | been |
| 2 | twistedmatrix |
| 2 | make |
| 2 | jobs. |
| 2 | #EuroPython |
| 2 | Use |
| 2 | way |
| 2 | role |
| 2 | test |
| 2 | update |
| 2 | parallellaboard |
| 2 | daily |
| 2 | Just |
| 2 | MT |
| 2 | MP |
| 2 | It's |
| 2 | following |
| 2 | may |
| 2 | Model |
| 2 | switch |
| 2 | RT |
| 2 | tweets |
| 2 | WeAreN |
| 2 | name |
| 2 | attended |
| 2 | programming |
| 2 | think |
| 2 | message |
| 2 | short |
| 2 | Do |
| 2 | online |
| 2 | science, |
| 2 | #WeAreN |
| 2 | going |
| 2 | Growth |
| 2 | where |
| 2 | #synod |
| 2 | 3 |
| 2 | jobs |
| 2 | many |
| 2 | Jeremy |
| 2 | those |
| 2 | these |
| 2 | engineering |
| 2 | GNU |
| 2 | different |
| 2 | surveillance |
| 2 | week |
| 2 | blog |
| 2 | LindaWoodhead |
| 2 | start |
| 2 | ن |
| 2 | How |
| 2 | watched |
| 2 | trash |
| 2 | #Python |
| 2 | coverage |
| 2 | @LindaWoodhead |
| 2 | remote |
| 2 | consider |
| 2 | program |
| 2 | very |
| 2 | St |
| 2 | Your |
| 2 | github |
| 2 | that's |
| 2 | its |
| 2 | it. |
| 2 | it: |
| 2 | c_of_e |
| 2 | research |
| 2 | together |
| 2 | without |
| 2 | nothing |
| 2 | pre-print |
| 2 | during |
| 2 | Part |
| 2 | last |
| 2 | Steve |
| 2 | point |
| 2 | church |
| 2 | Women |
| 2 | error |
| 2 | arXiv |
| 2 | http://t.co/0yBSWrVaUW |
| 2 | person |
| 2 | Names |
| 2 | docker |
| 2 | Reproducible |
| 2 | source |
| 2 | popular |
| 2 | back |
| 2 | @twistedmatrix |
| 2 | am |
| 2 | < |
| 2 | @PyConUK |
| 2 | AV |
| 2 | Implement |
| 2 | asyncio |
| 2 | Git |
| 2 | try |
| 2 | making |
| 2 | involved |
| 2 | Algorithm?”: |
| 2 | tools |
| 2 | … |
| 2 | Video |
| 2 | links |
| 2 | profile |
| 2 | lines |
| 2 | One |
| 2 | 2015 |
| 2 | Can |
| 2 | lecture |
| 2 | data |
| 2 | need |
| 2 | which |
| 2 | Some |
| 2 | Bishop |
| 2 | fact |
| 2 | local |
| 2 | computer |
| 2 | Good |
| 2 | synod |
| 2 | passing |
| 2 | it's |
| 2 | PyConUK |
| 2 | #asyncio |
| 2 | intro |
| 2 | Oxford |
| 2 | single |
| 2 | latest |
| 2 | CofE |
| 2 | async |
| 2 | Telegraph |
| 2 | growth |
| 2 | Science |
| 2 | problem |
| 2 | this: |
+--------+------------------------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.605255023184
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 0.831932773109
Averge words per tweet: 16.175
Number of favorites: 2 Common entities in favorites...
+--------+-------------+
| Entity | Count |
+--------+-------------+
| 2 | @AndersInno |
| 2 | AndersInno |
+--------+-------------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.9375
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 0.75
Averge words per tweet: 8.0
Number of favorites: 6 Common entities in favorites...
+--------+-------+
| Entity | Count |
+--------+-------+
| 4 | the |
| 3 | to |
| 2 | be |
| 2 | of |
| 2 | this |
| 2 | is |
| 2 | in |
| 2 | I |
| 2 | a |
+--------+-------+ Some statistics about the content of the favorities... Lexical diversity (words): 0.872340425532
Lexical diversity (screen names): 1.0
Lexical diversity (hashtags): 1.0
Averge words per tweet: 15.6666666667
Number of favorites: 0 Common entities in favorites...
+--------+-------+
| Entity | Count |
+--------+-------+
+--------+-------+ Some statistics about the content of the favorities... No statuses to analyze
Python 分析Twitter用户喜爱的推文的更多相关文章
- Python 获取Twitter用户与Friends和Followers的关系(eg, 交集,差集)
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-30 @author: guaguastd @name: f ...
- 在Twitter信息流中大规模应用深度学习——推文的相关度计算使用了深度学习
我们如何对信息流进行排序? 在引入排序算法之前,信息流的组成非常简单:收集所有由你的关注对象在你最后一次登录Twitter之后发送的推文,再将它们按照时间倒序显示出来.这个看起来很简单,但要为数以亿计 ...
- 【Python数据分析】用户通话行为分析
主要工作: 1.对从网上营业厅拿到的用户数据.xls文件,通过Python的xlrd进行解析,计算用户的主叫被叫次数,通话时间,通话时段. 2.使用matplotlib画图包,将分析的结果直观的绘制出 ...
- Python分析44130条用户观影数据,挖掘用户与电影之间的隐藏信息!
01.前言 很多电影也上映,看电影前很多人都喜欢去 『豆瓣』 看影评,所以我爬取44130条 『豆瓣』 的用户观影数据,分析用户之间的关系,电影之间的联系,以及用户和电影之间的隐藏关系. 02.爬取观 ...
- [原创博文] 用Python做统计分析 (Scipy.stats的文档)
[转自] 用Python做统计分析 (Scipy.stats的文档) 对scipy.stats的详细介绍: 这个文档说了以下内容,对python如何做统计分析感兴趣的人可以看看,毕竟Python的库也 ...
- 推文《阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析》笔记
推文<阿里凑单算法首次公开!基于Graph Embedding的打包购商品挖掘系统解析>笔记 从17年5月份开始接触Graph Embedding,学术论文读了很多,但是一直不清楚这技术是 ...
- 用Python分析国庆旅游景点,告诉你哪些地方好玩、便宜、人又少
注:本人参考“裸睡的猪”公众号同名文章,学习使用. 一.目标 使用Python分析出国庆哪些旅游景点:好玩.便宜.人还少的地方,不然拍照都要抢着拍! 二.获取数据 爬取出行网站的旅游景点售票数据,反映 ...
- 五月天的线上演唱会你看了吗?用Python分析网友对这场线上演唱会的看法
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者:CDA数据分析师 豆瓣9.4分!这场线上演唱会到底多好看? 首先让我 ...
- 完成分析 FastAdmin 用户余额功能(后台篇)
分析 FastAdmin 用户余额功能(后台篇) 分析 FastAdmin 用户余额功能(后台篇) 虽然 FastAdmin 主要针对后台的框架,但也在不断完善前台的功能,有一天小伙伴在社区里提了一个 ...
随机推荐
- 史上最强Android 开启照相或者是从本地相册选中一张图片以后先裁剪在保存并显示的讲解附源码
整个程序的布局很简单 只在一个垂直方向上的线性布局里面有俩个按钮(Button)和一个显示图片的控件(ImageView)这里就不给出这部分的代码了 1.是打开系统的相册 Intent alb ...
- 基于visual Studio2013解决面试题之1409基数排序
题目
- 将某个MySQL库中的UTF8字符列都转成GBK格式
DELIMITER $$ DROP PROCEDURE IF EXISTS `dba`.`Proc_ChangeCharacter2GBK`$$ CREATE DEFINER=`root`@`%` P ...
- hdu3999The order of a Tree (二叉平衡树(AVL))
Problem Description As we know,the shape of a binary search tree is greatly related to the order of ...
- Python标准库:内置函数dict(**kwarg)
本函数是从一个字典參数构造一个新字典.參数kwarg是键值对的字典參数.以两个*开头的參数.就会收集成字典形式. 样例: #dict() #以键对方式构造字典 d1 = dict(one = 1, t ...
- 初入Android--Activate生命周期
Activate的主要生命周期 (注意:这只是主要的生命周期,而不是完整的生命周期方法,其中的两个周期之间可能还执行了其他的一些方法) 每个时刻在屏幕上的状态 进入onCreate方法:Activat ...
- STM32的FSMC总线复用调试笔记
调试FSMC总线复用模式时主要遇到以下几点: 1.寄存器的配置,首先注意使能地址数据复用,其次要存储器类型选择FSMC_MemoryType_NOR,否则出现不了NADV信号. FSMC_NORSRA ...
- 设计模式6:Composite
Entry.java: package gendwang.cisco.com; public abstract class Entry { private int height = 0; privat ...
- 在MyEclipse中复制web工程时要注意的事项
有时候我们要在MyEclipse中将一个WEB工程进行复制,然后将工程名进行重命名,但这样还是会出错,因为只改变工程名还不够,一般在MyEclipse中WEB工程的[WebRoot]目录名和工程名是一 ...
- 【ASP.NET Web API教程】2.4 创建Web API的帮助页面
原文:[ASP.NET Web API教程]2.4 创建Web API的帮助页面 注:本文是[ASP.NET Web API系列教程]的一部分,如果您是第一次看本博客文章,请先看前面的内容. 2.4 ...