trinker / sentimentr

Dictionary based sentiment analysis that considers valence shifters
Other
426 stars 84 forks source link

valence_shifters not found #107

Closed MsPhotonUIUC closed 2 years ago

MsPhotonUIUC commented 5 years ago

I am getting this issue when I run my code:

simple code: emotion(text, emotion_dt = lexicon::hash_nrc_emotions, valence_shifters_dt = lexicon::hash_valence_shifters, drop.unused.emotions = FALSE, un.as.negation = TRUE, un.as.negation.warn = isTRUE(all.equal(valence_shifters_dt, lexicon::hash_nrc_emotions)), n.before = 5, n.after = 2)

Error: Error in all.equal(valence_shifters_dt, lexicon::hash_nrc_emotions) : object 'valence_shifters_dt' not found

How do I import/access the valence shifters lexicon?

trinker commented 2 years ago

Because you copied arguments from the function which allows other arguments to be self referenced (e.g., valence_shifters_dt) but not when you add them as an argument after the = sign.

If you swap the valence_shifters_dt for lexicon::hash_valence_shifters inside the all.equal then this works:

text <- "i hate grilled cheese!"

emotion(text, emotion_dt = lexicon::hash_nrc_emotions,
valence_shifters_dt = lexicon::hash_valence_shifters,
drop.unused.emotions = FALSE, un.as.negation = TRUE,
un.as.negation.warn = isTRUE(all.equal(lexicon::hash_valence_shifters,
lexicon::hash_nrc_emotions)), n.before = 5, n.after = 2)