Description Usage Arguments Details Value See Also Examples
Computes sentiment score by counting the number of positive and negative terms.
1 2 |
text |
Character vector with the text to be classified |
pos |
Positive words lexicon |
neg |
Negative words lexicon |
pos_s |
Numeric vector of scores for each word in the pos vec |
neg_s |
Numeric vector of scores for each word in the neg vec |
lan |
Languaje of the lexicon (can be either 'en' or 'es') |
normalize |
Whether or not to normalize the values of each words' score. |
By default uses an english lexicon downloaded from
http://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html. In particular
if no list of words is provided, the function loads the dataset
warriner_et_al_en()
or warriner_et_al_es()
, depending
on the lang
argument, both of which contains a vector of words with
their respective valence (pleasantness of the stimulus).
The arguments pos_s
and neg_s
allow to provide with scores
(valence) to each vector of words, so instead of adding 1 or -1 for every
positive or negative word the function can add some other value specified by
these arguments.
By default, when using the default lexicon, the function loads the english
lexicon (lan='en'
). Otherwise, if lan
is set to 'es', it
will load the spanish lexicon.
When normalize
is set to TRUE
(default), the function will normalize
the scores values for each word such as all values are within -1 and 1. Note that
this does not implies that the final sentiment score will be in that range as
well since it is a result of the addition of the scores.
Numeric Vector with scores
sentiment_lexicon_pos_en()
sentiment_lexicon_neg_en()
Other statistics: plot.tw_Class_table
,
plot.tw_Class_ts
1 2 3 4 5 6 7 8 9 10 11 12 | # Example data
text <- c(
"I'm feeling sad today",
"This is terrible, bad",
"I'm doing ok",
"I'm feeling great",
"I'm feeling nothing",
"This is sick, but good at the same time")
# Getting the scores
tw_sentiment(text)
tw_sentiment(text, normalize=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.