def glove2dict(src_filename):
"""GloVe Reader.
Parameters
----------
src_filename : str
Full path to the GloVe file to be processed.
Returns
-------
dict
Mapping words to their GloVe vectors.
"""
reader = csv.reader(open(src_filename), delimiter=' ',
quoting=csv.QUOTE_NONE)
return {line[0]: np.array(list(map(float, line[1:]))) for line in reader}
评论列表
文章目录