tm
-packageを使用してRでテキストマイニングを行っています。すべてが非常にスムーズに機能します。ただし、ステミング後に 1 つの問題が発生します ( http://en.wikipedia.org/wiki/Stemming )。明らかに、同じ語幹を持つ単語がいくつかありますが、それらが「一緒に投げられない」ことが重要です (これらの単語は異なる意味を持っているため)。
例として、以下の 4 つのテキストを参照してください。ここでは、「講師」または「講義」(「協会」と「協会」)を同じ意味で使用することはできません。ただし、これはステップ 4 で行われることです。
一部のケース/単語に対してこれを手動で実装するエレガントなソリューションはありますか (たとえば、「講師」と「講義」は 2 つの異なるものとして保持されます)。
texts <- c("i am member of the XYZ association",
"apply for our open associate position",
"xyz memorial lecture takes place on wednesday",
"vote for the most popular lecturer")
# Step 1: Create corpus
corpus <- Corpus(DataframeSource(data.frame(texts)))
# Step 2: Keep a copy of corpus to use later as a dictionary for stem completion
corpus.copy <- corpus
# Step 3: Stem words in the corpus
corpus.temp <- tm_map(corpus, stemDocument, language = "english")
inspect(corpus.temp)
# Step 4: Complete the stems to their original form
corpus.final <- tm_map(corpus.temp, stemCompletion, dictionary = corpus.copy)
inspect(corpus.final)