![](/img/trans.png)
[英]R and tm package: create a term-document matrix with a dictionary of one or two words?
[英]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"
此處,單詞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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.