glove-python icon indicating copy to clipboard operation
glove-python copied to clipboard

Problem running the example script

Open kylemadigan opened this issue 10 years ago • 9 comments

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 my_corpus.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.

kylemadigan avatar Feb 01 '16 09:02 kylemadigan

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).

maciejkula avatar Feb 01 '16 22:02 maciejkula

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

kylemadigan avatar Feb 02 '16 01:02 kylemadigan

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

YantianZha avatar May 06 '16 21:05 YantianZha

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

abhipsabasu avatar Sep 25 '16 08:09 abhipsabasu

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

ankian27 avatar Oct 03 '16 01:10 ankian27

@ankian27 It didn't work for me.

akeshwarj avatar Jan 23 '17 09:01 akeshwarj

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?

AutomataVM avatar Sep 11 '17 03:09 AutomataVM

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

  • python setup.py cythonize
  • pip install -e .

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 :) )

Manfed avatar Nov 25 '17 11:11 Manfed

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

WhiskersReneeWe avatar Jan 28 '19 02:01 WhiskersReneeWe