ライブラリを使用して、用語とドキュメントのマトリックスを構築していtm
ます。
# Create corpus.
corporize <- function(dir_to_corporize)
{
crp <- Corpus(DirSource(dir_to_corporize, mode="text", encoding="ASCII"),
readerControl=list(reader=readPlain, language="en_EN"))
crp <- tm_map(crp, removeWords, stopwords("english"))
crp <- tm_map(crp, removePunctuation, preserve_intra_word_dashes=F)
crp <- tm_map(crp, removeNumbers)
crp <- tm_map(crp, stripWhitespace)
crp <- tm_map(crp, content_transformer(tolower))
}
ただし、用語と文書のマトリックスを確認すると、いくつかのストップワードが残っていることがわかりました。
the last time i saw
we need talk about kevin
you make me feel like
それはなぜですか、どうすればよいですか?