我正在使用tm
-package进行R中的一些文本挖掘。一切都很顺利。但是,在阻塞之后会出现一个问题(http://en.wikipedia.org/wiki/Stemming)。显然,有一些词汇具有相同的词干,但重要的是它们不是“一起”(因为这些词语意味着不同的东西)。使用tm-package进行文本挖掘 - 词语词干
例如,请参阅下面的4个文本。在这里你不能使用“讲师”或“讲座”(“协会”和“同伴”)互换。但是,这是在步骤4中完成的。
是否有任何优雅的解决方案如何对某些案例/单词进行手动实现(例如,“讲师”和“讲座”保留为两个不同的东西)?
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)
这是干扰点。你这样做是为了获取根词。如果你想保留差异,那就不要干涉。 –
我知道。但是,在某些情况下,是否有一种优雅的方式来改变它? – majom