Description Usage Arguments Value Author(s) Examples
Classifies the emotion (e.g. anger, disgust, fear, joy, sadness, surprise) of a set of texts using a naive Bayes classifier trained on Carlo Strapparava and Alessandro Valitutti's emotions
lexicon.
1 | classify_emotion(textColumns,algorithm="bayes",prior=1.0,verbose=FALSE,...)
|
textColumns |
A |
algorithm |
A |
prior |
a |
verbose |
A |
... |
Additional parameters to be passed into the |
Returns an object of class data.frame
with seven columns and one row for each document.
anger |
The absolute log likelihood of the document expressing an angry sentiment. |
disgust |
The absolute log likelihood of the document expressing a disgusted sentiment. |
fear |
The absolute log likelihood of the document expressing a fearful sentiment. |
joy |
The absolute log likelihood of the document expressing a joyous sentiment. |
sadness |
The absolute log likelihood of the document expressing a sad sentiment. |
surprise |
The absolute log likelihood of the document expressing a surprised sentiment. |
best_fit |
The most likely sentiment category (e.g. anger, disgust, fear, joy, sadness, surprise) for the given text. |
Timothy P. Jurka <tpjurka@ucdavis.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 | # LOAD LIBRARY
library(sentiment)
# DEFINE DOCUMENTS
documents <- c("I am very happy, excited, and optimistic.",
"I am very scared, annoyed, and irritated.",
"Iraq's political crisis entered its second week one step closer to the potential
dissolution of the government, with a call for elections by a vital coalition partner
and a suicide attack that extended the spate of violence that has followed the withdrawal
of U.S. troops.")
# CLASSIFY EMOTIONS
classify_emotion(documents,algorithm="bayes",verbose=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.