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.
sentiment_attributes(
text.var,
polarity_dt = lexicon::hash_sentiment_jockers_rinker,
valence_shifters_dt = lexicon::hash_valence_shifters,
...
)
The text variable.
A data.table of positive/negative words and weights with x and y as column names.
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.
Returns a list of four items:
The number of words, sentences, and questions in the text
The rate of sentiment attributes relative to the number of words
The rate that valence shifters cooccur with a polarized word in the same sentence
A cooccurrence matrix of sentiment attributes; `polarized` is the sum of positive and negative
# NOT RUN {
sentiment_attributes(presidential_debates_2012$dialogue)
# }
Run the code above in your browser using DataLab