from gensim.models import Word2Vec
from gensim.models.word2vec import LineSentence
# 原始的训练语料转化成一个sentence的迭代器,每一次迭代返回的sentence是一个word(utf8格式)的列表
def vctor_word():
# wiki_news = open('wiki.zh.jian.seg.txt', 'r',encoding='utf-8')
wiki_news = open('weibo_content.txt', 'r', encoding='utf-8')
sentences=LineSentence(wiki_news)
model=Word2Vec(sentences,sg=0,size=100,window=5,min_count=5,workers=9)
model.save('zhiwiki_news.word2vec')
vctor_word()
转载于:https://www.cnblogs.com/hapyygril/p/9981774.html