Python 新浪微博元素 (Word, Screen Name)词汇多样性
CODE:
#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-7-10
@author: guaguastd
@name: weiboLexicalDiversity.py
''' if __name__ == '__main__': # get weibo_api to access sina api
from sinaWeiboLogin import sinaWeiboLogin
sinaWeiboApi = sinaWeiboLogin() # import sinaWeibo
from sinaWeibo import extractWeiboEntities # import sinaWeoboStatuses
from sinaWeiboStatuses import publicTimeline # import sinaWeiboFrequency
from sinaWeiboLexicalDiversity import weibo_lexical_diversity, weibo_average_words # get the new 5 weibo
weiboNum = 5
statuses = publicTimeline(sinaWeiboApi, weiboNum)
status_texts,screen_names,words = extractWeiboEntities(statuses) for token in (words, screen_names):
print '\rLexical diversity of %s: ' % token
print weibo_lexical_diversity(token) for status in (status_texts,):
print '\rAverage words of %s: ' % status
print weibo_average_words(status)
RESULT:
Lexical diversity of [u'[moc\u8f6c\u53d1]2014\u65b0\u6b3e\u590f\u88c5\u5370\u82b1\u77ed\u8896\u8fde\u8863\u88d9\u9ad8\u7aef\u5927\u7801\u4e2d\u5e74\u5973\u88c5\u4fee\u8eab\u663e\u7626\u857e\u4e1d\u8fde\u8863\u88d9', u'http://t.cn/RvCLdgN', u'[\u795e\u9a6c]\u963f\u4f9d\u83b2\u8fde\u8863\u88d9', u'ccdd\u5973\u88c52014\u590f\u88c5\u65b0\u6b3e', u'\u97e9\u7248', u'\u5c0f\u9999\u98ce\u857e\u4e1d\u516c\u4e3b\u88d9', u'\u6b63\u54c1', u'http://t.cn/RvCyo4X', u'\u590f\u65e5\u5ea6\u5047\u6e05\u51c9\u88c5~~>>>>>>\u559c\u6b22\u70b9\u8fd9\u91cc\uff1ahttp://t.cn/RvEqd5R', u'\u6211\u6b63\u5728\u6b66\u4fa0\u5361\u724c\u624b\u6e38\u201c\u5927\u638c\u95e8\u201d\u4e2d\u51b2\u51fb\u8840\u6218\u699c\u5355\uff0c\u613f\u5404\u4f4d\u5927\u4fa0\u62d4\u5200\u76f8\u52a9\uff01\u6ce8\u518c\u5927\u638c\u95e8\uff0c\u586b\u5199\u6211\u7684\u9080\u8bf7\u7801\u30102zr7\u3011\uff0c\u5171\u540c\u83b7\u53d6\u4e30\u539a\u5956\u52b1\u3002http://t.cn/8FUZSTe', u'@\u5927\u638c\u95e8\u6e38\u620f', u'\u8f7b\u8f68\u65e9\u4e0a\u7684\u7a7a\u8c03\u5f00\u5f97\u7565\u5927']:
1.0 Lexical diversity of [u'kathyisangel', u'wangbinrona', u'\u5168\u7403\u6d41\u884c\u670d\u9970\u6f6e\u7f8e\u98ce\u5c1a\u63a7', u'\u624b\u673a\u7528\u62372454403221', u'\u6b63\u76f4\u4f60\u4e00\u8138\u7684\u52c7\u6562\u541b']:
1.0 Average words of [u'[moc\u8f6c\u53d1]2014\u65b0\u6b3e\u590f\u88c5\u5370\u82b1\u77ed\u8896\u8fde\u8863\u88d9\u9ad8\u7aef\u5927\u7801\u4e2d\u5e74\u5973\u88c5\u4fee\u8eab\u663e\u7626\u857e\u4e1d\u8fde\u8863\u88d9 http://t.cn/RvCLdgN', u'[\u795e\u9a6c]\u963f\u4f9d\u83b2\u8fde\u8863\u88d9 ccdd\u5973\u88c52014\u590f\u88c5\u65b0\u6b3e \u97e9\u7248 \u5c0f\u9999\u98ce\u857e\u4e1d\u516c\u4e3b\u88d9 \u6b63\u54c1 http://t.cn/RvCyo4X', u'\u590f\u65e5\u5ea6\u5047\u6e05\u51c9\u88c5~~>>>>>>\u559c\u6b22\u70b9\u8fd9\u91cc\uff1ahttp://t.cn/RvEqd5R', u'\u6211\u6b63\u5728\u6b66\u4fa0\u5361\u724c\u624b\u6e38\u201c\u5927\u638c\u95e8\u201d\u4e2d\u51b2\u51fb\u8840\u6218\u699c\u5355\uff0c\u613f\u5404\u4f4d\u5927\u4fa0\u62d4\u5200\u76f8\u52a9\uff01\u6ce8\u518c\u5927\u638c\u95e8\uff0c\u586b\u5199\u6211\u7684\u9080\u8bf7\u7801\u30102zr7\u3011\uff0c\u5171\u540c\u83b7\u53d6\u4e30\u539a\u5956\u52b1\u3002http://t.cn/8FUZSTe @\u5927\u638c\u95e8\u6e38\u620f ', u'\u8f7b\u8f68\u65e9\u4e0a\u7684\u7a7a\u8c03\u5f00\u5f97\u7565\u5927']:
2.4
Python 新浪微博元素 (Word, Screen Name)词汇多样性的更多相关文章
- 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 对Twitter tweet的元素 (Word, Screen Name, Hash Tag)的频率分析
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-2 @author: guaguastd @name: tw ...
- 【NLP】Python NLTK获取文本语料和词汇资源
Python NLTK 获取文本语料和词汇资源 作者:白宁超 2016年11月7日13:15:24 摘要:NLTK是由宾夕法尼亚大学计算机和信息科学使用python语言实现的一种自然语言工具包,其收集 ...
- python统计元素重复次数
python统计元素重复次数 # !/usr/bin/python3.4 # -*- coding: utf-8 -*- from collections import Counter arr = [ ...
- python如何转换word格式、读取word内容、转成html
# python如何转换word格式.读取word内容.转成html? import docx from win32com import client as wc # 首先将doc转换成docx wo ...
- Python Appium 元素定位方法简单介绍
Python Appium 元素定位 常用的八种定位方法(与selenium通用) # id定位 driver.find_element_by_id() # name定位 driver.find_ ...
- 借助python工具从word文件中抽取相关表的定义,最后组装建表语句-非常好
借助python工具从word文件中抽取表的定义,最后组装建表语句-非常好 --如有转载请以超链接的方式注明原文章出处,谢谢大家.请尊重每一位乐于分享的原创者 1.python脚本 ## -*- co ...
- python+selenium 元素被定位到而且click()也提示执行成功,但是页面就是没有变化和跳转。
python+selenium 元素被定位到而且click()也提示执行成功,但是页面就是没有变化和跳转. 如果多次定位和click(),有时候会跳转. 我遇到很多次就是很郁闷,有人说,操作太快的,页 ...
随机推荐
- 如何将UISearchBar上"Cancel"按钮改为”取消“?
别说话,直接上代码 for (id obj in [searchBar subviews]) { if ([obj isKindOfClass:[UIView class]]) { ...
- Java中的位运算符、移位运算
一.位运算 Java中有4个位运算,它们的运算规则如下: (1)按位与 (&) :两位全为1,结果为1,否则为0: (2)按位或 (|) :两位有一个为1,结果为1,否则为0: (3) ...
- Can't connect to MySQL server on 'XXX' (13)
出现can't connect to MySQL server using '' (13)的错误,结果是 SELinux 不让 httpd 访问外网,一开始还以为是iptables造成的,关闭之后发现 ...
- WCF技术剖析之二十八:自己动手获取元数据[附源代码下载]
原文:WCF技术剖析之二十八:自己动手获取元数据[附源代码下载] 元数据的发布方式决定了元数据的获取行为,WCF服务元数据架构体系通过ServiceMetadataBehavior实现了基于WS-ME ...
- URAL 1792. Hamming Code (枚举)
1792. Hamming Code Time limit: 1.0 second Memory limit: 64 MB Let us consider four disks intersectin ...
- 使用aidl绑定远程服务
一.服务端 1.清单文件,因为要远程调用,所以要配个action <service android:name="com.example.alipayservice.AliPayServ ...
- 在WPF的DATAGRID中快速点击出现在ADDNEW或EDITITEM事务过程不允许DEFERREFRESH
原文 在WPF的DATAGRID中快速点击出现在ADDNEW或EDITITEM事务过程不允许DEFERREFRESH 在项目中关于DataGrid的遇到过一些问题,其中是关于迁入CheckBox的双向 ...
- 立波 iphone3gs越狱教程:成功把iphone3gs手机升级成ios6.1.3系统,完美越狱,解决no service和耗电量大的问题
前几天,老婆使用的iphone3gs摔地了,把手机里的连接电源的那个神马线给搞坏了,结果花了200多块大洋修好了: 修好后,老婆抱怨道:5年了,这手机好多软件都装不上,说手机版本号太低了, 我就说凑合 ...
- 8天玩转并行开发——第二天 Task的使用
原文 8天玩转并行开发——第二天 Task的使用 在我们了解Task之前,如果我们要使用多核的功能可能就会自己来开线程,然而这种线程模型在.net 4.0之后被一种称为基于 “任务的编程模型”所冲击, ...
- HTML5 input placeholder 颜色 改动
David Murdoch:Chrome支持input=[type=text]占位文本属性,但下列CSS样式却不起作用: CSS input[placeholder], [placeholder], ...