mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 18:56:36 +03:00
Fix noun chunks iterator for new stringstore
This commit is contained in:
parent
606879b217
commit
fd9b6722a9
|
@ -12,9 +12,9 @@ def english_noun_chunks(obj):
|
||||||
labels = ['nsubj', 'dobj', 'nsubjpass', 'pcomp', 'pobj',
|
labels = ['nsubj', 'dobj', 'nsubjpass', 'pcomp', 'pobj',
|
||||||
'attr', 'ROOT']
|
'attr', 'ROOT']
|
||||||
doc = obj.doc # Ensure works on both Doc and Span.
|
doc = obj.doc # Ensure works on both Doc and Span.
|
||||||
np_deps = [doc.vocab.strings[label] for label in labels]
|
np_deps = [doc.vocab.strings.add(label) for label in labels]
|
||||||
conj = doc.vocab.strings['conj']
|
conj = doc.vocab.strings.add('conj')
|
||||||
np_label = doc.vocab.strings['NP']
|
np_label = doc.vocab.strings.add('NP')
|
||||||
seen = set()
|
seen = set()
|
||||||
for i, word in enumerate(obj):
|
for i, word in enumerate(obj):
|
||||||
if word.pos not in (NOUN, PROPN, PRON):
|
if word.pos not in (NOUN, PROPN, PRON):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user