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

孤街醉人 提交于 2019-11-27 11:23:39

问题


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.")

回答1:


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



回答2:


There is new R package called sentiment140, required no additional component installation nor language model training.

  • Easy to use
  • work with Twitter Text

Cool stuff !

http://github.com/okugami79/sentiment140




回答3:


This is what I did to install 'sentiment' 0.2 in R version 3.0.2

I downloaded the 'sentiment_0.2.tar.gz' from the repository http://cran.r-project.org/src/contrib/Archive/sentiment/

Then I've put the 'sentiment_0.2.tar.gz' in the main directory --> C:

Then I used the command to install packages from local zip:

install.packages("C:/sentiment_0.2.tar.gz", repos = NULL, type="source")

This is what I've got:

Warning in install.packages : package ‘C:/sentiment_0.2.tar.gz’ is not available (for R version 3.0.2)

Installing package into ‘C:/Users/y65liu/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified)

** installing source package 'sentiment' ...

** package 'sentiment' successfully unpacked and MD5 sums checked

** R

** data

** preparing package for lazy loading

** help

** installing help indices

** building package indices

** testing if installed package can be loaded

** DONE (sentiment) ?

When I call the library, the library is regularly loaded with its related packages ('tm', 'Rstem')

You may found documentation on using the sentiment package here:

https://sites.google.com/site/miningtwitter/questions/sentiment/sentiment

Hope this help!




回答4:


To install sentiment analysis package use this http://cran.r-project.org/web/packages/sentiment/index.html since the packages are quite old already and R cran removed them from their site.

the packages that are required before installing are tm , Rstem , twitteR,ggplot2,plyr,RColorBrewer and wordcloud it may provide some errors but I worked for me so far :P



来源:https://stackoverflow.com/questions/15194436/is-there-any-other-package-other-than-sentiment-to-do-sentiment-analysis-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!