Techgeeks1
Techgeeks1

Reputation: 596

How to get the positive score only?

I am new to sentiment analysis.I want to get the positive score only not all like compound,neg ,pos,neutral.Can anyone help me to achieve this?

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

thanks in advance.

Upvotes: 4

Views: 2532

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476557

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.

Upvotes: 2

Related Questions