更新Vader词典分数如何工作?

我正在将NLTK用于python,并且正在尝试更新一组单词的分数。似乎分数正在更新,但似乎没有按照我指定的方式更新。我想知道是否有人知道这个过程如何运作?

我在下面附加了一个最小的工作示例,显示了更新前后的分数

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

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

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

之前和之后的分数可以在下面看到

{'neg': 0.0,'neu': 1.0,'pos': 0.0,'compound': 0.0}
{'neg': 0.0,'neu': 0.0,'pos': 1.0,'compound': 0.7906}
iCMS 回答:更新Vader词典分数如何工作?

尝试仅查询词典 moon,如下所示:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

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

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

输出为:

enter image description here

本文链接:https://www.f2er.com/2144781.html

大家都在问