sentiment_attributes: Extract Sentiment Attributes from Text

Description Usage Arguments Value Note Examples

View source: R/sentiment_attributes.R

Description

This function utilizes gofastr and termco to extract sentiment based attributes (attributes concerning polarized words and valence shifters) from a text. Attributes include the rate of polarized terms and valence shifters relative to number of words. Additionally, coocurrence rates for valence shifters are computed.

Usage

1
2
3
4
5
6
sentiment_attributes(
  text.var,
  polarity_dt = lexicon::hash_sentiment_jockers_rinker,
  valence_shifters_dt = lexicon::hash_valence_shifters,
  ...
)

Arguments

text.var

The text variable.

polarity_dt

A data.table of positive/negative words and weights with x and y as column names.

valence_shifters_dt

A data.table of valence shifters that can alter a polarized word's meaning and an integer key for negators (1), amplifiers(2), de-amplifiers (3) and adversative conjunctions (4) with x and y as column names.

...

ignored.

Value

Returns a list of four items:

Meta

The number of words, sentences, and questions in the text

Attributes

The rate of sentiment attributes relative to the number of words

Polarized_Cooccurrences

The rate that valence shifters cooccur with a polarized word in the same sentence

Cooccurrences

A cooccurrence matrix of sentiment attributes; 'polarized' is the sum of positive and negative

Note

gofastr and termco must be installed. If they are not (which they are not part of sentimentr install) then the function will prompt you to attempt to install them using install.packages and ghit::install_github.

Examples

1
2
3
4
## Not run: 
sentiment_attributes(presidential_debates_2012$dialogue)

## End(Not run)

sentimentr documentation built on Oct. 12, 2021, 9:06 a.m.