mirror of https://github.com/explosion/spaCy.git
Fix Vectors pickling
This commit is contained in:
parent
3d6487c734
commit
9cc202d670
|
@ -15,11 +15,8 @@ from .compat import basestring_, path2str
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
def unpickle_vectors(keys_and_rows, data):
|
def unpickle_vectors(bytes_data):
|
||||||
vectors = Vectors(data=data)
|
return Vectors().from_bytes(bytes_data)
|
||||||
for key, row in keys_and_rows:
|
|
||||||
vectors.add(key, row=row)
|
|
||||||
return vectors
|
|
||||||
|
|
||||||
|
|
||||||
cdef class Vectors:
|
cdef class Vectors:
|
||||||
|
@ -86,8 +83,7 @@ cdef class Vectors:
|
||||||
return len(self.key2row)
|
return len(self.key2row)
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
keys_and_rows = tuple(self.key2row.items())
|
return (unpickle_vectors, (self.to_bytes(),))
|
||||||
return (unpickle_vectors, (keys_and_rows, self.data))
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"""Get a vector by key. If the key is not found, a KeyError is raised.
|
"""Get a vector by key. If the key is not found, a KeyError is raised.
|
||||||
|
|
Loading…
Reference in New Issue