读取word2vec训练好的词向量
def load_word2vec_object(self, source_data_path):
source_data = open(source_data_path, 'rb')
source_data_dict = {}
for i, line in enumerate(source_data):
if i == 0 and 'word2vec' in line:
continue
line = line.split(' ')
word = line[0].decode('utf-8')
word_vec_list = [float(x) for x in line[1:]]
source_data_dict[word] = np.array(word_vec_list) # 写入字典
return source_data_dict