From e28f90b672379b65db409bda0650d2a65bc5b5fe Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 4 Jun 2017 15:51:50 -0500 Subject: [PATCH] Fix syntax iterators --- spacy/lang/de/syntax_iterators.py | 6 +++--- spacy/lang/en/__init__.py | 2 +- spacy/lang/en/syntax_iterators.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spacy/lang/de/syntax_iterators.py b/spacy/lang/de/syntax_iterators.py index ab750989e..e5dcbf1ff 100644 --- a/spacy/lang/de/syntax_iterators.py +++ b/spacy/lang/de/syntax_iterators.py @@ -15,9 +15,9 @@ def noun_chunks(obj): # and not just "eine Tasse", same for "das Thema Familie". labels = ['sb', 'oa', 'da', 'nk', 'mo', 'ag', 'ROOT', 'root', 'cj', 'pd', 'og', 'app'] doc = obj.doc # Ensure works on both Doc and Span. - np_label = doc.vocab.strings['NP'] - np_deps = set(doc.vocab.strings[label] for label in labels) - close_app = doc.vocab.strings['nk'] + np_label = doc.vocab.strings.add('NP') + np_deps = set(doc.vocab.strings.add(label) for label in labels) + close_app = doc.vocab.strings.add('nk') rbracket = 0 for i, word in enumerate(obj): diff --git a/spacy/lang/en/__init__.py b/spacy/lang/en/__init__.py index 7775084c4..ec14fecd0 100644 --- a/spacy/lang/en/__init__.py +++ b/spacy/lang/en/__init__.py @@ -31,7 +31,7 @@ class EnglishDefaults(Language.Defaults): lemma_rules = dict(LEMMA_RULES) lemma_index = dict(LEMMA_INDEX) lemma_exc = dict(LEMMA_EXC) - sytax_iterators = dict(SYNTAX_ITERATORS) + syntax_iterators = dict(SYNTAX_ITERATORS) class English(Language): diff --git a/spacy/lang/en/syntax_iterators.py b/spacy/lang/en/syntax_iterators.py index dec240669..4240bd657 100644 --- a/spacy/lang/en/syntax_iterators.py +++ b/spacy/lang/en/syntax_iterators.py @@ -11,9 +11,9 @@ def noun_chunks(obj): labels = ['nsubj', 'dobj', 'nsubjpass', 'pcomp', 'pobj', 'attr', 'ROOT'] doc = obj.doc # Ensure works on both Doc and Span. - np_deps = [doc.vocab.strings[label] for label in labels] - conj = doc.vocab.strings['conj'] - np_label = doc.vocab.strings['NP'] + np_deps = [doc.vocab.strings.add(label) for label in labels] + conj = doc.vocab.strings.add('conj') + np_label = doc.vocab.strings.add('NP') seen = set() for i, word in enumerate(obj): if word.pos not in (NOUN, PROPN, PRON):