这里的word2vec程序是miklov他们的原生的接口、
一般来说建议使用
$ pip install word2vec
会遇到
('Compilation command:', 'gcc /tmp/pip-build-sWAR1E/word2vec/word2vec/c/word2vec.c -o bin/word2vec -march=corei7')
/tmp/cciCPwRP.o:在函数‘InitUnigramTable’中:
word2vec.c:(.text+0x7f):对‘pow’未定义的引用
word2vec.c:(.text+0xf6):对‘pow’未定义的引用
word2vec.c:(.text+0x196):对‘pow’未定义的引用
/tmp/cciCPwRP.o:在函数‘TrainModelThread’中:
word2vec.c:(.text+0x1bcd):对‘sqrt’未定义的引用
/tmp/cciCPwRP.o:在函数‘TrainModel’中:
word2vec.c:(.text+0x32e5):对‘pthread_create’未定义的引用
word2vec.c:(.text+0x3325):对‘pthread_join’未定义的引用
word2vec.c:(.text+0x3821):对‘sqrt’未定义的引用
/tmp/cciCPwRP.o:在函数‘main’中:
word2vec.c:(.text+0x4251):对‘exp’未定义的引用
collect2: error: ld returned 1 exit status
----------------------------------------
只需要加上编译条件:
root@master:/App# CFLAGS='-lpthread -lm' pip install word2vec
Collecting word2vec
Using cached https://files.pythonhosted.org/packages/5b/33/8e1cf93216342f0fe8aa4484ef1a833a12c4f6d6bf8e8b46ecc0feb5e5e8/word2vec-0.9.2.tar.gz
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from word2vec)
Requirement already satisfied: cython in /usr/local/lib/python2.7/dist-packages (from word2vec)
Building wheels for collected packages: word2vec
Running setup.py bdist_wheel for word2vec ... done
Stored in directory: /root/.cache/pip/wheels/89/a1/cb/417bcc7143a3e2befcc82da185ce8ad4a340eb82c0bf48969c
Successfully built word2vec
Installing collected packages: word2vec
Successfully installed word2vec-0.9.2