NLTK 的 Vader 评分文本示例

Example of NLTK's Vader Scoring Text

我希望有人纠正我对 VADER 如何为文本评分的理解。我已经阅读了这个过程的解释 here,但是在重新创建它描述的过程时,我无法将测试句子的复合分数与 Vader 的输出相匹配。假设我们有句子:

"I like using VADER, its a fun tool to use"

VADER 选择的单词是 'like'(+1.5 分)和 'fun'(+2.3)。根据文档,这些值被求和(所以 +3.8),然后使用以下函数归一化到 0 到 1 之间的范围:

(alpha = 15)
x / x2 + alpha 

根据我们的数字,这应该变成:

3.8 / 14.44 + 15 = 0.1290

然而,VADER 输出返回的复合分数如下:

Scores: {'neg': 0.0, 'neu': 0.508, 'pos': 0.492, 'compound': 0.7003}

我的推理哪里出错了? Similar 问题已被问过多次,但尚未提供 VADER 分类的实际示例。任何帮助将不胜感激。

只是你的规范化有误。从 code 函数定义:

def normalize(score, alpha=15):
"""
Normalize the score to be between -1 and 1 using an alpha that
approximates the max expected value
"""
norm_score = score/math.sqrt((score*score) + alpha)
return norm_score

所以你有 3.8/sqrt(3.8*3.8 + 15) = 0.7003