r 文本分析词干补全
r text analysis stem completion
如何在R中完成词干后的单词?
x <- c("completed","complete","completion","teach","taught")
tm <- Corpus(VectorSource(x))
tm <- tm_map(tm, stemDocument)
inspect(tm)
用于说明目的的示例,因为实际的文本语料库要大得多。
我之前搜索过 examples 是指创建一组同义词,但是对于大型语料库,如何获得诸如同义词词典?对于动词,我怎样才能将词干词完成为当前时态?谢谢
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 会有方法,但我不确定。
一个快速而肮脏的解决方案可能是在 stemDocument
中设置 type = shortest
通常我认为当前时态词会比过去时态和动名词短。
如何在R中完成词干后的单词?
x <- c("completed","complete","completion","teach","taught")
tm <- Corpus(VectorSource(x))
tm <- tm_map(tm, stemDocument)
inspect(tm)
用于说明目的的示例,因为实际的文本语料库要大得多。
我之前搜索过 examples 是指创建一组同义词,但是对于大型语料库,如何获得诸如同义词词典?对于动词,我怎样才能将词干词完成为当前时态?谢谢
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 会有方法,但我不确定。
一个快速而肮脏的解决方案可能是在 stemDocument
中设置 type = shortest
通常我认为当前时态词会比过去时态和动名词短。