understanding nltk with python
My nltk data is ~/nltk_data/corpora/words/(en,en-basic,README)
According to init.py inside ~/lib/python2.7/site-packages/nltk/corpus , to
read a list of the words in the Brown Corpus, use
nltk.corpus.brown.words():
>>> from nltk.corpus import brown
>>> print brown.words()
['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', ...]
This init.py has
words = LazyCorpusLoader(
'words', WordListCorpusReader, r'(?!README|\.).*')
1.] So when I write
>>>from nltk.corpus import words Am I importing the 'words' function from
"init.py" which resides in directory
"python2.7/site-packages/nltk/corpus" ???
2.] Also why this happening:-
>>> import nltk.corpus.words
ImportError: No module named words
>>> from nltk.copus import words
WORKS FINE
3.] The "brown" corpus resides inside ~/nltk_data/corpora (and not in
nltk/corpus). So why does this command work ??
>>> from nltk.corpus import brown
I mean , shouldnt it be this --
>>> from nltk_data.corpora import brown
No comments:
Post a Comment