6

Rのテキストマイニングパッケージに次の機能がある可能性があるかどうか疑問に思っていました:

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

理想的には、既存のコーパスに追加のドキュメントを組み込みたいと考えています。

どんな助けでも大歓迎です

4

2 に答える 2

11

次のように使用できるはず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 パッケージ ドキュメントを参照してtm_combineください。

于 2011-07-07T20:50:50.463 に答える
0

ビッグデータ テキスト マイニング セットのコンテキストでも、この問題を克服します。データ セット全体を一度にロードすることはできませんでした。

ここでは、そのようなビッグデータセットの別のオプションが可能です。このアプローチは、ループ内で 1 つの文書コーパスのベクトルを収集することです。このようにすべてのドキュメントを処理した後、このベクターを 1 つの巨大なコーパスに変換して、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"])))
于 2017-05-27T12:31:12.800 に答える