Quick Social Media Sentiment Analysis with VADER

I recently came across a very useful open source python library that performs sentiment analysis out of the box. The library is called VADER (Valence Aware Dictionary and sEntiment Reasoner) and the source code is available on Github. With VADER you can be up and running performing sentiment classification very quickly even if you don’t have positive and negative text examples to train a classifier or want to write custom code to search for words in a sentiment lexicon. VADER is also computationally efficient when compared to other Machine Learning and Deep Learning approaches.

VADER is a lexicon and rule-based sentiment analysis library that I have found to work well, even on short textual statements. VADER performs well on text originating in social media and is described fully in a paper entitled “VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text.” published at ICWSM-14. VADER is able to include sentiment from emoticons (e.g, :-)), sentiment-related acronyms (e.g, LOL) and slang (e.g, meh).

VADER is a python library and can be installed using pip:

pip install vaderSentiment

Once VADER is imported, the sentiment for a list of sentences can be found using the vaderSentiment() method:

from vaderSentiment import sentiment as vaderSentiment 

sentences = [
"The plot was good, but the characters are uncompelling and the dialog is not great.",
"A really bad, horrible book.",
"At least it isn't a horrible book."
for sentence in sentences:
print sentence,
sentiment = vaderSentiment(sentence)
print "\n\t" + str(sentiment)

The vaderSentiment() method returns the values to represent the amount of negative, positive, and neutral sentiment and also works out the compound sentiment value as a signed value to indicate overall sentiment polarity. The output for the code snippet above:

The plot was good, but the characters are uncompelling and the dialog is not great.
{'neg': 0.327, 'neu': 0.579, 'pos': 0.094, 'compound': -0.7042}
A really bad, horrible book.
{'neg': 0.791, 'neu': 0.209, 'pos': 0.0, 'compound': -0.8211}
At least it isn't a horrible book.
{'neg': 0.0, 'neu': 0.637, 'pos': 0.363, 'compound': 0.431}