如何在文本文件中使用单词映射向量



>我有一个包含 100 个句子的文本文件,每个单词的 10 维向量存储在另一个文本文件中。我想制作一个新的文本文件,其中将为每个矩阵中句子中的每个单词打印向量。请帮助我。

这是使用Python和Gensim的一种方法。

from gensim.models import word2vec
# Change this to your own path.
pathToBinVectors = '/data/GoogleNews-vectors-negative300.bin'
model1 = word2vec.Word2Vec.load_word2vec_format(pathToBinVectors, binary=True)
print model1['resume'] -> This will print a vector of the word "resume".

来源:https://bitbucket.org/yunazzang/aiwiththebest_byor

最新更新