我想使用wordnet
lemmatizer对a
> a<-c("He saw a see-saw on a sea shore", "she is feeling cold")
> a
[1] "He saw a see-saw on a sea shore" "she is feeling cold"
我将a
转换为语料库并执行预处理步骤(如删除词尾词,词形还原等)
> a <- Corpus(VectorSource(a))
我想以下面的方式进行词形还原,
> filter <- getTermFilter("ExactMatchFilter", a, TRUE)
> terms <- getIndexTerms("NOUN", 1, filter)
> sapply(terms, getLemma)
但我收到此错误
> filter <- getTermFilter("ExactMatchFilter", a, TRUE)
Error in .jnew(paste("com.nexagis.jawbone.filter", type, sep = "."), word, :
java.lang.NoSuchMethodError: <init>
我的想法是整个语料库而不是一个单词,它是如何实现的?
答案 0 :(得分:4)
将代码放入循环中,您可以尝试这样的事情:
lapply(a,function(x){
x.filter <- getTermFilter("ExactMatchFilter", x, TRUE))
terms <- getIndexTerms("NOUN", 1, x.filter)
sapply(terms, getLemma)
})