mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Fix load fail for missing vectors
This commit is contained in:
parent
a3c51a0355
commit
b8e1603cc4
|
@ -32,8 +32,6 @@ cdef class Vectors:
|
||||||
self.data = data
|
self.data = data
|
||||||
self.key2row = {}
|
self.key2row = {}
|
||||||
self.keys = np.ndarray((self.data.shape[0],), dtype='uint64')
|
self.keys = np.ndarray((self.data.shape[0],), dtype='uint64')
|
||||||
for string in strings:
|
|
||||||
self.add(string)
|
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
return (Vectors, (self.strings, self.data))
|
return (Vectors, (self.strings, self.data))
|
||||||
|
@ -101,12 +99,14 @@ cdef class Vectors:
|
||||||
|
|
||||||
def from_disk(self, path, **exclude):
|
def from_disk(self, path, **exclude):
|
||||||
def load_keys(path):
|
def load_keys(path):
|
||||||
|
if path.exists():
|
||||||
self.keys = numpy.load(path)
|
self.keys = numpy.load(path)
|
||||||
for i, key in enumerate(self.keys):
|
for i, key in enumerate(self.keys):
|
||||||
self.keys[i] = key
|
self.keys[i] = key
|
||||||
self.key2row[key] = i
|
self.key2row[key] = i
|
||||||
|
|
||||||
def load_vectors(path):
|
def load_vectors(path):
|
||||||
|
if path.exists():
|
||||||
self.data = numpy.load(path)
|
self.data = numpy.load(path)
|
||||||
|
|
||||||
serializers = OrderedDict((
|
serializers = OrderedDict((
|
||||||
|
|
Loading…
Reference in New Issue
Block a user