diff --git a/spacy/syntax/ner.pyx b/spacy/syntax/ner.pyx index 62d4dc0e2..6e7507899 100644 --- a/spacy/syntax/ner.pyx +++ b/spacy/syntax/ner.pyx @@ -76,7 +76,7 @@ cdef class BiluoPushDown(TransitionSystem): elif move == 'MISSING': return 'M' else: - return MOVE_NAMES[move] + '-' + self.strings[label] + return MOVE_NAMES[move] + '-' + self.strings.decode_int(label) cdef int preprocess_gold(self, GoldParse gold) except -1: for i in range(gold.length): @@ -101,7 +101,7 @@ cdef class BiluoPushDown(TransitionSystem): label = 0 elif '-' in name: move_str, label_str = name.split('-', 1) - label = self.strings[label_str] + label = self.strings.intern(label_str) else: move_str = name label = 0 diff --git a/spacy/syntax/transition_system.pyx b/spacy/syntax/transition_system.pyx index 9e624bd58..402e1c2f1 100644 --- a/spacy/syntax/transition_system.pyx +++ b/spacy/syntax/transition_system.pyx @@ -27,7 +27,7 @@ cdef class TransitionSystem: for label_str in sorted(label_strs): self.add_action(int(action), label_str) - self.root_label = self.strings['ROOT'] + self.root_label = self.strings.intern('ROOT') self.freqs = {} if _freqs is None else _freqs for attr in (TAG, HEAD, DEP, ENT_TYPE, ENT_IOB): self.freqs[attr] = defaultdict(int) @@ -41,7 +41,7 @@ cdef class TransitionSystem: labels_by_action = {} cdef Transition t for trans in self.c[:self.n_moves]: - label_str = self.strings[trans.label] + label_str = self.strings.decode_int(trans.label) labels_by_action.setdefault(trans.move, []).append(label_str) return (self.__class__, (self.strings, labels_by_action, self.freqs), @@ -86,7 +86,7 @@ cdef class TransitionSystem: def add_action(self, int action, label): if not isinstance(label, int): - label = self.strings[label] + label = self.strings.intern(label) # Check we're not creating a move we already have, so that this is # idempotent for trans in self.c[:self.n_moves]: