From 1af9510ceb6b08cfdcfbf26df6896f26709fac0d Mon Sep 17 00:00:00 2001 From: shademe Date: Fri, 19 Aug 2022 14:43:39 +0200 Subject: [PATCH] `Morphology`: Use `StringStore.items()` to enumerate features when pickling --- spacy/morphology.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spacy/morphology.pyx b/spacy/morphology.pyx index 2c3be7b46..6068b7f61 100644 --- a/spacy/morphology.pyx +++ b/spacy/morphology.pyx @@ -7,6 +7,7 @@ from libcpp.memory cimport shared_ptr from .errors import Warnings from . import symbols +from .strings import get_string_id cdef class Morphology: @@ -27,7 +28,7 @@ cdef class Morphology: self.strings = strings def __reduce__(self): - tags = set([self.get(self.strings[s]) for s in self.strings]) + tags = set([self.get(key) for key, _ in self.strings.items()]) tags -= set([""]) return (unpickle_morphology, (self.strings, sorted(tags)), None, None) @@ -99,7 +100,7 @@ cdef class Morphology: if features == "": features = self.EMPTY_MORPH - tag_hash = self.strings[features] + tag_hash = get_string_id(features) tag = self._lookup_tag(tag_hash) if tag: return deref(tag).key