Twitter Sentiment Analysis Challenge for Learn Python for Data Science #2 by @Sirajology on Youtube
This is the code for the Twitter Sentiment Analyzer challenge for 'Learn Python for Data Science #2' by @Sirajology on YouTube. The code uses the tweepy library to access the Twitter API and the TextBlob library to perform Sentiment Analysis on each Tweet. We'll be able to see how positive or negative each tweet is about whatever topic we choose.
- tweepy (http://www.tweepy.org/)
- textblob (https://textblob.readthedocs.io/en/dev/)
Install missing dependencies using pip
Once you have your dependencies installed via pip, run the script in terminal via
python demo.py
Instead of printing out each tweet, save each Tweet to a CSV file with an associated label. The label should be either 'Positive' or 'Negative'. You can define the sentiment polarity threshold yourself, whatever you think constitutes a tweet being positive/negative. Push your code repository to github then post it in the comments. I'll give the winner a shoutout a week from now!
This code challenge is given by Siraj and challenge completed by Tirth
To save the tweets with it polarity in csv:
Get the public tweets
Make a row in csv file with label "Tweets and Polarity"
Perform the sentiment analysis on tweets and store it in variable
Csv file does not support write column operation, therefore store the tweets with its polarity in variable
Zip the collected tweets with its polarity. Zip perform row to column operation
Write the stored zip into csv
Done