2012-11-26 16 views
3

我已經使用R來挖掘tweets,並且我得到了tweets中使用的最頻繁的詞。然而,最常見的詞是這樣的:尋找twit和文本消息風格的停止詞

[1] "cant"  "dont"  "girl"  "gonna" "lol"  "love"  
[7] "que"  "thats" "watching" "wish"  "youre" 

我正在尋找趨勢和文本中的名稱和事件。 我想知道是否有方法從語料庫中刪除這種文本消息風格的單詞(如要去,想要......)?他們有沒有停用詞? 任何幫助,將不勝感激。

+2

你可能要考慮http://www.ark.cs.cmu.edu/TweetNLP/ – hadley

回答

4

文本挖掘軟件包保留自己的停用詞表並提供用於管理和彙總此類文本的有用工具。

讓我們假設你的推文存儲在一個向量中。

library(tm) 
words <- vector_of_strings 
corpus <- Corpus(VectorSource(words)) 
corpus <- tm_map(corpus, removePunctuation) 
corpus <- tm_map(corpus, function(x) tolower(x)) 
corpus <- tm_map(corpus, function(x) removeWords(x, 
       stopwords())) 

可以使用的最後一行用自己的停止字()的名單:

stoppers <- c(stopwords(), "gonna", "wanna", "lol", ...) 

不幸的是,你必須產生自己的「短信」或「網絡消息」的列表停用詞。

但是,你能欺騙了一下,從NetLingo借款(http://vps.netlingo.com/acronyms.php

library(XML) 
theurl <- "http://vps.netlingo.com/acronyms.php" 
h <- htmlParse(theurl) 
h <- getNodeSet(h,"//ul/li/span//a") 
stoppers <- sapply(h,xmlValue)