我使用进行情感分析,并附带了stanza包(因为我主要是用CoreNLP工作)。我希望在CoreNLP系统中使用所有5个类(从非常消极到非常积极)获得情绪评分。我知道,使用内置在节中的情感分类器只使用3个类(正、中性、负;https://stanfordnlp.github.io/stanza/sentiment.html),但即使我直接访问CoreNLP服务器,我也只能得到正的负值。为什么?下面的代码不应该在5个类中返回情感分数,因为它使用的是CoreNLP本身?
import stanza
from stanza.server import CoreNLPClient
text=("This was the best movie ever made!")
with CoreNLPClient(
annotators=['tokenize', 'ssplit', 'sentiment']) as client:
ann=client.annotate(text)
#print(ann)
sentence=ann.sentence[0]
print(sentence.sentiment)发布于 2022-03-09 10:49:22
stanza本身就是一个用python构建的独立模块。
CoreNLPClient使用实际的CoreNLP。如果您仔细观察它的输出,您将看到它确实提供了5级输出,但它最终只会将其舍入到3级。
尝试打印sentence而不是sentence.sentiment,您将看到。
https://stackoverflow.com/questions/71023807
复制相似问题