def main():
args = docopt("""
Usage:
text2numpy.py <path>
""")
path = args['<path>']
matrix = read_vectors(path)
iw = sorted(matrix.keys())
new_matrix = np.zeros(shape=(len(iw), len(matrix[iw[0]])), dtype=np.float32)
for i, word in enumerate(iw):
if word in matrix:
new_matrix[i, :] = matrix[word]
np.save(path + '.npy', new_matrix)
save_vocabulary(path + '.vocab', iw)
评论列表
文章目录