0

我正在尝试用RTermDocumentMatrix中的包的功能制作一个术语文档矩阵tm,发现有些单词不包括在内。

> library(tm)
> tdm <- TermDocumentMatrix(Corpus(VectorSource("The book is of great importance.")))
> rownames(tdm)
[1] "book"        "great"       "importance." "the" 

在这里,单词isof已从矩阵中排除。如果语料库只包含删除的单词,它会给出以下消息。

> 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

在构建矩阵之前删除了isof的消息信号,但我无法弄清楚它发生的原因以及如何将所有标记包含在语料库中。

任何帮助表示赞赏。

4

1 回答 1

3

使用 TermDocumentMatrix 的控制参数

require(tm)
tdm <- TermDocumentMatrix(Corpus(VectorSource("of is of is")), control =  list(stopwords=FALSE, wordLengths=c(0, Inf)))
rownames(tdm)
于 2014-01-31T16:05:45.673 回答