mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Add test for 850: Matcher fails on zero-or-more.
This commit is contained in:
parent
3a5f726208
commit
6d67213b80
29
spacy/tests/regression/test_issue850.py
Normal file
29
spacy/tests/regression/test_issue850.py
Normal 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
|
Loading…
Reference in New Issue
Block a user