We have explained how to get a sentiment score for words in Python. Instead of building our own lexicon, we can use a pre-trained one like the VADER which stands from _Valence Aware Dictionary and sEntiment Reasoner _and is specifically attuned to sentiments expressed in social media.
You can install the VADER library using pip like pip install vaderSentiment
or you can get it directly from NTLK. You can have a look at VADER documentation.
The VADER library returns 4 values such as:
Notice that the pos
, neu
and neg
probabilities add up to 1. Also, the compound
score is a very useful metric in case we want a single measure of sentiment. Typical threshold values are the following:
Let’s see these features in practice. We will work with a sample fo twitters obtained from NTLK.
#python #nltk #sentiment-analysis #sentiment #vader