mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Prevent strings from being lost during from_disk and from_bytes
This commit is contained in:
parent
41c2218c53
commit
aefef6fd28
|
@ -215,7 +215,10 @@ cdef class StringStore:
|
||||||
path = util.ensure_path(path)
|
path = util.ensure_path(path)
|
||||||
with path.open('r') as file_:
|
with path.open('r') as file_:
|
||||||
strings = ujson.load(file_)
|
strings = ujson.load(file_)
|
||||||
|
prev = list(self)
|
||||||
self._reset_and_load(strings)
|
self._reset_and_load(strings)
|
||||||
|
for word in prev:
|
||||||
|
self.add(word)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def to_bytes(self, **exclude):
|
def to_bytes(self, **exclude):
|
||||||
|
@ -234,7 +237,10 @@ cdef class StringStore:
|
||||||
RETURNS (StringStore): The `StringStore` object.
|
RETURNS (StringStore): The `StringStore` object.
|
||||||
"""
|
"""
|
||||||
strings = ujson.loads(bytes_data)
|
strings = ujson.loads(bytes_data)
|
||||||
|
prev = list(self)
|
||||||
self._reset_and_load(strings)
|
self._reset_and_load(strings)
|
||||||
|
for word in prev:
|
||||||
|
self.add(word)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def set_frozen(self, bint is_frozen):
|
def set_frozen(self, bint is_frozen):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user