I'm trying to do a sentiment analysis using hash_sentiment_socal_google in Sentimentr. Looking through the responses, I've noticed that one word responses of "unsure", or "unknown", get an average sentiment score of -.5. And "yes", gets .8. I would like all of them to show up as 0, or neutral.
I don't actually see any of these words in hash_sentiment_socal_google, so I'm not sure why these responses are being assigned sentiment scores. But I just figured I could add to the key with the following code to set to 0:
updated_socal_google <-
sentimentr:::update_polarity_table(lexicon::hash_sentiment_socal_google,
x = data.frame(words = c('yes', 'unsure', 'unknown'),
polarity = c(0, 0, 0), stringsAsFactors = FALSE))
But after running the code below:
sentiments_new <- sentiment_by(text_sentences, by = NULL,
averaging.function = average_mean,
updated_socal_google, amplifier.weight = .5,
n.before = 10, n.after = 4)
These one word responses are still getting assigned the same average sentiment scores as before, not 0. Can someone explain what I'm doing wrong?
Thank you!
Found out the answer, so wanted to update in case anyone else runs into this issue. I needed to specify that polarity_dt = updated_socal_google.
So instead of what I had above:
sentiments_new <- sentiment_by(text_sentences, by = NULL,
averaging.function = average_mean,
polarity_dt = updated_socal_google, amplifier.weight = .5,
n.before = 10, n.after = 4)