Mapping 如何用文本文件中的单词映射向量

Mapping 如何用文本文件中的单词映射向量,mapping,word2vec,Mapping,Word2vec,我有一个包含100个句子的文本文件,每个单词的10维向量存储在另一个文本文件中。我想制作一个新的文本文件,其中每个矩阵中句子中的每个单词都将打印向量。请帮帮我。这里有一种使用Python和Gensim的方法 from gensim.models import word2vec # Change this to your own path. pathToBinVectors = '/data/GoogleNews-vectors-negative300.bin' model1 = word2v

我有一个包含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".

来源:

这里有一种使用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".
资料来源: