Bri*_*ian 14 r corpus text-mining stop-words tm
我在R中有一个使用该tm软件包的语料库.我正在应用该removeWords功能来删除停用词
tm_map(abs, removeWords, stopwords("english")) 
有没有办法将自己的自定义停用词添加到此列表中?
Jam*_*mes 35
stopwords只是为你提供了一个单词的向量,只需c将你自己的单词与之结合起来.
tm_map(abs, removeWords, c(stopwords("english"),"my","custom","words")) 
小智 5
将您的自定义保存stop words在 csv 文件中(例如:)word.csv。
library(tm)
stopwords <- read.csv("word.csv", header = FALSE)
stopwords <- as.character(stopwords$V1)
stopwords <- c(stopwords, stopwords())
然后你可以申请custom words你的文本文件。
text <- VectorSource(text)
text <- VCorpus(text)
text <- tm_map(text, content_transformer(tolower))
text <- tm_map(text, removeWords, stopwords)
text <- tm_map(text, stripWhitespace)
text[[1]]$content