Import WordNet In NLTK

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

I want to import wordnet dictionary but when i import Dictionary form wordnet i see this error :

 for l in open(WNSEARCHDIR+'/lexnames').readlines(): IOError: [Errno 2] No such file or directory: 'C:\\Program Files\\WordNet\\2.0\\dict/lexnames' 

I install wordnet2.1 in this directory but i cant import please help me to solve this problem

import nltk from nltk import * from nltk.corpus import wordnet from wordnet import Dictionary  print '-----------------------------------------' print Dictionary.length 

回答1:

The following works for me:

>>> nltk.download() # Download window opens, fetch wordnet >>> from nltk.corpus import wordnet as wn 

Now I've a WordNetCorpusReader called wn. I don't know why you're looking for a Dictionary class, since there's no such class listed in the docs. The NLTK book, in section 2.5, explains what you can do with the nltk.corpus.wordnet module.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!