Python program that analyzes the sentiment of a tweet placing it into one of three categories; positive, negative, or neutral.
This program operates by linking together a few different api's in order to display the final output. The program first accesses twitter's and AWS Amazon Comprehend's apis by authentication via a series of keys given to the user after they have created accounts with these services. Next, the tweets of the user you are analyzing are called and parsed with into text and are then analyzed by the Amazon Comprehend api. Documentation regarding how this api can detect whether a body of text can be positive, negative or neutral can be found here. Each tweet analyzed increased the value of one of the following: positive, negative, neutral. After all of the tweets have been analyzed, the user is then displayed a pie chart of the returned data using the plot.ly web service.
- This program requires you to use a twitter development account in order to access their api which will allow you to fetch the tweets from the user you are analyzing.
- After your account has been created and approved, you will be able to use the keys provided for you in order to access twitters api.
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
- TWITTER_ACCESS_TOKEN_KEY
- TWITTER_ACCESS_TOKEN_SECRET
- You will need to create an AWS account to use the Amazon Comprehend api.
- AWS_ACCESS_KEY
- AWS_SECRET_KEY
- Import the following libraries into your project's interpreter
- PLOTLY
- BOTO3
- PYTHON-TWITTER
- Enter the required keys you gathered from the steps above.
- Enter the twitter username of the account's tweets you wish to analyze, and change the number of recent tweets you wish to analyze. The default is fifty, but you can analyze up to two-hundred tweets every call.