2013-03-04 48 views
8

R中的「情感」包已從Cran存儲庫中刪除。什麼是可以進行輿情分析的其他軟件包?除了「情緒」之外還有其他什麼包可以做R中的情感分析嗎?

例如,我可以如何使用其他軟件包重寫?

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.") 
+0

qdap做了一個極性的事情,但它在這一點上是低水平的。本質上它是一個字典查找系統,可能無法很好地擴展到大型項目。它更多用於話語研究。 – 2013-03-04 04:14:50

+0

你看過鏈接到這裏的工作流程和功能嗎? http://stackoverflow.com/q/10233087/1036500下面是其他兩種方法的摘要:https://sites.google。com/site/miningtwitter/questions/sentiment – Ben 2013-03-04 04:37:16

+1

你可以這樣做,'library(sos); findFn('sentiment analysis')',你基本上有'qdap'和'textir',但也有'tm.plugin。情緒「的時間序列..在R-Forge中,」情感「套裝依然存在。 – agstudy 2013-03-04 04:38:57

回答

12

我找不到sentiment package.This是基於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函數預處理語料庫:

  • tolower的
  • removePunctuation
  • removeNumbers = TRUE,
  • removeWords =列表(停用詞( 「英語」)),
  • stripWhitespace
  • stemDocument
  • minWordLength = 3,

然後,應用評分功能:

  • 極性
  • 主觀性
  • pos_refs_per_ref
  • neg_refs_per_ref
  • senti_diffs_per_ref
+0

每次得分()代碼拋出一個錯誤:得分< - 得分(corpus.txt) Error.TermDocumentMatrix(list(i = c(2L,6L,8L,11L,12L,: 找不到函數「tm_tag_score」。其他人遇到不同的錯誤:http://stackoverflow.com/questions/24612080/tm-plugin-sentiment-issue-error-could-not-find-function-dmetadata。你能建議還是應該發佈一個新問題?謝謝 – lawyeR 2015-04-28 12:46:05

0

要安裝的情感分析包中使用此 http://cran.r-project.org/web/packages/sentiment/index.html 因爲包已經很老了,R cran也刪除了d他們從他們的網站。

,在安裝之前所需的軟件包都TM,Rstem,微博GGPLOT2,plyr,RColorBrewer和wordcloud 它可以提供一些錯誤,但我爲我工作至今:P

+0

鏈接到OP已經告訴我們的軟件包已不在CRAN中 – neilfws 2014-04-17 01:49:50

+0

是的,但是您可以在檔案中找到它,然後在R中手動安裝軟件包 – Napmi 2014-05-03 12:47:40

2

這是我做過什麼中的R版本安裝 '情緒' 0.2 3.0.2

我從網上下載資源庫中的 'sentiment_0.2.tar.gz' http://cran.r-project.org/src/contrib/Archive/sentiment/

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

然後我用命令從本地zip安裝包:

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

這是我有:

警告在install.packages: 包 'C:/sentiment_0.2.tar.gz' 不可用(對於R版本3.0.2)

安裝封裝成 'C:/Users/y65liu/Documents/R/win-library/3.0' (爲 'LIB' 是未指定)

**安裝源包 '情緒' ...

**包'情緒'蘇ccessfully解壓和MD5校驗和檢查

** [R

**數據

**準備包延遲加載

**幫助

**安裝幫助指數

**建築包裝指數

**測試安裝的軟件包是否可以加載

**完成(情緒)?

當我調用庫,該庫定期加載到它相關的軟件包(「以舊換新」,「Rstem」)

您可能發現文檔放在這裏使用的感悟包:

https://sites.google.com/site/miningtwitter/questions/sentiment/sentiment

希望得到這個幫助!