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

4

9

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.")
Reading answered 4/3, 2013 at 4:11 Comment(8)
qdap does a polarity thing but it's low level at this point. Essentially it's a dictionary lookup system and may not scale well to large projects. It's intended more for discourse studies.Impugn
Have you looked at the workflows and functions linked to here? https://mcmap.net/q/490493/-sentiment-analysis-using-r-closed/1036500 Here's a summary of two other methods: sites.google.com/site/miningtwitter/questions/sentimentPurvis
you can do this , library(sos) ;findFn('sentiment analysis'), you have essentially, qdap and textir but there is also tm.plugin.sentiment for time series .. The sentiment package is still exist in R-Forge also.Meta
The qdap::polarity function is an implementation based on the first link Ben provides but with a custom algorithm. I'm not happy with it but haven't had time to develop it further yet.Impugn
@Reading I add some concrete example to your question..( I am joking for the text example, feel free to edit it)Meta
@Meta I do not find the "sentiment" package in R-Forge either. I got the archived version on CRAN. But It isn't loading properly. > install.packages("C:/Users/Documents/R/win-library/2.15/sentiment.zip", repos=NULL) Installing package(s) into ‘C:/Users/Documents/R/win-library/2.15’ (as ‘lib’ is unspecified) package ‘sentiment’ successfully unpacked and MD5 sums checked > library(sentiment) Error in library(sentiment) : ‘sentiment’ is not a valid installed package Am I missing somethingReading
@TylerRinker Has qdap's polarity abilities improved in the past two years?Hoffarth
@Hoffarth yes I rewrote the algorithm to be more accurate and faster. It also takes into account negators (e.g., "It's not good" is ranked as a negative polarity rather than positive as "not" is accounted for). Other algorithms do not.Impugn
M
12

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
Meta answered 4/3, 2013 at 7:45 Comment(1)
Each time the score() code throws an error: scored <- score(corpus.txt) Error in polarity.TermDocumentMatrix(list(i = c(2L, 6L, 8L, 11L, 12L, : could not find function "tm_tag_score". Others have encountered different errors: #24612580. Can you advise or should I post a new question? Thank you.Ovovitellin
C
3

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

Crossruff answered 8/10, 2013 at 23:25 Comment(0)
I
2

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
Interne answered 29/4, 2015 at 20:1 Comment(0)
T
0

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

Tram answered 3/10, 2013 at 13:29 Comment(2)
That links to the package which the OP already told us is no longer in CRAN.Brevet
Yes but you can find it at the archives and then install the package manually in RTram

© 2022 - 2024 — McMap. All rights reserved.