This repository contains two Python scripts that perform sentiment analysis on recent tweets containing a given keyword. The sentiment polarity of each tweet is extracted using TextBlob and stored in an Elasticsearch index. The second script aggregates the sentiment values stored in Elasticsearch and plots a bar graph of the sentiment distribution.
- docker
- requests
- textblob
- matplotlib
- Start Elasticsearch and Kibana containers by running
docker-compose up -d
- Replace the bearer_token in the first script with a valid Twitter API token.
- Run the first script to index the sentiment of recent tweets containing the query "marvel".
- Run the second script to visualize the sentiment distribution of the indexed tweets.
script.py
: Indexes the sentiment of recent tweets containing the query "marvel".chart.py
: Aggregates the sentiment values stored in Elasticsearch and plots a bar graph of the sentiment distribution.
For more detailed information on this project, see the following Medium articles: