python-3.xnltksentiment-analysisvader

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.


Solution

  • 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.