使用wordnet提取同义词 [英] extracting synonyms using wordnet

查看:93
本文介绍了使用wordnet提取同义词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究论文并以R语言实现解决方案.我必须使用词网字典库查找同义词.我得到了针对单个单词的同义词,但是当我尝试使用一组单词的循环来获取同义词时,出现错误订阅已脱离约束".如果有人可以指导我如何使用循环针对文本中的每个单词获取同义词,或者还有其他方法可以做到这一点?这是我正在尝试的代码

I am currently working on my thesis and implementing the solution in R language. i have to find synonyms using word-net dictionary library. i get the synonyms against single word but when i try to get synonyms using loop for set of words i get the error "Subscription is out of bond".. kindly if some one can guide me how to get synonyms for against each word in text using loop or is there any other way to do it? here is the code i am trying

*my_corpus <- "closure animal wrong carnivore herbivore meat omnivore veg wrong"
  for (j in seq(my_corpus))
    {
      if(initDict()) {
           filter <- getTermFilter("ExactMatchFilter", "my_corpus", TRUE)
           terms <- getIndexTerms("NOUN", 5, filter)
           getSynonyms(terms[[my_corpus]])
        }
    }

*

推荐答案

require(stringr)
my_corpus <- str_split(my_corpus," ")[[1]]

用j替换"my_corpus"

replace "my_corpus" with j

将print()放在getSynonyms周围

put print() around getSynonyms

my_corpus <- "closure animal wrong carnivore herbivore meat omnivore veg wrong"
require(stringr)
my_corpus <- str_split(my_corpus," ")[[1]]
  for (j in (my_corpus))
    {
           filter <- getTermFilter("ExactMatchFilter", j, TRUE)
           terms <- getIndexTerms("NOUN", 5, filter)
           print(getSynonyms(terms[[1]]))
    }

尝试公司",并注意没有商机出现. wordnet软件包中的同义词非常不完整

Try "company" and notice how no businesses ever come up. Synonyms from wordnet package are very incomplete

这篇关于使用wordnet提取同义词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆