簡體   English   中英

在R tm包中的term-document矩陣中包括所有標記

[英]Including all tokens in the term-document matrix in the R tm package

我試圖用R中的tm包的TermDocumentMatrix函數創建一個術語文檔矩陣,發現其中不包含某些單詞。

> 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

矩陣建造之前消息信號被刪除,但我一直無法弄清楚它為什么會發生,我怎么能包括在語料庫中的所有令牌。

任何幫助表示贊賞。

使用TermDocumentMatrix的控制參數

require(tm)
tdm <- TermDocumentMatrix(Corpus(VectorSource("of is of is")), control =  list(stopwords=FALSE, wordLengths=c(0, Inf)))
rownames(tdm)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM