extract_sentiment_terms: Extract Sentiment Words

Description Usage Arguments Value Examples

View source: R/extract_sentiment_terms.R

Description

Extract the sentiment words from a text.

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

sentimentr documentation built on April 24, 2018, 5:03 p.m.