我试图使用NLTK中的Vader情绪分析中的polarity_scores()
,但它给了我错误:
polarity_scores() missing 1 required positional argument: 'text'
我完全是个Python初学者。谢谢你的帮助!
from nltk.sentiment.vader import SentimentIntensityAnalyzer as sid
sentences=["hello","why is it not working?!"]
for sentence in sentences:
ss = sid.polarity_scores(sentence)
你需要首先初始化一个感伤强度分析器的对象,然后调用该对象上的方法polarity_scores。
请尝试以下代码:
SentimentIntensityAnalyzer
是一个类。您需要初始化SentimentIntensityAnalyzer
的对象,并在该对象上调用polarity_scores()
方法。如果你还没有下载词典文件
相关问题 更多 >
编程相关推荐