2012-11-13 52 views
7

我有以下兩個DTM-S:[R DocumentTermMatrix控制列表不工作,自動忽略未知參數

dtm <- DocumentTermMatrix(t) 

dtmImproved <- DocumentTermMatrix(t, 
       control=list(minWordLength = 4, minDocFreq=5)) 

當我實現這一點,我看到兩個相等的DTM-S,如果我打開dtmImproved,有帶有3個符號的詞。爲什麼minWordLength參數不起作用?謝謝!

> dtm 
A document-term matrix (591 documents, 10533 terms) 

Non-/sparse entries: 43058/6181945 
Sparsity   : 99% 
Maximal term length: 135 
Weighting   : term frequency (tf) 
> dtmImproved 
A document-term matrix (591 documents, 10533 terms) 

Non-/sparse entries: 43058/6181945 
Sparsity   : 99% 
Maximal term length: 135 
Weighting   : term frequency (tf) 
+0

此外,當我添加任何東西到「列表(......)」什麼也沒發生,版本'tm'是否使用的是沒有任何警告或某物其他 –

回答

23
dtmImproved <- DocumentTermMatrix(t, control=list(wordLengths=c(4, 15), 
            bounds = list(global = c(5,Inf)))) 

這解決了問題!由於缺乏適當的文件真的MADS我失望(:

+1

。 TermDocumentMatrix的幫助列出了全局選項並給出了本地選項的鏈接。 'minWordLength'從不列爲選項,但詳細描述'wordLengths'。該文檔顯示寫得很好,易於遵循。 – mnel

+0

是的,這是一個幫助,不幸找不到谷歌搜索,但它更像是我的錯) –

+1

@ mnel:它默默地忽略任何它不識別的參數,例如, '(control = list(bounds = list(c(0,Inf))))''而不是'(control = list(bounds = list(global = c(0,Inf))))'。這是一個很大的痛苦。您是否發現缺失的標籤「全球」?我沒有...... – smci

0

它始終是一個好主意,看是否可用源代碼閱讀wordcloud功能@ GitHub上的源代碼,這裏是這樣說的:
#作者:ianfellows
.....
如果(min.freq> MAX(頻率))
min.freq < - 0

所以你DocumentTermMatrix,返回MAX(頻率)< min.freq約束,且你設置的,也就是說,非條件出現在你設定的min.freq界限以上。

希望這有助於 MJJ