4

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.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
Techgeeks1
  • 556
  • 1
  • 4
  • 18

1 Answers1

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.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555