sentimentr (version 2.6.1)

extract_sentiment_terms: Extract Sentiment Words

Description

Extract the sentiment words from a text.

Usage

extract_sentiment_terms(text.var,
  polarity_dt = lexicon::hash_sentiment_jockers_rinker, hyphen = "",
  ...)

Arguments

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 hyphen = " " would result in a space between words (e.g., 'sugar free').

Ignored.

Value

Returns a data.table with columns of positive and negative terms.

Examples

Run this code
# NOT RUN {
library(data.table)
set.seed(10)
x <- get_sentences(sample(hu_liu_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
# }

Run the code above in your browser using DataCamp Workspace