在最新版本的R中使用wordnet获取同义词

时间:2017-03-22 20:18:48

标签: r

我尝试在最新版本的R中使用wordnet包找到同义词。

我已经下载了wordnet文件,以下是错误操作:

> library(wordnet)
Warning message:
In initDict() :
  cannot find WordNet 'dict' directory: please set the environment variable WNHOME to its parent
> initDict("C:/Users/iris/Downloads/WordNet-3.0/WordNet-3.0/dict")
[1] TRUE
> library(wordnet)
> Str = synonyms("help")
Error in charmatch(x, WN_synset_types) : 
  argument "pos" is missing, with no default
> synonyms("company", "NOUN")
Error in getDict() : could not find Wordnet dictionary
> getDict("C:/Users/iris/Downloads/WordNet-3.0/WordNet-3.0/dict")
Error in getDict("C:/Users/iris/Downloads/WordNet-3.0/WordNet-3.0/dict") : 
  unused argument ("C:/Users/iris/Downloads/WordNet-3.0/WordNet-3.0/dict")

R中的wordnet包有什么常见问题吗?

library(wordnet)
Warning message:
In initDict() :
  cannot find WordNet 'dict' directory: please set the environment variable WNHOME to its parent
> initDict()
[1] FALSE
Warning message:
In initDict() :
  cannot find WordNet 'dict' directory: please set the environment variable WNHOME to its parent
> setDict("C:/Users/iris/Downloads/WordNet-3.0/WordNet-3.0/dict")
> getDict()
[1] "Java-Object{com.nexagis.jawbone.Dictionary@1540e19d}"
> initDict()
[1] FALSE
Warning message:
In initDict() :
  cannot find WordNet 'dict' directory: please set the environment variable WNHOME to its parent

1 个答案:

答案 0 :(得分:1)

这似乎对我有用(使用Sys.setenv(WNHOME ......并且没有initDict()):

library(wordnet)
Sys.setenv(WNHOME ="C:/<windows path>/WordNet-3.0/dict")
setDict("C:/<windows path>/WordNet-3.0/dict")
synonyms("car","NOUN")

[1] "auto"         "automobile"   "cable car"    "car"          "elevator car" "gondola"     
[7] "machine"      "motorcar"     "railcar"      "railroad car" "railway car"
相关问题