gpt4 book ai didi

python - Spacy 极性/情感方法不起作用

转载 作者:行者123 更新时间:2023-12-02 19:46:34 28 4
gpt4 key购买 nike

我想使用 spacy 来获取某些句子的极性,我有以下代码:

import spacy


if __name__ == "__main__":

nlp = spacy.load("en_core_web_lg")
test_text = ['that is a great news','the book is very bad']

sentiment = {'polarity':[]}
for text in test_text:
doc = nlp(unicode(text))
print (doc.sentiment)

但我在所有情况下都得到 0.0。

为什么会这样呢?显然两个句子的极性不一样

最佳答案

尽管文档将 sentement 列为文档属性,但 spaCy 模型并未附带情感分类器。要做情感分类,首先要训练自己的模型following this example .

关于python - Spacy 极性/情感方法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59131400/

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