在使用R中的NLP时,有没有办法在词干中获得基本词而不是词根?
码:
> #Loading libraries
> library(tm)
> library(slam)
>
> #Vector
> Vec=c("happyness happies happys","sky skies")
>
> #Creating Corpus
> Txt=Corpus(VectorSource(Vec))
>
> #Stemming
> Txt=tm_map(Txt, stemDocument)
>
> #Checking result
> inspect(Txt)
A corpus with 2 text documents
The metadata consists of 2 tag-value pairs and a data frame
Available tags are:
create_date creator
Available variables in the data frame are:
MetaID
[[1]]
happi happi happi
[[2]]
sky sky
>
Run Code Online (Sandbox Code Playgroud)
我可以使用R得到"happyness happies happys"的基本单词"happy"(基本单词)而不是"happi"(根单词)
您可能正在寻找词干分析器。以下是CRAN 任务视图中的一些词干提取器:自然语言处理:
RWeka是 Weka 的接口,Weka 是用 Java 编写的用于数据挖掘任务的机器学习算法的集合。在自然语言处理环境中特别有用的是其标记化和词干提取功能。
Snowball提供了 Snowball 词干分析器,其中包含 Porter 词干分析器和其他几种针对不同语言的词干分析器。有关详细信息,请参阅 Snowball 网页。
Rstem是 Porter 词干提取算法的 C 版本的替代接口。