Hello World from OSS Silicon Valley


HowToUse/Gensim/0.13


#contents

*Prerequisite [#w093136a]
-Python installation (You can refer [[HowToUse/Python/2.7]])
-Python installation (You can refer [[HowToUse/Python/3.5]])
-MeCab installation (You can refer [[HowToUse/MeCab/0.996]])

*Install&Setup [#wf3d9d56]
:Step.1|
Install Gensim.

 $ pip install numpy
 $ pip install scipy
 $ pip install gensim
 $ pip install cython


*HowToUse [#k5057dff]
:Step.1|
xxx
Prepare the input file.

 $ mecab -Owakati text.txt -o data.txt


:Step.2|
Create sample code as below.

 from gensim.models import word2vec
 data = word2vec.Text8Corpus('data.txt')
 model = word2vec.Word2Vec(data, size=200)
 out = model.most_similar(positive=[u'人間'])
 for x in out:
  print (x[0],x[1])

:Step.3|
Execute the script.

 $ python <script name>

In case you encounter the error as below, you need to install bg2 and recompile python.

 ImportError: No module named _bz2

Install bz2

 $ sudo yum install libbz2-devel
 $ CFLAGS="-fPIC" pyenv install <version> 

*Author [#sf97f8eb]
S.Yatsuzuka


#back(back,center,0)