Hello World from OSS Silicon Valley


HowToUse/Gensim/0.13

_ Prerequisite

  • Python installation (You can refer HowToUse/Python/3.5)
  • MeCab installation (You can refer HowToUse/MeCab/0.996)

_ Install&Setup

Step.1
Install Gensim.
$ pip install numpy
$ pip install scipy
$ pip install gensim
$ pip install cython

_ HowToUse

Step.1
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

S.Yatsuzuka

[ back ]
Last-modified: 2016-12-13 (Tue) 07:22:53 (2691d)