我正在使用用于python的NLTK,并尝试更新一组单词的分数。虽然分数似乎正在更新,但它们似乎没有按照我指定的方式更新。我想知道是否有人知道这个过程是如何运作的
我在下面附上了一个最低限度的工作示例,显示了更新前后的分数
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}
尝试仅查询词典
moon
,如下所示:输出为:
相关问题 更多 >
编程相关推荐