From aefef6fd282a93e39f949248345d39432bbfe4d1 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 19 Aug 2017 22:42:17 +0200 Subject: [PATCH] Prevent strings from being lost during from_disk and from_bytes --- spacy/strings.pyx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spacy/strings.pyx b/spacy/strings.pyx index 2e42b9667..6f676c79a 100644 --- a/spacy/strings.pyx +++ b/spacy/strings.pyx @@ -215,7 +215,10 @@ cdef class StringStore: path = util.ensure_path(path) with path.open('r') as file_: strings = ujson.load(file_) + prev = list(self) self._reset_and_load(strings) + for word in prev: + self.add(word) return self def to_bytes(self, **exclude): @@ -234,7 +237,10 @@ cdef class StringStore: RETURNS (StringStore): The `StringStore` object. """ strings = ujson.loads(bytes_data) + prev = list(self) self._reset_and_load(strings) + for word in prev: + self.add(word) return self def set_frozen(self, bint is_frozen):