我试图用RTermDocumentMatrix
中的tm
包功能创建一个术语文档矩阵,发现其中不包含某些单词。
> library(tm)
> tdm <- TermDocumentMatrix(Corpus(VectorSource("The book is of great importance.")))
> rownames(tdm)
[1] "book" "great" "importance." "the"
此处,单词is和of已从矩阵中排除。如果语料库仅包含已删除的单词,则会显示以下消息。
> tdm <- TermDocumentMatrix(Corpus(VectorSource("of is of is")))
Warning message:
In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
> rownames(tdm)
NULL
该消息信号是和的矩阵是建立之前被删除,但它为什么会发生,我怎么能包括在语料库中的所有令牌我一直无法弄清楚。
任何帮助表示赞赏。
使用TermDocumentMatrix的控制参数
require(tm)
tdm <- TermDocumentMatrix(Corpus(VectorSource("of is of is")), control = list(stopwords=FALSE, wordLengths=c(0, Inf)))
rownames(tdm)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句