Machine Learning

lightweightsentiment

Worked on a little sentiment analysis tool. The goal was to have a natural language processor that would report back a basic polarity score on text provided. So lightweightsentiment is a Lightweight Sentiment Analysis Tool built using the nltk (natural language toolkit) python framework.

Requirements

lightweightsentiment was written to conform to python 2 or 3 and requires the following modules installed (newer versions may work):

nltk==3.4.5

textblob==0.15.3

To install nltk run:

python -m textblob.download_corpora

Usage

Simply run the input.py script with a –text option and then some text to see sentiment. For example:

python input.py --text "Gosh, I hate this feature"

The output would then be a number between -1.0 and 1.0. For example:

-0.8

You can then train the data.json file using the –train option:

python input.py --train="This is an great python script!" --label="pos"

Get the Code

Most of the work is done by NaiveBayesClassifier. There’s plenty of places to go from here, but to download, check out https://github.com/krypted/lightweightsentiment.