A Flask web app with twitter OAuth for analysing user's tweet topics and its sentiments.
The user has to login using his/her twitter account details.
The application will retrieve user's tweets and apply an unsupervised clustering technique in NLP known as topic modeling to classify tweets into topics.The model used here is the Biterm topic modleing model know as BTM.BTM is most suitable model for small texts like tweets.
Read more about BTM here.
The application will also perform sentiment analysis using the vader sentiment analysis module.
-
If you face any issue regarding the biterm model, delete the existing folder name 'biterm' and clone the BTM repo and use the biterm folder from there.
-
Create a twitter developer's account.
-
Create an app from the developer's home page
-
Mention the details for the app as shown, you can rename other fields but keep the callback url same.
Callback url : http://127.0.0.1:5000/login/twitter/authorized
- From this page go to "Keys and tokens" and copy your tokens and paste in the app.py file.
twitter_blueprint = make_twitter_blueprint(
api_key= "<your_api_key>", api_secret= ""<your_api_secret>")
Website URL can be any random url.
- Install dependencies
pip install -r requirements.txt
- In the main directory run the following command
python app.py
- You will get a url, go to that url. In most cases it is this-
http://127.0.0.1:5000/
-
The app is hosted!!
-
Login using your twitter credentials
- Enter your profile display name/ID.
- Final user dashboard
-
Your username/display name
-
Topics clustered by BTM
-
Each tweet classified into one of the 3 topics.
-
Vader Sentiment analysis for each tweet.
You can take the demo of the application at the heroku deployed version of the app .
Please note that the app will work if you have significant amount of tweets (at least 10-15).
If you do not have these many tweets please add a few more test tweets to see the results.
Priya Mane