| extract_sentiment_terms {sentimentr} | R Documentation |
Extract the sentiment words from a text.
extract_sentiment_terms(text.var, polarity_dt = lexicon::hash_sentiment_jockers_rinker, hyphen = "", ...)
text.var |
The text variable. |
polarity_dt |
A data.table of positive/negative words and weights with x and y as column names. |
hyphen |
The character string to replace hyphens with. Default replaces
with nothing so 'sugar-free' becomes 'sugarfree'. Setting |
... |
Ignored. |
Returns a data.table with columns of positive and negative terms.
library(data.table) set.seed(10) x <- get_sentences(sample(cannon_reviews[[2]], 1000, TRUE)) sentiment(x) pol_words <- extract_sentiment_terms(x) pol_words pol_words$sentence pol_words$neutral data.table::as.data.table(pol_words) attributes(extract_sentiment_terms(x))$counts attributes(extract_sentiment_terms(x))$elements