0

私のコーパスは次のようになります: 私のコーパス、myCorpus1 には 33704 ツイートが含まれています。以下のコードで確認できます。しかし、TermDocument Matrix である中間マトリックスを作成すると、3732 個のドキュメントしかありません。私の質問は、TermDocumentMatrix がどのように機能するかです。何か不足していますか?それとも、この関数は各ツイートを文書として扱うのではなく、独自の方法で文書を解析するのでしょうか?なぜ用語が非常に少ないのか不思議に思います。33704ツイートのテキストには10​​902以上あるはずだと思います

tweet_text2<-tweets2$text
myCleanedText <- sapply(tweet_text2,function(row) iconv(row, "latin1", "ASCII", sub=""))
as.vector(myCleanedText)
df<-data.frame(myCleanedText)
myCorpus1<-Corpus(VectorSource(as.vector(myCleanedText)))
myCorpus1<-tm_map(myCorpus1,content_transformer(tolower,removeURL,removeNumPunct),lazy=TRUE)
myCorpus1 <- tm_map(myCorpus1, removePunctuation,lazy=TRUE)
myCorpus1 <- tm_map(myCorpus1, removeNumbers,lazy=TRUE)
myStopwords <- c(stopwords('english'), "available", "via")
myStopwords<-setdiff(myStopwords,c("afraid","fear")) #varsa stopwordden cikar
myCorpus1<-tm_map(myCorpus1, stripWhitespace,lazy=TRUE)
myCorpus1<-tm_map(myCorpus1,as.PlainTextDocument,mc.cores=1)
myDtm <- as.matrix(TermDocumentMatrix(myCorpus1, control = list(minWordLength = 1,weighting=weightTfIdf,minDocFreq=0)))

> myCorpus1
<<VCorpus>>
Metadata:  corpus specific: 0, document level (indexed): 0
Content:  documents: 33704

> dim(myDtm)
[1] 10902  3732

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

4

0 に答える 0