Merge pull request #738 from danielhers/master

Fix #737: support loading word vectors with " " as a word
This commit is contained in:
Matthew Honnibal 2017-01-13 02:02:52 +11:00 committed by GitHub
commit a6d7147cf0

View File

@ -479,7 +479,7 @@ cdef class Vocab:
cdef double norm = 0.0 cdef double norm = 0.0
for line_num, line in enumerate(file_): for line_num, line in enumerate(file_):
pieces = line.split() pieces = line.split()
word_str = pieces.pop(0) word_str = " " if line.startswith(" ") else pieces.pop(0)
if vec_len == -1: if vec_len == -1:
vec_len = len(pieces) vec_len = len(pieces)
elif vec_len != len(pieces): elif vec_len != len(pieces):