Skip to content

Sentiment/subjectivity analysis on twitter posts using Tweepy, TextBlob, matplotlib

Notifications You must be signed in to change notification settings

osurob/twitter-sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Twitter sentiment and subjectivity analysis

Sentiment/subjectivity analysis on twitter posts using Tweepy, TextBlob, matplotlib

Dataset information

In order to gather information from twitter I used the tweepy API to collectively create a representative dataset. The dataset is gathered through searching for posts that contain a relevant keyword.

This keyword is indicated here as Love. public_tweets = api.search(q='Love',count = 100)

Requirements/Dependencies

There are some general library requirements for the project and some which are specific to individual methods. The general requirements are as follows.

-> Tweepy

-> Textblob

-> Termcolor

-> csv

-> matplotlib.pyplot

-> Twitter account

Usage

  1. In order to use the code you must have the listed dependencies installed.
  2. Clone the github repo
  3. Go to https://developer.twitter.com/en/apps and create new app, fill out information and get Consumer key/secret and access token/secret.
  4. Open the twitterSentiment.py file and change the consumer_key, consumer_secret, access_token, and access_key to the twitter app api information you got from the previous step.
  5. public_tweets = api.search(q='Love',count = 100) Change "Love" to the keyword
  6. Open terminal, and run python twitterSentiment.py OR python3 twitterSentimen.py if you have python3 installed.
  7. A CSV file will be saved to the local directory including 100 posts, their username, subjectivity level, and sentiment level.
  8. A plot will be displayed using the CSV file to visually present sentiment and subjectivity level for the keyword.

About

Sentiment/subjectivity analysis on twitter posts using Tweepy, TextBlob, matplotlib

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages