ToneSense is a React web app that allows a user to enter in a sentence and receive a sentiment analysis result from a Machine Learning Model. This repository contains the source code for the RESTful API built in Flask.
This project was built in two separate parts: Version 1 relies on a external API with a pre-trained model and Version 2 uses a self fine tuned model. Explained in more detail below.
Deployed with Google App Engine.
This version utilizes the Google Cloud NLP API to analyze the user's sentence and return a sentiment analysis result.
The API will return a numbered score and magnitude which represents the sentence's sentiment on a scale of -1.0 to 1.0. The scoring range is as follows: 0.25 to 1.0 corresponds to a result of "likely positive", -0.25 to 0.25 corresponds to a result of "likely neutral", and -1.0 to -0.25 returns corresponds to a result of "likely negative".
This version was built using a Naive Bayes Classifier model and fine tuned with the Natural Language Toolkit (NLTK). The model was fine tuned in Google Colab.
The ML model implements binary classification, therefore the results returned are either "positive" or "negative", with the score 1.0 or -1.0, respectively.
- Make a clone of this repository.
- Checkout the master branch.
- Install Anaconda.
- Activate a new Conda environment.
- Install Python 3.7.4.
- Install dependencies using pip
pip install -r requirements.txtor using Condaconda install --file requirements.txt - Create a Google Cloud Platform account.
- Follow installation instructions to get started with Cloud Natural Language API.
- Install and initialize Cloud SDK.
- Run server locally
python application.py - To interact with model and see its results in the Web App, follow the installation instructions in the corresponding repository.
- Google NLP Route: '/api/v1/results/{string:text}'
- Parameter: String, spaces allowed
- Naive Bayes Classifier Route: '/api/v2/results/{string:text}'
- Parameter: String, spaces allowed
ToneSense is developed by Kristina Moskalets as a capstone project for Ada Developers Academy.
