Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while implementing lda.py #8

Closed
robotsorcerer opened this issue Jun 1, 2015 · 2 comments
Closed

Error while implementing lda.py #8

robotsorcerer opened this issue Jun 1, 2015 · 2 comments

Comments

@robotsorcerer
Copy link

Hi @shuyo ,

Thanks a lot for providing this script for the public community.

I ran your code based on Karpathy's Nipspreview. I generally follow his README.md file to generate the respective wordclouds, thumbnails etc but I find that when I execute python lda.py -f allpapers.txt -k 7 --alpha=0.5 --beta=0.5 -i 100, I got the following output:

$ python lda.py -f allpapers.txt -k 7 --alpha=0.5 --beta=0.5 -i 100
Traceback (most recent call last):
File "lda.py", line 150, in
main()
File "lda.py", line 139, in main
docs = [voca.doc_to_ids(doc) for doc in corpus]
File "/home/lex/Desktop/nipspreview/vocabulary.py", line 65, in doc_to_ids
id = self.term_to_id(term)
File "/home/lex/Desktop/nipspreview/vocabulary.py", line 48, in term_to_id
term = lemmatize(term0)
File "/home/lex/Desktop/nipspreview/vocabulary.py", line 35, in lemmatize
w = wl.lemmatize(w0.lower())
File "/usr/local/lib/python2.7/dist-packages/nltk/stem/wordnet.py", line 40, in lemmatize
lemmas = wordnet._morphy(word, pos)
File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 99, in getattr
self.__load()
File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 64, in __load
except LookupError: raise e
LookupError:

Resource u'corpora/wordnet' not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- '/home/lex/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'

and I'm wondering what is wrong? Could you help me out? Thanks!

@robotsorcerer
Copy link
Author

I've figured this out. Pardon my taking your time please.
I needed to download 'corpora/wordnet'. So I entered python, imported nltk, import nltk and then did nltk.download() which seems to fix the issue nicely.
Thanks once again~!

@shuyo
Copy link
Owner

shuyo commented Jun 26, 2015

Sorry for my late response.
I'm glad to hear your problem has been solved.

@shuyo shuyo closed this as completed Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants