Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any other package other than "sentiment" to do Sentiment Analysis in R? [closed]

The "sentiment" package in R was removed from the Cran repository. What are the other packages which can do Sentiment Analysis?

For example, how I can rewrite this using other packages?

 library(sentiment)
# CLASSIFY EMOTIONS
classify_emotion(some_txt,algorithm="bayes",verbose=TRUE)
# classify polarity
class_pol = classify_polarity(some_txt, algorithm="bayes")

Where documents here is defined as:

# DEFINE text
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
                "I am very scared from OP question, annoyed, and irritated.")
like image 437
user1946217 Avatar asked Mar 04 '13 04:03

user1946217


1 Answers

I can't find sentiment package.This is based on the tm.plugin.sentiment package. You can find it here.

First, I create my Corpus:

some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
+              "I am very scared from OP question, annoyed, and irritated.")
 text.corpus <- Corpus(VectorSource(some_txt))

Then, I apply score on the corpus

> text.corpus <- score(text.corpus)

The result is stored in the meta :

> meta(text.corpus)
  MetaID polarity subjectivity pos_refs_per_ref neg_refs_per_ref senti_diffs_per_ref
1      0        0    0.2857143        0.1428571        0.1428571           0.0000000
2      0       -1    0.1428571        0.0000000        0.1428571          -0.1428571

behind the code The score function (the default behavior), will pre-procees the corpus using these tm functions:

  • tolower
  • removePunctuation
  • removeNumbers = TRUE,
  • removeWords = list(stopwords("english")),
  • stripWhitespace
  • stemDocument
  • minWordLength = 3,

Then, apply the score functions:

  • polarity
  • subjectivity
  • pos_refs_per_ref
  • neg_refs_per_ref
  • senti_diffs_per_ref
like image 89
agstudy Avatar answered Nov 15 '22 20:11

agstudy