Method suggestions don't work for 'nltk.corpus.wordnet` (vscode)

45 Views Asked by At

When I write nltk.corpus.wordnet., method suggestions don't show up and I can't see the signatures of the functions that I call, even though the code executes fine.

This happens both in notebook and in regular .py files.


import nltk
nltk.corpus.wordnet

This code prints <WordNetCorpusReader in '/home/user/nltk_data/corpora/wordnet.zip/wordnet/'>

Is the module is stored in a .zip file that gets unzipped at runtime? Is that why it's invisible to the IDE?


I also can't find an api reference for this module. They have a reference for nltk.corpus.READER.wordnet but not for the one without reader. There's just no way for me to even know the names of the methods that are available.

1

There are 1 best solutions below

0
splaytreez On

Solved with a clutch...

Suggestions do work for nltk.corpus.reader.wordnet.WordNetCorpusReader, which is the same class that's imported with nltk.corpus.wordnet. I only needed to initialize it, so I did this:

from nltk.corpus import wordnet
import nltk.corpus.reader.wordnet as wn

reader = wn.WordNetCorpusReader(wordnet.root, wordnet._omw_reader)

Now reader works exactly like nltk.corpus.wordnet and has method suggestions