spaCy/spacy/tests/regression/test_issue429.py

26 lines
685 B
Python
Raw Normal View History

2017-01-10 21:24:10 +03:00
# coding: utf-8
from __future__ import unicode_literals
from ...matcher import Matcher
2017-01-10 21:24:10 +03:00
import pytest
@pytest.mark.models('en')
def test_issue429(EN):
def merge_phrases(matcher, doc, i, matches):
if i != len(matches) - 1:
return None
2017-05-22 14:54:20 +03:00
spans = [(ent_id, ent_id, doc[start:end]) for ent_id, start, end in matches]
for ent_id, label, span in spans:
span.merge('NNP' if label else span.root.tag_, span.text, EN.vocab.strings[label])
doc = EN('a')
matcher = Matcher(EN.vocab)
2017-05-23 12:36:02 +03:00
matcher.add('TEST', merge_phrases, [{'ORTH': 'a'}])
doc = EN.make_doc('a b c')
2017-06-04 23:53:17 +03:00
EN.tensorizer(doc)
EN.tagger(doc)
matcher(doc)
EN.entity(doc)