From 6d67213b80350fe63e46ea2a18688f4a5a3f0d81 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 7 Mar 2017 15:55:28 +0100 Subject: [PATCH] Add test for 850: Matcher fails on zero-or-more. --- spacy/tests/regression/test_issue850.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spacy/tests/regression/test_issue850.py diff --git a/spacy/tests/regression/test_issue850.py b/spacy/tests/regression/test_issue850.py new file mode 100644 index 000000000..4113ec512 --- /dev/null +++ b/spacy/tests/regression/test_issue850.py @@ -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