From 9e09b39b9f4bb8f497a011afd635dccccefdfc65 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 30 Sep 2016 20:11:49 +0200 Subject: [PATCH] Revert "Changes to transition systems for new StringStore scheme" This reverts commit 0442e0ab1e4fd08966b0ac2bfd296b55d96ed25f. --- spacy/syntax/ner.pyx | 4 ++-- spacy/syntax/transition_system.pyx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spacy/syntax/ner.pyx b/spacy/syntax/ner.pyx index 6e7507899..62d4dc0e2 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.decode_int(label) + return MOVE_NAMES[move] + '-' + self.strings[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.intern(label_str) + label = self.strings[label_str] else: move_str = name label = 0 diff --git a/spacy/syntax/transition_system.pyx b/spacy/syntax/transition_system.pyx index 402e1c2f1..9e624bd58 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.intern('ROOT') + self.root_label = self.strings['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.decode_int(trans.label) + label_str = self.strings[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.intern(label) + label = self.strings[label] # Check we're not creating a move we already have, so that this is # idempotent for trans in self.c[:self.n_moves]: