python - NLTK 的 Vader 评分文本示例

标签 python nlp nltk lexicon vader

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

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

VADER 选择的词是“喜欢”(+1.5 分)和“有趣”(+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

关于python - NLTK 的 Vader 评分文本示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51707282/

相关文章:

python - 我们如何使用 python 在给定文本中实现共指解析?

python - 根据位置将字符串过滤到列表中 - Python

python - 如何在 qiskit 中从 np.array 创建单一门?

python - 在列表理解期间无法解包返回的元组

nlp - 导入 Pytorch_Transformers 时找不到模块错误

java - 自动分析数据(自然语言处理)

nlp - 人与城市/州的关系抽取

python - 默认的 nltk 词性标记集是什么?

Python NLTK 莎士比亚语料库

python - 在 Pandas DataFrame 上的日期列上使用 numpy is_busday 函数