pythonsentiment-analysisvader

VaderSentiment: unable to update emoji sentiment score


As title states, code is as follows:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

new_words = {
    '🔥': 4.0,
}

sia = SentimentIntensityAnalyzer()
sia.lexicon.update(new_words)
sia.polarity_scores('🔥')

The given emoji is considered to be negative by the original lexicon, but I want it to be positive instead. However, updating according to the above code does not seem to work at all:

{'neg': 1.0, 'neu': 0.0, 'pos': 0.0, 'compound': -0.34}


Solution

  • So apparently Vader transforms emojis to their word representation prior to extracting sentiment. You can find this mapping in "site-packages/vaderSentiment/emoji_utf8_lexicon.txt".

    Updating the code to:

    new_words = {
        'fire': 4.0,
    }
    

    works.