spaCy/spacy/tests/regression/test_issue590.py

23 lines
766 B
Python
Raw Normal View History

2017-01-10 18:24:10 +00:00
# coding: utf-8
from __future__ import unicode_literals
2017-01-10 18:24:10 +00:00
from ...attrs import ORTH, IS_ALPHA, LIKE_NUM
from ...matcher import Matcher
from ..util import get_doc
2017-01-10 18:24:10 +00:00
def test_issue590(en_vocab):
"""Test overlapping matches"""
doc = get_doc(en_vocab, ['n', '=', '1', ';', 'a', ':', '5', '%'])
2017-01-10 18:24:10 +00: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')
matches = matcher(doc)
assert len(matches) == 2