我知道您可以通过手动将它们添加到 vader_lexicon.txt 文件来添加自己的单词。我想知道是否有另一种方法可以在 python 代码中执行此操作,因为我不希望使用我的代码的人需要修改其他 .txt 文件。
from nltk.sentiment.vader import SentimentIntensityAnalyzer as SIA
sia = SIA()
sia.lexicon
这将得到字典。正在考虑类似的事情:
sia.lexicon.update{u'word': 3}