私はコーパスに対してunigramsとbigramsの2つの文書 - 項行列を作ろうとしています。しかし、バイグラム・マトリックスは現在、ユニグラム・マトリックスとまったく同じです。私はなぜその理由がわかりません。R-bigramトークナイザの文書用語行列が動作しない
コード:
docs<-Corpus(DirSource("data", recursive=TRUE))
# Get the document term matrices
BigramTokenizer <- function(x) NGramTokenizer(x, Weka_control(min = 2, max = 2))
dtm_unigram <- DocumentTermMatrix(docs, control = list(tokenize="words",
removePunctuation = TRUE,
stopwords = stopwords("english"),
stemming = TRUE))
dtm_bigram <- DocumentTermMatrix(docs, control = list(tokenize = BigramTokenizer,
removePunctuation = TRUE,
stopwords = stopwords("english"),
stemming = TRUE))
inspect(dtm_unigram)
inspect(dtm_bigram)
Iは、(X、N = 2)nグラムを使用しようとしたnグラムパッケージからトークナイザとして、それはどちらか動作しません。どのようにしてbigramトークンを修正するのですか?
私もこの問題を抱えています。答えが見つかったら教えてください。 –
返事の遅れて、申し訳ありませんが、私はコーパスの代わりにVCorpusを使用してこれを動作させました。 – filaments