3

I want to update the chart up and chart down emojis sentiment values in the vader lexicon. Seeing this post (VaderSentiment: unable to update emoji sentiment score) I have tried to replicate it but with no success:

new_words = {
    "chart decreasing" : -1,
    "" : -1
}
analyzer.lexicon.update(new_words)

analyzer.polarity_scores("")

Result: {'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}

It should show neg: 1.0, as I have just updated the lexicon.

Any ideas how to update the values?

pietrodito
  • 1,783
  • 15
  • 24
Laurence_jj
  • 646
  • 1
  • 10
  • 23

1 Answers1

1
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

new_words = {
    'decreasing': -4.0,
}

sia = SentimentIntensityAnalyzer()
sia.lexicon.update(new_words)
sia.polarity_scores('')
Vulwsztyn
  • 2,140
  • 1
  • 12
  • 20
  • 3
    could you please explain your answer? code only answers are not really preferred on SO. – JHBonarius Apr 13 '21 at 09:47
  • It's not like he is asking about an algorithm. Explanation: you should use 'decreasing' instead of "chart decreasing" – Vulwsztyn Apr 13 '21 at 09:49
  • how do you find the names of the emoji? For example this one was listed as `chart decreasing` in the vader emoji lexicon - https://github.com/cjhutto/vaderSentiment/blob/master/vaderSentiment/emoji_utf8_lexicon.txt – Laurence_jj Apr 13 '21 at 11:25
  • would your answer not also impact the word `decreasing` as apposed to just the emoji. – Laurence_jj Apr 13 '21 at 11:26
  • 1
    it would appear that most of the emojis seem to take the first word used in the name, e.g. `sleeping face` would respond to `sleeping` – Laurence_jj Apr 16 '21 at 15:55