R文本挖掘包:允许将新文档合并到现有语料库中

R文本挖掘包:允许将新文档合并到现有语料库中,r,text,text-mining,R,Text,Text Mining,我想知道R的文本挖掘包是否有可能具有以下功能: myCorpus <- Corpus(DirSource(<directory-contatining-textfiles>),control=...) # add docs myCorpus.addDocs(DirSource(<new-dir>),control=...) myCorpus您应该能够像中一样使用c(,) > library(tm) > data("acq") > data("cr

我想知道R的文本挖掘包是否有可能具有以下功能:

myCorpus <- Corpus(DirSource(<directory-contatining-textfiles>),control=...)
# add docs
myCorpus.addDocs(DirSource(<new-dir>),control=...)

myCorpus您应该能够像中一样使用
c(,)

> library(tm)
> data("acq")
> data("crude")
> together <- c(acq,crude)
> acq
A corpus with 50 text documents
> crude
A corpus with 20 text documents
> together
A corpus with 70 text documents
>库(tm)
>数据(“acq”)
>数据(“原油”)
>联合acq
包含50个文本文档的语料库
>粗糙的
包含20个文本文档的语料库
>一起
包含70个文本文档的语料库

您可以在
tm_combine
下找到更多信息我在大数据文本挖掘集的上下文中也解决了这个问题。无法一次加载整个数据集

在这里,这种大数据集的另一种选择是可能的。该方法是在循环中收集一个文档语料库的向量。在像这样处理所有文档之后,可以将该向量转换为一个巨大的语料库,例如在其上创建DTM

# Vector to collect the corpora:
webCorpusCollection <- c()

# Loop over raw data:
for(i in ...) {

  try({      

    # Convert one document into a corpus:
    webDocument <- Corpus(VectorSource(iconv(webDocuments[i,1], "latin1", "UTF-8")))

    #
    # Do other things e.g. preprocessing...
    #

    # Store this document into the corpus vector:
    webCorpusCollection <- rbind(webCorpusCollection, webDocument)

  })
}

# Collecting done. Create one huge corpus:
webCorpus <- Corpus(VectorSource(unlist(webCorpusCollection[,"content"])))
收集语料库的向量:
感谢您的回复。我不知道更新的tm手册。以前的tm手册(2010或以前的版本)中没有此功能。