如何只得到正分?

How to get the positive score only?

我是情感新手 analysis.I 只想获得积极的分数,而不是像化合物,否定,积极,neutral.Can 谁能帮助我实现这个目标?

sid = SentimentIntensityAnalyzer()
ss = sid.polarity_scores(sentence) 

提前致谢。

基于source code,方法returns一个字典,形状为:

{"neg" : ..., "neu" : ..., "pos" : ..., "compound" : ...}

所以你可以简单地使用:

sid = SentimentIntensityAnalyzer()
ss = sid.polarity_scores(sentence)<b>['pos']</b> # the positive score

此处 ['pos'] 获取与 'pos' 键关联的值。