【问题标题】:Sentiment analysis using R [closed]使用 R 进行情绪分析
【发布时间】:2012-05-01 06:19:12
【问题描述】:

是否有任何专注于情绪分析的 R 包?我有一个小型调查,用户可以在其中写下关于他们使用网络工具的体验的评论。我要求一个数字排名,并且可以选择包含评论。

我想知道评估评论正面或负面的最佳方法是什么。我希望能够使用 R 将其与用户提供的数字排名进行比较。

【问题讨论】:

  • 在这里查看 Jeffery Breen 的作品:slideshare.net/jeffreybreen/r-by-example-mining-twitter-for
  • @mweylandt,作为 Jeffrey 本人,这是“r-e-y”。但这似乎是一种简单、整洁的方法。
  • Jeffrey Breen 为像我这样的文本挖掘初学者提供了一个极好的指南。我提倡访问Paras共享的链接。通过该链接,您可以访问专门研究该主题的 Bing Liu 教授网站:[意见挖掘、情绪分析和意见垃圾邮件检测][1] [1]:cs.uic.edu/~liub/FBS/sentiment-analysis.html问候,罗德

标签: r sentiment-analysis


【解决方案1】:

您仍然可以使用情绪包。按照下面的脚本安装它。

您可能需要 R 3.x。

require(devtools)
install_url("http://cran.r-project.org/src/contrib/Archive/sentiment/sentiment_0.2.tar.gz")
require(sentiment)
ls("package:sentiment")

【讨论】:

  • setiment 包依赖于 rstem 包,R 3.0.2 也不支持
  • 是的,即使是源站点:sites.google.com/site/miningtwitter/home 警告:由于 twitter API 的更改,不再支持此 google 站点中的代码...尽管非常欢迎您浏览其内容
【解决方案2】:

我尝试重新组织并提供一个有凝聚力的情绪分析包here。 SentR 包括词干提取和预处理,并提供对 ViralHeat API、默认聚合函数以及更高级的朴素贝叶斯方法的访问。

安装比较简单:

install.packages('devtools')
require('devtools')
install_github('mananshah99/sentR')
require('sentR')

还有一个简单的分类例子:

# Create small vectors for happy and sad words (useful in aggregate(...) function)
positive <- c('happy', 'well-off', 'good', 'happiness')
negative <- c('sad', 'bad', 'miserable', 'terrible')

# Words to test sentiment
test <- c('I am a very happy person.', 'I am a very sad person', 
'I’ve always understood happiness to be appreciation. There is no greater happiness than appreciation for what one has- both physically and in the way of relationships and ideologies. The unhappy seek that which they do not have and can not fully appreciate the things around them. I don’t expect much from life. I don’t need a high paying job, a big house or fancy cars. I simply wish to be able to live my life appreciating everything around me. 
')

# 1. Simple Summation
out <- classify.aggregate(test, positive, negative)
out

# 2. Naive Bayes
out <- classify.naivebayes(test)
out

提供以下输出:

  score
1     1
2    -1
3     2

     POS                NEG                 POS/NEG             SENT      
[1,] "9.47547003995745" "0.445453222112551" "21.2715265477714"  "positive"
[2,] "1.03127774142571" "9.47547003995745"  "0.108836578774127" "negative"
[3,] "67.1985217685598" "35.1792261323723"  "1.9101762362738"   "positive"

请随时贡献:) 希望有所帮助!

【讨论】:

  • 嗨 Manan,我喜欢你的解决方案。我尝试过并将尝试更多。您是否有任何用例,例如您已公开供其他人使用的任何项目?谢谢
  • @seakyourpeak 感谢您的评论!我正在开发一个示例 Twitter 情绪提取存储库 (github.com/manans99),但目前每个函数的文档都包含一个示例用例。如果您还有任何问题,请随时 PM 我。
  • @manan 我目前正在处理 Facebook 帖子数据。我已经能够提取帖子并构建一个 wordcloud。我想知道您是否认为在我的列表中使用最常用的词来表示否定和肯定是一个好主意。例如:如果在我的 wordcloud 中我发现 like,bad,great,love,happy,sad,plane, car, transport.. 我会使用 like,great,love,happy 作为正面分类器,sad,bad 作为负面分类器.. ?
【解决方案3】:

还有this package:

sentiment: Tools for Sentiment Analysis

sentiment 是一个 R 包,带有用于情感分析的工具,包括用于积极/消极和情感分类的贝叶斯分类器。

2012 年 12 月 14 日更新:它已被删除到 archive...

2013 年 3 月 15 日更新:qdap 包有一个 polarity 函数,基于 Jeffery Breen 的工作

【讨论】:

  • R 3.3 不再提供此包
【解决方案4】:

有关使用 1) Viral Heat API 2) Jeffrey Breen 的方法 3) 使用 Sentiment Package 的分步指南,请查看此链接:https://sites.google.com/site/miningtwitter/questions/sentiment

【讨论】:

    【解决方案5】:

    Here's 我在 R 中所做的情感分析工作。

    代码绝不是经过修饰或打包好的,但我posted it on Github 带有基本文档。我使用了ViralHeat sentiment API,它只返回JSON,所以进行情感分析的实际函数非常简单(参见代码here)。

    如果您在使用它时遇到问题,请随时与我联系。请注意,您需要先向 ViralHeat 注册一个 API 密钥,然后才能使用它。如果您发现配额过于严格,我已经联系了他们,他们很乐意在我使用 API 的几个月里给我更多的查询。

    【讨论】:

      猜你喜欢
      • 2017-11-06
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多