Search code examples
pythonvader

How to get nicer data from vaderSentiment?


I know I can get this from vader: {'neg': 0.071, 'neu': 0.895, 'pos': 0.034, 'compound': -0.296}

but is their a way to get just the overall result? Say for instance {'Positive'} or {'Negative'}

also... what do I look up to see everything I can do with vader? Like a list of functions or something.


Solution

  • The compound score is computed by summing the valence scores of each word in the lexicon, adjusted according to the rules, and then normalized to be between -1 (most extreme negative) and +1 (most extreme positive). This is the most useful metric if you want a single unidimensional measure of sentiment for a given sentence.

    You can then set thresholds for negative[-1, 0), neutral[0, 0.5) and positive[0.5, 1] to classify them into categories. For example:

    def get_category(compounded):
    if compounded < 0:
        return 'negative'
    elif compounded < 0.5:
        return 'neutral'
    else:
        return 'positive'
    

    Choose thresholds that would work best for your data and use case.