An application which displays India's region wise twitter sentiment on the map.
git clone https://github.com/geekyJock8/hows_india_feeling.git
-
In the backend folder create a new file
config.py
-
In
config.py
paste the following code with your twitter api credentials:consumer_key = 'YOUR KEY' consumer_secret = 'YOUR SECRECT' access_token = 'YOUR TOKEN' access_token_secret = 'YOUR TOKEN SECRET'
- cd into backend
- Run
python3 tweet_handler.py
This will fetch the latest data from Twitter API. tweet_handler.py
contains the logic of fetching tweets.
- Inside backend run
python app.py
Note down the url of your local server
-
In root directory, in
index.js
:Set
api_url = 'YOUR LOCAL SERVER'
(It's most likely going to be at
http://127.0.0.1:5000/
)
- Open
index.html
in a browser
The idea was to show the sentiment of each particular area. So, far it only fetches tweets state wise.
Since Twitter doesn't allow a geometry parameter to filter tweets, we are using points and radius filter of twitter api. The mapping is stored in constants.py
Since there's a limit on the number of tweets we can fetch, only a few number of tweets are fetched per 15 minutes. The tweet_handler.py is required to added as cron job which is to be run every 15 minutes.
Also, the number of tweets fetched per state is not same, rather's proportional to the state's population density.
Next step would be to replace this logic with something which is more correct. One possible solution is to fill each area with smaller circles and use these circles. This is a good starting point.
- Improve UI
- Improve mapping logic
- Create Logic for smaller areas
- Make a better todo list
Contributions are welcome!