WordNetCorpusReader error

1,321 views
Skip to first unread message

David Liontooth

unread,
Dec 5, 2014, 11:28:06 PM12/5/14
to nltk-...@googlegroups.com

I installed the NLTK 3.0.0 release with python2.7.8.11 on Debian. My script bugs out with

   'WordNetCorpusReader' object has no attribute '_LazyCorpusLoader__args'

Here's the whole message:

Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "phrase-count.py", line 137, in count_year
    feature_vector = _count_phrases(captionfile, phrases_dict)
  File "phrase-count.py", line 102, in _count_phrases
    words = _read_caption_and_clean(captionfile)
  File "phrase-count.py", line 76, in _read_caption_and_clean
    return cleansing.clean(words)
  File "/home/liontooth/Programming/count-phrases/cleansing.py", line 10, in clean
    words = [__morphy(w) for w in words]
  File "/home/liontooth/Programming/count-phrases/cleansing.py", line 47, in __morphy
    result_set.insert(0, wn.morphy(word, wn.NOUN))
  File "/usr/lib/python2.7/dist-packages/nltk/corpus/util.py", line 99, in __getattr__
    self.__load()
  File "/usr/lib/python2.7/dist-packages/nltk/corpus/util.py", line 73, in __load
    args, kwargs  = self.__args, self.__kwargs
AttributeError: 'WordNetCorpusReader' object has no attribute '_LazyCorpusLoader__args'

Any suggestions as to what's going wrong?

Cheers,
Dave

Justin Barber

unread,
Dec 12, 2014, 2:44:17 PM12/12/14
to nltk-...@googlegroups.com
Dave,

I just answered a similar question on stackoverflow. This error occurs when you access a LazyCorpusLoader proxy object for a second time while it is in the process of being converted into a WordNetCorpusReader object. This would take place if you were using `threading` or `multiprocessing`. In order to avoid this issue, be sure the LazyCorpusLoader has finished transforming into a WordNetCorpusReader object before accessing the LazyCorpusLoader proxy object for a second time. See my answer on stackoverflow for further information. (Your question doesn't provide much detail, so I can't address your particular situtation here.)

Cheers,
Justin
Reply all
Reply to author
Forward
0 new messages