zoukankan      html  css  js  c++  java
  • 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 visualize_frequency_map
        
        # pip install prettytable
        # from prettytable import PrettyTable
    
        # 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('
    Input 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)):
                # Build a frequency map for each set of data and plot the values
                c = Counter(data)
                sTitle = label
                xLabel = "Bins (number of times an item appeared)"
                yLabel = "Number of items in bin"
                visualize_frequency_map(c.values(), sTitle, xLabel, yLabel)

    RESULT:






  • 相关阅读:
    appium 命令安装记录
    用命令方式启动、停止appium服务和app
    adb连接网易mumu模拟器
    获取APP包名,launcherActivity
    jekins配置
    Appium工作原理
    关于An association from the table XX refers to an unmapped class错误
    什么是MYSQL回表查询
    MySQL的in和or的效率问题
    MYSQL语句优化
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4217731.html
Copyright © 2011-2022 走看看