From b8e1603cc44cf2f1fc0b2f6384e547c95d9d68fa Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 19 Aug 2017 22:07:00 +0200 Subject: [PATCH] Fix load fail for missing vectors --- spacy/vectors.pyx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index ae45f99b3..72e30bd2f 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -32,8 +32,6 @@ cdef class Vectors: self.data = data self.key2row = {} self.keys = np.ndarray((self.data.shape[0],), dtype='uint64') - for string in strings: - self.add(string) def __reduce__(self): return (Vectors, (self.strings, self.data)) @@ -101,13 +99,15 @@ cdef class Vectors: def from_disk(self, path, **exclude): def load_keys(path): - self.keys = numpy.load(path) - for i, key in enumerate(self.keys): - self.keys[i] = key - self.key2row[key] = i + if path.exists(): + self.keys = numpy.load(path) + for i, key in enumerate(self.keys): + self.keys[i] = key + self.key2row[key] = i def load_vectors(path): - self.data = numpy.load(path) + if path.exists(): + self.data = numpy.load(path) serializers = OrderedDict(( ('keys', load_keys),