View source: R/classify_emotion.R
classify_emotion | R Documentation |
classify_emotion
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.
classify_emotion( textColumns, algorithm = "bayes", prior = 1, verbose = FALSE, lang = "en", ... )
textColumns |
A |
algorithm |
A |
prior |
A |
verbose |
A |
lang |
Language, "en" for English and "pt" for Brazilian Portuguese. |
... |
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. |
trust |
The absolute log likelihood of the document expressing a trust sentiment. |
negative |
The absolute log likelihood of the document expressing a negative sentiment. |
positive |
The absolute log likelihood of the document expressing a positive sentiment. |
anticipation |
The absolute log likelihood of the document expressing a anticipation 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> and Jodavid Ferreira <jdaf1@de.ufpe.br>
# DEFINE DOCUMENTS documents <- c("I am very happy, excited, and optimistic.", "I am very scared, annoyed, and irritated.") # CLASSIFY EMOTIONS classify_emotion(documents,algorithm="bayes",verbose=TRUE, lang = "en") # pt-BR documentos <- c("Estou muito feliz, animado e otimista.", "Estou muito assustado e irritado.") # CLASSIFY EMOTIONS classify_emotion(documentos,algorithm="bayes",verbose=TRUE, lang = "pt")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.