2012-11-26 15 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)