Description Usage Arguments Value Note Examples
View source: R/sentiment_attributes.R
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.
1 2 3 4 5 6 | sentiment_attributes(
text.var,
polarity_dt = lexicon::hash_sentiment_jockers_rinker,
valence_shifters_dt = lexicon::hash_valence_shifters,
...
)
|
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. |
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 |
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
.
1 2 3 4 | ## Not run:
sentiment_attributes(presidential_debates_2012$dialogue)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.