Sentiment analysis attempts to extract the sentiment/mood from a section of text. In this case, it attempts to label the text as negative or positive. This project is a simple REST API utilizing a FastText model to do sentiment analysis.
FastText is unsupervised and only understands words and phrases in the context of it's training data. For example, when finding a word's nearest neighbors, the model will be useless for words that don't correlate with mood. Also, as with most ML, it will preform poorly when it encounters text dissimilar from what it was trained on.
The live demo explains how to use the API including example curls and responses.
An example curl for both of the endpoints exposed by the REST API:
curl -X POST -H "Content-Type: application/json" -d '{"text":"broke after 2 days"}' 'https://sentiment-analysis.mod64.net/api/sentiment'
curl -X POST -H "Content-Type: application/json" -d '{"text":"bad"}' 'https://sentiment-analysis.mod64.net/api/nearestneighbors'
- Running the ML model is CPU intensive and the node.js FastText library is not great. I would definitely improve the devops, run more node processes, and audit the library.
- Redo the frontend demo page. It is rubbish. It is a modified bootstrap example and some jQuery.
- Add Yelp reviews to the model. I scraped all Yelp locations in the US and have a couple hundred thousand reviews to make model better (was out of scope for this demo).
- I started with a TS/Node.js starter project I maintain for one off project exactly like this.
- I am using an ML model I trained a while back. You can read more about it.
- Clone this repository
- Run
npm install - Run
npm run build - Run
./scripts/install_model.shNOTE: This file is about 2GB - Run
npm run start
Run npm run build_and_test
Run npm run build; npm run startdev;