文本挖掘软件包保留自己的停用词表并提供用于管理和汇总此类文本的有用工具。
让我们假设你的推文存储在一个向量中。
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)
你可能要考虑http://www.ark.cs.cmu.edu/TweetNLP/ – hadley