maciejkula / glove-python

Toy Python implementation of http://www-nlp.stanford.edu/projects/glove/
Apache License 2.0
1.25k stars 319 forks source link

Problem running the example script #43

Open kylemadigan opened 8 years ago

kylemadigan commented 8 years ago

Hi there, I would like to try your example.py but I have no idea what corpus are to use/ I have just started learning python and machine learning and I am really confused. In your using guide example: ipython -i -- examples/example.py -c my_corpus.txt -t 10

I tried using the link that you have provided (http://www-nlp.stanford.edu/projects/glove) under "Download pre-trained word vectors" - I chose the Wikipedia 2014 + Gigaword 5 - (glove.6B.zip). In this glove.6B.zip file there are 4 files (glove.6B.50d , glove.6B.100d, glove.6B.200d and glove.6B.300d)

In the python command I tried running it using -i -- examples/example.py -c mycorpus.txt -t 10 where I renamed on the the file i.e. (glove.6B.50d to my corpus.txt).

I get an error message where it says : No module named corpus_cython. Did I do any of the steps wrongly?

I was wondering ,if you can provide me with the link to "my_corpus.txt" where you can get the result

In [1]: glove.most_similar('physics') Out[1]: [('biology', 0.89425889335342257), ('chemistry', 0.88913708236100086), ('quantum', 0.88859617025616333), ('mechanics', 0.88821824562025431)

Thank you.

maciejkula commented 8 years ago

A couple of tips:

  1. You need to install the package before you can run the code. This is normally done by running pip install glove_python or pip install . in the directory where you cloned the code. If you are on OSX/Windows this could be more complicated, and at the moment I haven't really got much advice to offer.
  2. The corpus file in the example is a simple text file, one sentence per line (if memory serves). You can try downloading and parsing wikipedia dumps for this (the -w flag in the example might be of use https://github.com/maciejkula/glove-python/blob/master/examples/example.py#L41). I used a small dump like this to provide the example you mentioned. The pre-trained word vectors you downloaded are just that: the output of a model like this, rather than the input.

Hope this helps (somewhat).

kylemadigan commented 8 years ago

Hi , thank you for the advice. I have installed glove_python and even cython using pip cmd but for some reason the script was not able to run and this message appears "No module named corpus_cython." asd

Any idea what caused this issue? Thanks

YantianZha commented 8 years ago

Has anyone solved this problem? I will try to solve it.

abhipsabasu commented 7 years ago

Same error is coming. No module named corpus_cython. If anyone has found a way to deal with it then please let me know

ankian27 commented 7 years ago

I got it to work. I guess the problem was that I did not execute the 'pip install .' command in the cloned repository, instead executed the command before cloning it. Anyways got it to work by copying the contents of '/usr/local/lib/python2.7/dist-packages' (This directory containing the required modules like Cython and glove) and pasting it in the cloned repository. Say yes to all the prompts to merge the directories or replacing the files and it would work

akeshwarj commented 7 years ago

@ankian27 It didn't work for me.

AutomataVM commented 6 years ago

didn't work for me either. I'm on ubuntu and I installed everything possible but I still receive the same message, what could it be?

Manfed commented 6 years ago

@kylemadigan I solved this issue by running commands from Development section of readme:

After that I used command: ipython -i -- examples/example.py -c plwiki-20171103-pages-articles.xml.bz2 -t 20 -w for now everything is working (still :) )

WhiskersReneeWe commented 5 years ago

I did the above. But it says no module named genism even though I installed it.