9

R 中的“情感”包已从 Cran 存储库中删除。还有哪些可以进行情绪分析的软件包?

例如,我如何使用其他包重写它?

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

这里的文档定义为:

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

4 回答 4

12

我找不到sentiment包。这是基于tm.plugin.sentiment包的。你可以在这里找到它。

首先,我创建我的语料库:

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

然后,我在语料库上应用分数

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

结果存储在 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

代码后面的score函数(默认行为),将使用这些 tm 函数对语料库进行预处理:

  • 降低
  • 删除标点符号
  • removeNumbers = TRUE,
  • removeWords = list(stopwords("english")),
  • 条空白
  • 干文件
  • minWordLength = 3,

然后,应用评分函数:

  • 极性
  • 主观性
  • pos_refs_per_ref
  • neg_refs_per_ref
  • senti_diffs_per_ref
于 2013-03-04T07:45:06.437 回答
3

有一个新的 R 包,称为Sentiment140,不需要额外的组件安装或语言模型训练。

  • 便于使用
  • 使用 Twitter 文本

很酷的东西 !

http://github.com/okugami79/sentiment140

于 2013-10-08T23:25:22.003 回答
2

这就是我在 R 版本 3.0.2 中安装 'sentiment' 0.2 所做的

我从存储库http://cran.r-project.org/src/contrib/Archive/sentiment/下载了“sentiment_0.2.tar.gz”

然后我把'sentiment_0.2.tar.gz'放在主目录--> C:

然后我使用命令从本地 zip 安装包:

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

这就是我所拥有的:

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
于 2015-04-29T20:01:57.437 回答
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

于 2013-10-03T13:29:01.663 回答