A spectral analysis of the basic elements of Python's tweet on a given topic in Twitter

Source: Internet
Author: User

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 Searc H from search import Search_for_tweet # import login, see http://blog.csdn.net/guaguastd/article/details/317  06155 from login Import Twitter_login # Get the twitter access API Twitter_api = Twitter_login () # import Tweets from tweets import extract_tweet_entities while 1:query = Raw_input (' \ninput the query (eg. #MentionSo            Meoneimportantforyou, 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 the 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)" Y Label = "Number of items in Bin" Visualize_frequency_map (C.values (), Stitle, Xlabel, Ylabel)

RESULT:






A spectral analysis of the basic elements of Python's tweet on a given topic in Twitter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.