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

CODE:

#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Created on 2014-7-8
@author: guaguastd
@name: plot_frequencies_words.py
'''

if __name__ == '__main__':
    #import json

    # import Counter
    from collections import Counter

    # import search
    from search import search_for_tweet

    # import visualize
    from visualize import visualize_for_frequencies

    # 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)  

        word_counts = sorted(Counter(words).values(), reverse=True)
        visualize_for_frequencies(word_counts, "Word Rank", "Freq")

RESULT:

Input the query (eg. #MentionSomeoneImportantForYou, exit to quit): #MentionSomeoneImportantForYou
Length of statuses 100
Length of statuses 196

Python 可视化Twitter中指定话题中Tweet的词汇频率,布布扣,bubuko.com

时间: 2024-08-01 10:44:27

Python 可视化Twitter中指定话题中Tweet的词汇频率的相关文章

Python 对Twitter中指定话题的Tweet基本元素的频谱分析

CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-9 @author: guaguastd @name: entities_frequency_map.py ''' if __name__ == '__main__': # import Counter from collections import Counter # import visualize from visualize import visua

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

CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-10 @author: guaguastd @name: retweet_frequency_map.py ''' if __name__ == '__main__': # import visualize from visualize import visualize_frequency_map # pip install prettytable # fr

JavaSE8基础 Arrays.sort 一维int数组中指定范围中的成员进行升序排列

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku2; import java.util.Arrays; public class Demo101 { public static void main(String[] args) { int[] nums = new int[] {1,23,1222,4,5,5,6,1243

Python 提取Twitter特定话题中转载tweet的用户

CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-7 @author: guaguastd @name: user_retweet_statuses.py ''' if __name__ == '__main__': # import login, see http://blog.csdn.net/guaguastd/article/details/31706155 from login import tw

Python 查找Twitter中最流行(转载最多)的10个Tweet

CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-4 @author: guaguastd @name: find_popular_retweets.py ''' # Finding the most popular retweets def popular_retweets(statuses): retweets = [ # Store out a tuple of these three values.

Python 提取Twitter tweets中的元素(包含text, screen names, hashtags)

#!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-1 @author: guaguastd @name: tweets.py ''' import json # import search, see http://blog.csdn.net/guaguastd/article/details/35537781 from search import search # import login, see http://bl

python xpath 获取指定页面中指定区域的html代码

最近一个朋友问我怎么把一个指定区域的内容转成pdf,网上查了一下python里面有个wkhtmltopdf模块可以将str.file.url转成pdf,我们今天不聊怎么转PDF,聊聊怎么获取页面中指定区域的html源码.用到的模块是lxml和requests这两个模块,没有装的小伙伴可以装一下 pip install  lxml requests 主要思想是利用xpath获取到指定区域的Element对象,然后再将Element对象传给etree.tostring(),即可得到指定区域的html

Ubuntu18.0 解决python虚拟环境中不同用户下或者python多版本环境中指定虚拟环境的使用问题

一. 不同用户下配置virtualenvwrapper的问题 问题描述: 安装virtualnev和virtualnevwrapper之后,在.bashrc进行virtualenvwrapper的相关配置后重新加载.bashrc文件时报错. 报错内容大致如下: /usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization

Kafka深度解析(如何在producer中指定partition)(转)

原文链接:Kafka深度解析 背景介绍 Kafka简介 Kafka是一种分布式的,基于发布/订阅的消息系统.主要设计目标如下: 以时间复杂度为O(1)的方式提供消息持久化能力,即使对TB级以上数据也能保证常数时间的访问性能 高吞吐率.即使在非常廉价的商用机器上也能做到单机支持每秒100K条消息的传输 支持Kafka Server间的消息分区,及分布式消费,同时保证每个partition内的消息顺序传输 同时支持离线数据处理和实时数据处理 为什么要用消息系统 解耦在项目启动之初来预测将来项目会碰到