Add test for 850: Matcher fails on zero-or-more.

This commit is contained in:
Matthew Honnibal 2017-03-07 15:55:28 +01:00
parent 3a5f726208
commit 6d67213b80
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
'''
Test Matcher matches with '*' operator and Boolean flag
'''
from __future__ import unicode_literals
import pytest
from ...matcher import Matcher
from ...vocab import Vocab
from ...attrs import LOWER
from ...tokens import Doc
@pytest.mark.xfail
def test_issue850():
matcher = Matcher(Vocab())
IS_ANY_TOKEN = matcher.vocab.add_flag(lambda x: True)
matcher.add_pattern(
"FarAway",
[
{LOWER: "bob"},
{'OP': '*', IS_ANY_TOKEN: True},
{LOWER: 'frank'}
])
doc = Doc(matcher.vocab, words=['bob', 'and', 'and', 'cat', 'frank'])
match = matcher(doc)
assert len(match) == 1
start, end, label, ent_id = match
assert start == 0
assert end == 4