【问题标题】:Is there any other package other than "sentiment" to do Sentiment Analysis in R? [closed]除了“情绪”之外,还有其他软件包可以在 R 中进行情绪分析吗? [关闭]
【发布时间】:2013-03-04 04:11:30
【问题描述】:

R 中的“sentiment”包已从 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.")

【问题讨论】:

  • qdap 做了极性的事情,但此时它的水平很低。本质上,它是一个字典查找系统,可能无法很好地扩展到大型项目。它更多地用于话语研究。
  • 你可以做到这一点,library(sos) ;findFn('sentiment analysis'),你基本上有,qdaptextir 但也有时间序列的tm.plugin.sentiment .. sentiment 包仍然存在于 R - 也锻造。
  • qdap::polarity 函数是基于 Ben 提供的第一个链接但使用自定义算法的实现。我对它不满意,但还没有时间进一步开发它。
  • @user1946217 我在您的问题中添加了一些具体示例..(我是在为文本示例开玩笑,请随意编辑)
  • @Dason 是的,我重写了算法,使其更准确、更快。它还考虑了否定词(例如,“不好”被列为负极性,而不是“不好”被认为是积极的)。其他算法没有。

标签: r sentiment-analysis


【解决方案1】:

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

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

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(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")),
  • stripWhitespace
  • stemDocument
  • minWordLength = 3,

然后,应用评分函数:

  • 极性
  • 主观性
  • pos_refs_per_ref
  • neg_refs_per_ref
  • senti_diffs_per_ref

【讨论】:

  • 每次 score() 代码抛出错误: 得分 stackoverflow.com/questions/24612080/…。你能建议还是我应该发布一个新问题?谢谢。
【解决方案2】:

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

  • 易于使用
  • 使用 Twitter 文本

很酷的东西!

http://github.com/okugami79/sentiment140

【讨论】:

    【解决方案3】:

    这就是我在 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
    

    【讨论】:

      【解决方案4】:

      要安装情绪分析包,请使用这个 http://cran.r-project.org/web/packages/sentiment/index.html 因为这些包已经很旧了,R cran 从他们的网站上删除了它们。

      安装前需要的包是 tm , Rstem , twitteR,ggplot2,plyr,RColorBrewer 和 wordcloud 它可能会提供一些错误,但到目前为止我为我工作:P

      【讨论】:

      • OP 已经告诉我们的包的链接不再在 CRAN 中。
      • 是的,但你可以在档案中找到它,然后在 R 中手动安装包
      猜你喜欢
      • 2017-11-06
      • 2012-05-01
      • 1970-01-01
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 2010-11-14
      • 1970-01-01
      • 2013-02-02
      相关资源
      最近更新 更多