From 5bf2fd1f788ccb6e9691b6d137edfd65120ee4ef Mon Sep 17 00:00:00 2001 From: Wolfgang Seeker Date: Tue, 3 May 2016 17:19:05 +0200 Subject: [PATCH] make the code less cryptic --- spacy/syntax/iterators.pyx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spacy/syntax/iterators.pyx b/spacy/syntax/iterators.pyx index 395f772ce..a02dce0b7 100644 --- a/spacy/syntax/iterators.pyx +++ b/spacy/syntax/iterators.pyx @@ -32,9 +32,10 @@ def german_noun_chunks(doc): np_deps = set(doc.vocab.strings[label] for label in labels) close_app = doc.vocab.strings['nk'] - i = 0 - while i < len(doc): - word = doc[i] + rbracket = 0 + for i, word in enumerate(doc): + if i < rbracket: + continue if word.pos == NOUN and word.dep in np_deps: rbracket = word.i+1 # try to extend the span to the right @@ -42,9 +43,6 @@ def german_noun_chunks(doc): for rdep in doc[word.i].rights: if rdep.pos == NOUN and rdep.dep == close_app: rbracket = rdep.i+1 - yield word.left_edge.i, rbracket, np_label - i = rbracket - continue - i += 1 + yield word.left_edge.i, rbracket, np_label CHUNKERS = {'en': english_noun_chunks, 'de': german_noun_chunks}