【发布时间】:2017-03-23 13:05:13
【问题描述】:
看完this article,我开始训练自己的模型。问题是作者没有说清楚Word2Vec中的sentences应该是什么样子。
我从维基百科页面下载文本,因为它写的是文章,我从中列出了句子:
sentences = [word for word in wikipage.content.split('.')]
因此,例如,sentences[0] 看起来像:
'Machine learning is the subfield of computer science that gives computers the ability to learn without being explicitly programmed'
然后我尝试用这个列表训练一个模型:
model = Word2Vec(sentences, min_count=2, size=50, window=10, workers=4)
但是模型的字典是由字母组成的!比如model.wv.vocab.keys()的输出是:
dict_keys([',', 'q', 'D', 'B', 'p', 't', 'o', '(', ')', '0', 'V', ':', 'j', 's', 'R', '{', 'g', '-', 'y', 'c', '9', 'I', '}', '1', 'M', ';', '`', '\n', 'i', 'r', 'a', 'm', '–', 'v', 'N', 'h', '/', 'P', 'F', '8', '"', '’', 'W', 'T', 'u', 'U', '?', ' ', 'n', '2', '=', 'w', 'C', 'O', '6', '&', 'd', '4', 'S', 'J', 'E', 'b', 'L', '$', 'l', 'e', 'H', '≈', 'f', 'A', "'", 'x', '\\', 'K', 'G', '3', '%', 'k', 'z'])
我做错了什么?提前致谢!
【问题讨论】:
标签: python nlp gensim word2vec