Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import WordNet In NLTK

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
like image 313
Masoud Abasian Avatar asked Jul 12 '11 08:07

Masoud Abasian


People also ask

What is NLTK Download (' WordNet ')?

WordNet is a lexical database for the English language, which was created by Princeton, and is part of the NLTK corpus. You can use WordNet alongside the NLTK module to find the meanings of words, synonyms, antonyms, and more.

What does NLTK WordNet do?

WordNet is a lexical database of English. Using synsets, helps find conceptual relationships between words such as hypernyms, hyponyms, synonyms, antonyms etc. An exception class for wordnet-related errors. The lexical entry for a single morphological form of a sense-disambiguated word.

How is WordNet used in NLP?

A really useful lexical resource is WordNet. Its unique semantic network helps us find word relations, synonyms, grammars, etc. This helps support NLP tasks such as sentiment analysis, automatic language translation, text similarity, and more.


2 Answers

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.

like image 170
Fred Foo Avatar answered Sep 19 '22 21:09

Fred Foo


You should try these commands:

import nltk
nltk.download('wordnet')

It worked for me.

like image 40
Malik Hamza Avatar answered Sep 22 '22 21:09

Malik Hamza