1

I am using NLTK for python and I am trying to update the scores for a set of words. Whilst it appears that the scores are updating, they don't appear to update in the way that I am specifying. I'm wondering if anyone knows how this process works?

I have attached a minimum working example below, showing the scores before and after the update

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

SIA = SentimentIntensityAnalyzer()
print(SIA.polarity_scores('moon'))

SIA.lexicon.update({'moon': 5})
print(SIA.polarity_scores('moon'))

The scores from the before and after can be seen below

{'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
{'neg': 0.0, 'neu': 0.0, 'pos': 1.0, 'compound': 0.7906}
Steffi Keran Rani J
  • 3,667
  • 4
  • 34
  • 56
Johnny
  • 320
  • 3
  • 12

1 Answers1

0

Try querying only for the lexicon moon like this:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

SIA = SentimentIntensityAnalyzer()
print(SIA.polarity_scores('moon'))

SIA.lexicon.update({'moon': 5})
print(SIA.lexicon['moon'])

The output is:

enter image description here

Steffi Keran Rani J
  • 3,667
  • 4
  • 34
  • 56