mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
* Cosmetic change to english noun chunks iterator -- use enumerate instead of range loop
This commit is contained in:
parent
02276cc444
commit
13fad36e49
|
@ -7,8 +7,7 @@ def english_noun_chunks(doc):
|
||||||
np_deps = [doc.vocab.strings[label] for label in labels]
|
np_deps = [doc.vocab.strings[label] for label in labels]
|
||||||
conj = doc.vocab.strings['conj']
|
conj = doc.vocab.strings['conj']
|
||||||
np_label = doc.vocab.strings['NP']
|
np_label = doc.vocab.strings['NP']
|
||||||
for i in range(len(doc)):
|
for i, word in enumerate(doc):
|
||||||
word = doc[i]
|
|
||||||
if word.pos in (NOUN, PROPN, PRON) and word.dep in np_deps:
|
if word.pos in (NOUN, PROPN, PRON) and word.dep in np_deps:
|
||||||
yield word.left_edge.i, word.i+1, np_label
|
yield word.left_edge.i, word.i+1, np_label
|
||||||
elif word.pos == NOUN and word.dep == conj:
|
elif word.pos == NOUN and word.dep == conj:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user