gpt4 book ai didi

python - 如何更新 vader 词典中的表情符号?

转载 作者:行者123 更新时间:2023-12-04 03:35:33 25 4
gpt4 key购买 nike

我想在 vader 词典中更新图表向上和向下图表表情符号的情绪值。看到这篇文章(VaderSentiment: unable to update emoji sentiment score)我试图复制它但没有成功:

new_words = {
"chart decreasing" : -1,
"📉" : -1
}
analyzer.lexicon.update(new_words)

analyzer.polarity_scores("📉")

结果:{'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}

它应该显示 neg: 1.0,因为我刚刚更新了词典。

关于如何更新值有什么想法吗?

最佳答案

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

new_words = {
'decreasing': -4.0,
}

sia = SentimentIntensityAnalyzer()
sia.lexicon.update(new_words)
sia.polarity_scores('📉')

关于python - 如何更新 vader 词典中的表情符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67006322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com