clairekelley
clairekelley

Reputation: 447

Sentiment analysis in R not recognizing modifying words

I am having a problem with SentimentAnalysis in R. I would like to find a way to do sentiment analysis in r that is not just based on the positivity or negativity of a single word. For example

library(SentimentAnalysis) 
sentiment_pos <- analyzeSentiment("This presentation is excellent and Informative ")
convertToDirection(sentiment_pos$SentimentQDAP)
sentiment_neg <- analyzeSentiment("This presentation is not excellent")
convertToDirection(sentiment_neg$SentimentQDAP)

this package scores both sentences as positive (i think because it is dictionary based and does not take into account that "not" is a negating modifier). I am trying to imitate the functionality of the python package textblob but using R. Does anyone have any idea for packages that have this functionality?

Upvotes: 0

Views: 67

Answers (1)

phiver
phiver

Reputation: 23598

You could use sentimentr. Scoring your 2 sentences gives different sentiments, because sentimentr uses valence shifters that can alter the polarity of a word.

library(sentimentr)

sentiment("This presentation is excellent and Informative")
   element_id sentence_id word_count sentiment
1:          1           1          6 0.4082483

sentiment("This presentation is not excellent")
   element_id sentence_id word_count  sentiment
1:          1           1          5 -0.4472136

Upvotes: 3

Related Questions