2017-01-10 21:24:10 +03:00
|
|
|
# coding: utf-8
|
2016-10-27 19:01:34 +03:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-01-13 00:00:37 +03:00
|
|
|
from ...matcher import Matcher
|
2016-10-27 19:01:34 +03:00
|
|
|
|
2017-01-10 21:24:10 +03:00
|
|
|
import pytest
|
|
|
|
|
2016-10-27 19:01:34 +03:00
|
|
|
|
2017-05-29 23:14:31 +03:00
|
|
|
@pytest.mark.models('en')
|
2017-01-13 00:00:37 +03:00
|
|
|
def test_issue429(EN):
|
2016-10-27 19:01:34 +03:00
|
|
|
def merge_phrases(matcher, doc, i, matches):
|
2017-09-06 20:13:51 +03:00
|
|
|
if i != len(matches) - 1:
|
|
|
|
return None
|
|
|
|
spans = [(ent_id, ent_id, doc[start:end]) for ent_id, start, end in matches]
|
|
|
|
for ent_id, label, span in spans:
|
|
|
|
span.merge(
|
|
|
|
tag=('NNP' if label else span.root.tag_),
|
|
|
|
lemma=span.text,
|
|
|
|
label='PERSON')
|
2017-01-13 00:00:37 +03:00
|
|
|
|
|
|
|
doc = EN('a')
|
|
|
|
matcher = Matcher(EN.vocab)
|
2017-05-23 12:36:02 +03:00
|
|
|
matcher.add('TEST', merge_phrases, [{'ORTH': 'a'}])
|
2017-05-23 11:06:53 +03:00
|
|
|
doc = EN.make_doc('a b c')
|
2017-01-13 00:00:37 +03:00
|
|
|
EN.tagger(doc)
|
|
|
|
matcher(doc)
|
|
|
|
EN.entity(doc)
|