Tweety is our CS172 final project that runs on a web browser that takes query terms from the user and returns the top tweets with the query. We stream tweets using Tweepy and perform indexing using ElasticSearch. We have also implemented sentiment analysis using TextBlob. We then display the tweets on a world map using folium.
To run Tweepy streamer:
- Create a twitter account and apply for twitter developer account
- After creating an account, find your api key, secret key, access token, and secret token under Keys and Access Tokens and add to stream.py
sudo pip install tweepy
to install tweepy- Run
python stream.py
- Collected tweets will be stored in a file named `CS_data.json'
To run the web interface files, use python 3.7.1, Django 2.1.7, Elasticsearch-dsl 6.3.1, textblob 0.15.3, and folium 0.8.2.
To install the libraries
pip3 install Django
pip3 install elasticsearch-dsl
pip3 install folium
pip3 install -U textblob
pip3 install xlrd
python3 -m textblob.download_corpora
Note: Depending on the system you are using, you may need a different variation of pip3 and python3 or simply pip and python to run the installs. Make sure the versions you download are the same as the ones listed above. To view the list run pip list
To run the sever:
- Move to CS172_Project directory by
cd CS172_Project
Note: Django creates two directories with the same name by default, one is a subdirectory. You must be in the first CS172_Project directory such that you can see the following files: manage.py, db.sqlite3, main/, pycache/,CS172_Project
- Run the server:
python3 manage.py runserver
- To stop the server:
CTRL+C
There are multiple ways to run ElasticSeach, however it must always remain running in the background of this program. To download the package
- Go to Elastic Search.
- Download and unzip the file.
- Run
bin/elasticsearch
- At command line, navigate to the main directory and run
curl -X POST "localhost:9200/_bulk" -H "Content-Type: application/json" --data-binary @tweet_index.json
The file name will be the file output by json_to_es.py
-
Open browser at Localhost
-
It should display status of ElasticSearch
To run the web browser, make sure both the server and ElasticSearch are running in the backgroud, open web browser and type:
http://127.0.0.1:8000/