Wrong import for nltk.corpus.reader.api (NLTK 3.0)

100 views
Skip to first unread message

spa...@vicomtech.org

unread,
Jan 12, 2015, 6:17:31 AM1/12/15
to nltk-...@googlegroups.com
Hi,

I am investigating the option to create a custom reader for the ES/CA AnCora corpus by extending the SyntaxCorpusReader class from nltk.corpus.reader.api. When I try to call the SyntaxCorpusReader class I get an AttributeError:

>>>from nltk.corpus.reader import api
>>>api.SyntaxCorpusReader
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SyntaxCorpusReader'

I checked the script apy.py under nltk/corpus/reader/api.py and it contains the SyntaxCorpusReader class but for some reason it is not accesible in the namespace of the api module.

I have looked into this further and I realized that the wrong api.py script is being imported:
>>>api.__file__
'/<PYTHONPKGS>/nltk/tokenize/api.pyc'
(where <PYTHONPKGS> is your local path to scripts)

I checked this in two different computers with NLTK 2.0.4 and 3.0.0 with fresh installations. It is obvious that there is a problem with the imports although everything seems to be all right in the __init__.py files.

Maybe is related to something with the LazyImport class?

Any help with this would be highly appreciated.

Regards,

Susana


Matías Guzmán Naranjo

unread,
Sep 2, 2015, 3:58:33 PM9/2/15
to nltk-users
I'm having the same problem, have you manage to solve it?

Alexis Dimitriadis

unread,
Sep 2, 2015, 4:11:49 PM9/2/15
to nltk-...@googlegroups.com
This should work:

    from nltk.corpus.reader import SyntaxCorpusReader

On 2 Sep 2015, at 15:20, Matías Guzmán Naranjo <morte...@gmail.com>
 wrote:
Reply all
Reply to author
Forward
0 new messages