It's a twitter sentiment thing.
- Scrapes tweets using twint.
- Passes the scraped tweets through roBERTa , (Hugging Face 🤗), this gives sentiment probabilities.
- All of the above is served using FastAPI.
- Front end is built using React, a bit of Material-UI.
- Data served by the API is plotted using Chart.js.
Steps for getting the code to do what's in the gif.
- Install the dependencies in
api/requirements.txt
- For
torch
I suggest following the steps here. - Also if
twint
doesn't install properly usingpip
, usepip3 install --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint
, this worked for me.
uvicorn api.main:app --reload
from the root of this repo.
If Hugging Face throws an error then rename files in api/core/model
to:
model
└── cardiffnlp
└── twitter-roberta-base-sentiment
├── config.json
└── pytorch_model.bin
and files in api/core/tokenizer
to:
tokenizer
└── cardiffnlp
└── twitter-roberta-base-sentiment
├── config.json
├── merges.txt
├── special_tokens_map.json
└── vocab.json
Note: these files are downloaded when the server runs.
npm install
to install the dependencies.npm start
to serve the frontend.
- API server should be served from port
http://localhost:5000
and frontend server fromhttp://localhost:3000
. - Impact is calculated using likes, retweets, and replies.
- This was done without much thought, more of an exercise than a project, not meant to be serious so a more than a few things may be broken.
- Tweet scores aren't aggregated, it would be more meaningful if it was.