2017-07-06 62 views
0

我有一个260 RTI应用程序的数据集。我应该对他们执行LDA。我使用tm和RTextTools软件包创建了term-doc矩阵。但是,输出差别很大。 Tm软件包不显示任何稀疏的条目数量。总条款数量差别很大。 下面是代码:为什么tm包和RTextTools包的输出不同?

library("tm") 
library("RTextTools") 
<I read the data here into a variable called 'data'> 
doc = Corpus(VectorSource(data)) 
m = create_matrix(data, language = "english", removeNumbers = TRUE, removePunctuation = TRUE, stemWords = TRUE, weighting = weightTf) #RtextTools statement 
tdm <- TermDocumentMatrix(doc, control = list(removePunctuation = TRUE, removeNumbers = TRUE, language = "english", stemWords = TRUE, stopWords = TRUE, weighting = weightTf) #tm statement 
>m 
#<<DocumentTermMatrix (documents: 260, terms: 951)>> 
Non-/sparse entries: 2669/244591 
Sparsity   : 99% 
>tdm 
#<<TermDocumentMatrix (terms: 1024, documents: 1)>> 
Non-/sparse entries: 1024/0 
Sparsity   : 0% 

如果您需要的数据集来理解这个问题更好,让我知道。

回答

0

请参阅?termFreq - 它必须是stemming=TRUE, stopwords=TRUE而不是stemWords = TRUE, stopWords = TRUE。另请注意,SimpleCorpus对象触发TermDocumentMatrix的默认行为可能会覆盖您的控制参数。

+0

所以你建议使用VCorpus? – BlackSwan

+0

@HimabinduBoddupalli是的。 – lukeA

+0

doc = VCorpus(VectorSource(data)) tdm < - TermDocumentMatrix(doc,control = list(language =“english”,removeNumbers = TRUE,removePuncutation = TRUE,stemming = TRUE,stopWords = TRUE,weighting = weightTf))Still不起作用。 – BlackSwan

相关问题