Provides a look at a user's polarity and subjectivity on twitter using the TextBlob library
- Install the Natural Language Toolkit from its website
- Make sure you install all of NLTK's prerequisites
- Install TextBlob from its website
- Install Tweepy using the instructions on their GitHub page
-
You can either use
pip install tweepy
orgit clone https://github.com/tweepy/tweepy.git python setup.py install
- Make sure you have a consumer key and secret generated by registering for a new api key on Twitter's developer page
- From the terminal, type
python [path/to/twitter-persona.py] [key] [secret] [user_to_analyze] [tweet_count] [include_retweets]
- Make sure you replace the objects in brackets with valid values
- Twitter's API will return at most 800 tweets.
This is an example of what results from running the script using @macklemore:
python twitter-persona.py [redacted_key] [redacted_secret] "Macklemore" 500 False
Average Polarity of Tweets: 0.151289301423
Average Subjectivity of Tweets: 0.347877407229
Most Negative Tweet: I picked the wrong night to drink 2 energy drinks.... Can't sleep. Can't wait. LETS GO!!!!!!! #seahawks http://t.co/YHfWiM7t4L
Most Positive Tweet: Leonardo blocking out the haters. He can't see you. My best friend. #pals #animals&me #fox #vintageGǪ http://t.co/LEDfOuEJTW
Most Objective Tweet: Seahawks plane headed to NYC.....TURN UP!!!!!!! #superbowl #seahawks http://t.co/fM6JpfnT7H
Most Subjective Tweet: SEATTLE... I'm pumped to announce that for our Key Arena show on the 11th we're bringing out Sir Mix-AGǪ http://t.co/v3XMmvD6hT