1.首先在网站上面下载gensim,我是在11服务器上面下载的
2.使用winpython打开
3.在command windows 下使用pip install gensim这句话进行,原先使用这句话pip install -U gensim进行安装发生了各种纠结的错误
4。由于语料库太大了,就是用了师兄提炼好的部分wiki.en.txt进行训练
5.在train_word2vec_model中将
"""if len(sys.argv) < 4:
print globals()['__doc__'] % locals()
sys.exit(1)
"""
修改为
inp = "wiki.en.text "
outp1 = "wiki.en.text.model"
outp2 = "wiki.en.text.vector"
后直接进行运行,(运行直接点击F5进行),
或者是可以不用修改代码直接使用run configure来进行(在run configure中command line option 中填写那3个参数,确定后直接点击F5进行运行)
这里的训练过程是很浪费时间的
处理43M的小的语料库花费了1个小时10分钟
387M的小语料库花费了10个小时
得到的一些结果举例
baghdad(伊拉克的首都)
england | london |
baghdad |
england-london=x-baghdad
model.similarity('woman', 'woman')
0.99999999999999989