stri_replace_all_fixed機能を使用して、Rで約4000個の文書を茎にしようとしています。しかし、私の言葉の単語の辞書は約から成っているので、それは非常に遅いです。 300kワード。文書がデンマーク語であり、したがってPorter Stemmer Algortihmが役に立たない(これはあまりにも攻撃的です)ので、私はこれをやっています。stri_replace_all_fixed大きなデータセットでは遅くなりました - 代替手段はありますか?
以下のコードを投稿しました。誰もがこれを行うための代替を知っていますか?
ロジック:各ドキュメントの各単語を調べます。 - > word = voc-tableの単語の場合は、tran-wordに置き換えます。 「VOC」は、データフレームの
##Read in the dictionary
voc <- read.table("danish.csv", header = TRUE, sep=";")
#Using the library 'stringi' to make the stemming
library(stringi)
#Split the voc corpus and put the word and stem column into different corpus
word <- Corpus(VectorSource(voc))[1]
tran <- Corpus(VectorSource(voc))[2]
#Using stri_replace_all_fixed to stem words
## !! NOTE THAT THE FOLLOWING STEP MIGHT TAKE A FEW MINUTES DEPENDING ON THE SIZE !! ##
docs <- tm_map(docs, function(x) stri_replace_all_fixed(x, word, tran, vectorize_all = FALSE))
構造:
Word Stem
1 abandonnere abandonner
2 abandonnerede abandonner
3 abandonnerende abandonner
...
313273 åsyns åsyn