CODE:

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. '''
  5. Created on 2014-7-9
  6. @author: guaguastd
  7. @name: entities_frequency_map.py
  8. '''
  9.  
  10. if __name__ == '__main__':
  11.  
  12. # import Counter
  13. from collections import Counter
  14.  
  15. # import visualize
  16. from visualize import visualize_frequency_map
  17.  
  18. # pip install prettytable
  19. # from prettytable import PrettyTable
  20.  
  21. # import search
  22. from search import search_for_tweet
  23.  
  24. # import login, see http://blog.csdn.net/guaguastd/article/details/31706155
  25. from login import twitter_login
  26.  
  27. # get the twitter access api
  28. twitter_api = twitter_login()
  29.  
  30. # import tweet
  31. from tweet import extract_tweet_entities
  32.  
  33. while 1:
  34. query = raw_input('\nInput the query (eg. #MentionSomeoneImportantForYou, exit to quit): ')
  35.  
  36. if query == 'exit':
  37. print 'Successfully exit!'
  38. break
  39.  
  40. statuses = search_for_tweet(twitter_api, query)
  41. status_texts,screen_names,hashtags,words = extract_tweet_entities(statuses)
  42.  
  43. for label, data in (('Word', words),
  44. ('Screen Name', screen_names),
  45. ('Hashtag', hashtags)):
  46. # Build a frequency map for each set of data and plot the values
  47. c = Counter(data)
  48. sTitle = label
  49. xLabel = "Bins (number of times an item appeared)"
  50. yLabel = "Number of items in bin"
  51. visualize_frequency_map(c.values(), sTitle, xLabel, yLabel)

RESULT:

Python 对Twitter中指定话题的Tweet基本元素的频谱分析的更多相关文章

  1. Python 对Twitter中指定话题的被转载Tweet数量的频谱分析

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

  2. Python 可视化Twitter中指定话题中Tweet的词汇频率

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

  3. Python 查找Twitter中特定话题中最流行的10个转发Tweet

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

  4. python 统计字符串中指定字符出现次数的方法

    python 统计字符串中指定字符出现次数的方法: strs = "They look good and stick good!" count_set = ['look','goo ...

  5. python提取mysql中指定列参数,并循环打印

    试验环境: Python 3.7.0 Mysql 5.0 实验目的: 使用python将数据库中指定的列中的数值取出来,并循环遍历,用以当成参数传递给需要它的方法. 本次实验取的是para列的数据 实 ...

  6. 用 python 修改文件中指定的行数

    #! /bin/python filename='setup.ini' lines=[] with open(filename,'r') as f: lines=f.readlines() lines ...

  7. python 删除文件中指定行

    代码适用情况:xml文件,循环出现某几行,根据这几行中的某个字段删掉这几行这段代码的作用删除jenkins中config.xml中在自动生成pipline报错的时的回滚 start = '<se ...

  8. python返回列表中指定内容的索引

    import numpy as npa=[2,10,2,3,4,10,10]ans = np.where(np.array(a)==10)print(ans) 结果是:(array([1, 5, 6] ...

  9. Python获取list中指定元素的索引

    在平时开发过程中,经常遇到需要在数据中获取特定的元素的信息,如到达目的地最近的车站,橱窗里面最贵的物品等等.怎么办?看下面 方法一: 利用数组自身的特性 list.index(target), 其中a ...

随机推荐

  1. DataGridView大扩展——显示行号

    原文 DataGridView大扩展——显示行号 在DataGridView 的实际使用中,经常需要标示出行号,这样可以比较醒目地看到当前信息.不过DataGridView 在绘制 DataGridV ...

  2. WinCE CAB Manager 3.0学习

    VS自带智能设备打包工具,能实现打包.但是,打包安装部署之后,设备上面没有卸载,找了好多资料,最终都没有解决. WinCE CAB Manager3.0完美解决. 打包步骤如下, 一,打开WinCE ...

  3. java基础程序题

    发现自己初学java时保存在word里的练习题,哈哈,放博客里面来作为纪念吧~~~ [程序1]  题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第四个月后每个月又生一对兔 ...

  4. 【C语言探索之旅】 第二部分第六课:创建你自己的变量类型

    内容简介 1.课程大纲 2.第二部分第六课: 创建你自己的变量类型 3.第二部分第七课预告:   文件读写 课程大纲 我们的课程分为四大部分,每一个部分结束后都会有练习题,并会公布答案.还会带大家用C ...

  5. Web API 数据流使用

    ASP.NET Web API 应用教程(一) ——数据流使用   相信已经有很多文章来介绍ASP.Net Web API 技术,本系列文章主要介绍如何使用数据流,HTTPS,以及可扩展的Web AP ...

  6. XML数据读取方式性能比较(一)

    原文:XML数据读取方式性能比较(一) 几个月来,疑被SOA,一直在和XML操作打交道,SQL差不多又忘光了.现在已经知道,至少有四种常用人XML数据操作方式(好像Java差不多),不过还没有实际比较 ...

  7. C#中调用c++的dll

    C#中调用c++的dll具体创建与调用步骤,亲测有效~   使用的工具是VS2010哦~其他工具暂时还没试过 我新建的工程名是my21dll,所以会生成2个同名文件.接下来需要改动的只有画横线的部分 ...

  8. C++中的class (2)

    class Father { protected void methodA(){ //do something } private void methodB(){//do something } } ...

  9. 聪明的kk

    聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描写叙述 聪明的"KK" 非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘.体现出本 ...

  10. SQL Server 日期相关

    原文:SQL Server 日期相关 原帖出处:http://blog.csdn.net/dba_huangzj/article/details/7657979 对于开发人员来说,日期处理或许简单,或 ...