4

我是情绪分析的新手。我只想得到积极的分数,而不是像复合,否定,pos,中性。谁能帮我实现这个目标?

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

提前致谢。

4

1 回答 1

2

Based on the source code, the method returns a dictionary with shape:

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

So you can simply use:

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

Here ['pos'] fetches the value that is associated with the 'pos' key.

于 2017-03-07T14:33:12.440 回答