2017-05-18 43 views
-1

如何在R中词干完成后完成单词?r文本分析词干完成

x <- c("completed","complete","completion","teach","taught") 
tm <- Corpus(VectorSource(x)) 
tm <- tm_map(tm, stemDocument) 
inspect(tm) 

举例说明目的,因为实际的文本语料库要大得多。

我以前搜索过examples,它指向创建一组同义词,但对于大型语料库,如何才能获得同义词词典?对于动词,我怎样才能完成词干现在时?由于

回答

2

TM具有功能stemCompletion()

x <- c("completed","complete","completion","teach","taught") 
tm <- Corpus(VectorSource(x)) 
tm <- tm_map(tm, stemDocument) 
inspect(tm) 
dictCorpus <- tm 
tm <- tm_map(tm, stemDocument) 
tm <- tm_map(tm, stripWhitespace, mc.cores=cores) 

tm<-tm_map(tm, stemCompletion,dictionary=dictCorpus) 

至于完成动词目前的紧张,我不知道这是可能的TM。也许RWeka,word2vec或qdap将有方法,但我不确定。

一个快速和肮脏的解决方案可能是设置type = shorteststemDocument通常我认为现在时单词将比过去式和动名词短。