2017-01-10 21:24:10 +03:00
|
|
|
# coding: utf-8
|
2016-11-06 13:21:36 +03:00
|
|
|
from __future__ import unicode_literals
|
2017-01-10 21:24:10 +03:00
|
|
|
|
2017-01-13 00:00:37 +03:00
|
|
|
from ...attrs import ORTH, IS_ALPHA, LIKE_NUM
|
2016-11-06 13:21:36 +03:00
|
|
|
from ...matcher import Matcher
|
2017-01-13 00:00:37 +03:00
|
|
|
from ..util import get_doc
|
2016-11-06 13:21:36 +03:00
|
|
|
|
2017-01-10 21:24:10 +03:00
|
|
|
|
2017-01-13 00:00:37 +03:00
|
|
|
def test_issue590(en_vocab):
|
|
|
|
"""Test overlapping matches"""
|
|
|
|
doc = get_doc(en_vocab, ['n', '=', '1', ';', 'a', ':', '5', '%'])
|
2017-01-10 21:24:10 +03:00
|
|
|
|
2017-01-13 00:00:37 +03:00
|
|
|
matcher = Matcher(en_vocab)
|
|
|
|
matcher.add_entity("ab", acceptor=None, on_match=None)
|
|
|
|
matcher.add_pattern('ab', [{IS_ALPHA: True}, {ORTH: ':'},
|
|
|
|
{LIKE_NUM: True}, {ORTH: '%'}],
|
|
|
|
label='a')
|
|
|
|
matcher.add_pattern('ab', [{IS_ALPHA: True}, {ORTH: '='},
|
|
|
|
{LIKE_NUM: True}],
|
|
|
|
label='b')
|
2016-11-06 13:21:36 +03:00
|
|
|
matches = matcher(doc)
|
|
|
|
assert len(matches) == 2
|