Description Usage Arguments Value Author(s) Examples
Classifies the polarity (e.g. positive or negative) of a set of texts using a naive Bayes classifier trained on Janyce Wiebe's subjectivity
lexicon.
1 2 | classify_polarity(textColumns,algorithm="bayes",pstrong=0.5,pweak=1.0,
prior=1.0,verbose=FALSE,...)
|
textColumns |
A |
algorithm |
A |
pstrong |
A |
pweak |
A |
prior |
a |
verbose |
A |
... |
Additional parameters to be passed into the |
Returns an object of class data.frame
with four columns and one row for each document.
pos |
The absolute log likelihood of the document expressing a positive sentiment. |
neg |
The absolute log likelihood of the document expressing a negative sentiment. |
pos/neg |
The ratio of absolute log likelihoods between positive and negative sentiment scores. A score of 1 indicates a neutral sentiment, less than 1 indicates a negative sentiment, and greater than 1 indicates a positive sentiment. |
best_fit |
The most likely sentiment category (e.g. positive, negative, neutral) for the given text. |
Timothy P. Jurka <tpjurka@ucdavis.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 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.",
"With nightfall approaching, Los Angeles authorities are urging residents to keep their
outdoor lights on as police and fire officials try to catch the person or people responsible
for nearly 40 arson fires in the last three days.")
# CLASSIFY POLARITY
classify_polarity(documents,algorithm="bayes",verbose=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.