I have created polarity and shifters dictionaries (a few words just to test) with columns x and y as requested.
I get the following error:
Error in [.data.frame`(polarity_dt, word_dat[["words"]]) : undefined columns selected
Please could you help me? Thank you in advance.
Best regards
FEEL_polarity <- read.csv2('./FEEL_polarity.csv')
SHIFTERS <- read.csv2('./Shifters.csv')
library("sentimentr")
text_to_analyse <- c("Je ne suis pas heureux. Je suis heureux.")
sentiment(get_sentences(text_to_analyse), polarity_dt = FEEL_polarity,valence_shifters_dt = SHIFTERS)
As you already mentioned in the comments it is best to use
data.table
for the polarity and shifters tables and set the key.If I run this with your text, I get the result below. -1.3 for sentence 1 and 1.7 for sentence 2. Be aware that negators should be coded as 1L not -1L.
Do realize that
sentimentr
is developed for the English language. For French dictionaries you can look at the following websites:FEEL: a French Expanded Emotion Lexicon. http://advanse.lirmm.fr/feel.php A French lexicon containing more than 14 000 distinct words expressing emotions and sentiments. It follows the Ekman basic two polarities and six emotions (Ekman, 1992). It has been created by automatically translating and expanding the English Emotional Lexicon NRC-Canada (Mohammad & Turney, 2013). The process has been supervised and validated manually by a human professional translator.
This file can be adjusted to get it to work with
sentimentr
or maybe withtidytext
. I still have to look into this. And maybeudpipe
might be better for French.POLTEXT: https://www.poltext.org/en/donnees-et-analyses/lexicoder with a lexicon you can use with
quanteda