Is it possible to edit NLTK's vader sentiment lexicon?
For anyone interested, this can also be achieved without having to manually edit the vader lexicon .txt file. Once loaded the lexicon is a normal dictionary with words as keys and scores as values. As provided by repoleved in this post:
from nltk.sentiment.vader import SentimentIntensityAnalyzer
new_words = {
'foo': 2.0,
'bar': -3.4,
}
SIA = SentimentIntensityAnalyzer()
SIA.lexicon.update(new_words)
If you wish to remove words, use the '.pop' function:
SIA = SentimentIntensityAnalyzer()
SIA.lexicon.pop('no')
I found the fix. I zipped the folder vader_lexicon
that contains the txt file and the changes I applied is now the one being accessed.