如何在R3.2.0中使用情绪包

如何在R3.2.0中使用情绪包,r,packages,sentiment-analysis,R,Packages,Sentiment Analysis,我是一个ML爱好者。最近我开始使用R及其软件包。但我无法安装R3.2.0的情绪软件包。我在谷歌上搜索过这个问题。它说R 3.2.0不再提供情绪包。但我在许多github存储库中看到情绪包没有被使用,但其文件仍在使用。我的主要问题是如何使用R 3.2.0的情绪包?这里是一个起点。首先是一些安装情感插件的代码(感谢Dason提供的有用评论) 接下来,使用前一篇SO文章中的一些文本来显示您可能会做什么,您可以创建一个数据帧 安装情绪分析软件包: # install.packages("tm.lexic

我是一个ML爱好者。最近我开始使用R及其软件包。但我无法安装R3.2.0的情绪软件包。我在谷歌上搜索过这个问题。它说R 3.2.0不再提供情绪包。但我在许多github存储库中看到情绪包没有被使用,但其文件仍在使用。我的主要问题是如何使用R 3.2.0的情绪包?

这里是一个起点。首先是一些安装情感插件的代码(感谢Dason提供的有用评论)

接下来,使用前一篇SO文章中的一些文本来显示您可能会做什么,您可以创建一个数据帧

安装情绪分析软件包:

# install.packages("tm.lexicon.GeneralInquirer", repos="http://datacube.wu.ac.at", type="source")
library(tm.lexicon.GeneralInquirer)
# install.packages("tm.plugin.sentiment", repos="http://R-Forge.R-project.org")
library(tm.plugin.sentiment) # posted comments on SO about this not working
library(tm)
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
             "I am very scared from OP question, annoyed, and irritated.", "I am completely neutral about blandness.")
corpus <- Corpus(VectorSource(some_txt)) 
pos <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Positiv")))
neg <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Negativ")))
pos.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Positiv")) # this lists each document with number below

neg.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Negativ")) 

total.df <- data.frame(positive = pos.score, negative = neg.score)
total.df <- transform(total.df, net = positive - negative)

  positive negative net
1        3        1   2
2        0        1  -1
3        0        0   0
使用已安装的功能:

# install.packages("tm.lexicon.GeneralInquirer", repos="http://datacube.wu.ac.at", type="source")
library(tm.lexicon.GeneralInquirer)
# install.packages("tm.plugin.sentiment", repos="http://R-Forge.R-project.org")
library(tm.plugin.sentiment) # posted comments on SO about this not working
library(tm)
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
             "I am very scared from OP question, annoyed, and irritated.", "I am completely neutral about blandness.")
corpus <- Corpus(VectorSource(some_txt)) 
pos <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Positiv")))
neg <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Negativ")))
pos.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Positiv")) # this lists each document with number below

neg.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Negativ")) 

total.df <- data.frame(positive = pos.score, negative = neg.score)
total.df <- transform(total.df, net = positive - negative)

  positive negative net
1        3        1   2
2        0        1  -1
3        0        0   0

some_txt这里是一个起点。首先是一些安装情感插件的代码(感谢Dason提供的有用评论)

接下来,使用前一篇SO文章中的一些文本来显示您可能会做什么,您可以创建一个数据帧

安装情绪分析软件包:

# install.packages("tm.lexicon.GeneralInquirer", repos="http://datacube.wu.ac.at", type="source")
library(tm.lexicon.GeneralInquirer)
# install.packages("tm.plugin.sentiment", repos="http://R-Forge.R-project.org")
library(tm.plugin.sentiment) # posted comments on SO about this not working
library(tm)
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
             "I am very scared from OP question, annoyed, and irritated.", "I am completely neutral about blandness.")
corpus <- Corpus(VectorSource(some_txt)) 
pos <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Positiv")))
neg <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Negativ")))
pos.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Positiv")) # this lists each document with number below

neg.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Negativ")) 

total.df <- data.frame(positive = pos.score, negative = neg.score)
total.df <- transform(total.df, net = positive - negative)

  positive negative net
1        3        1   2
2        0        1  -1
3        0        0   0
使用已安装的功能:

# install.packages("tm.lexicon.GeneralInquirer", repos="http://datacube.wu.ac.at", type="source")
library(tm.lexicon.GeneralInquirer)
# install.packages("tm.plugin.sentiment", repos="http://R-Forge.R-project.org")
library(tm.plugin.sentiment) # posted comments on SO about this not working
library(tm)
some_txt<- c("I am very happy at stack overflow , excited, and optimistic.",
             "I am very scared from OP question, annoyed, and irritated.", "I am completely neutral about blandness.")
corpus <- Corpus(VectorSource(some_txt)) 
pos <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Positiv")))
neg <- sum(sapply(corpus, tm_term_score, terms_in_General_Inquirer_categories("Negativ")))
pos.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Positiv")) # this lists each document with number below

neg.score <- tm_term_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), 
                           terms_in_General_Inquirer_categories("Negativ")) 

total.df <- data.frame(positive = pos.score, negative = neg.score)
total.df <- transform(total.df, net = positive - negative)

  positive negative net
1        3        1   2
2        0        1  -1
3        0        0   0

一些_txt@figurine:可能重复的代码不起作用。我在那里为agstudy留下了一条评论,描述了score()之后的错误[以及之前关于相关错误的SO问题,未回答]。看起来我无法添加答案,但我可以评论。我能够直接从github安装tm.plugin.touction(适用于R3.2.0):install.packages(“devtools”)库(devtools)install_github(“mannau/tm.plugin.touction”)@figurine:可能重复的代码不起作用。我在那里为agstudy留下了一条评论,描述了score()之后的错误[以及之前关于相关错误的SO问题,未回答]。看起来我无法添加答案,但我可以评论。我可以直接从github安装tm.plugin.touction(对于R3.2.0):install.packages(“devtools”)库(devtools)install_github(“mannau/tm.plugin.touction”)这是如何回答这个问题的?我告诉你如何安装touction函数并在测试用例中使用它们。这就是OP所问的。他们的主要问题是如何安装它。我建议将其分离出来,并解释如何安装,因为这是一个实际的问题。不需要争论,但最后一句是关于如何使用该软件包的问题。我试图解决安装和使用这两个问题。可能重新考虑否决票吗?:)我没有投反对票。我对最后一句话的理解只是重申他们无法安装它。如果你没有访问权限,就不能使用它。我能从最后一句话看出你是从哪里来的。我仍然认为分离安装代码并添加一点解释是一个好主意,这会让你得到我的支持。这是如何回答这个问题的?我告诉你如何安装情感函数并在测试用例中使用它们。这就是OP所问的。他们的主要问题是如何安装它。我建议将其分离出来,并解释如何安装,因为这是一个实际的问题。不需要争论,但最后一句是关于如何使用该软件包的问题。我试图解决安装和使用这两个问题。可能重新考虑否决票吗?:)我没有投反对票。我对最后一句话的理解只是重申他们无法安装它。如果你没有访问权限,就不能使用它。我能从最后一句话看出你是从哪里来的。我仍然认为分离安装代码并添加一点解释将是一个好主意,这将使您获得我的支持。