From 62ff128888bce33cf87e083a921ddac65a2f1879 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 16 Jul 2019 14:00:00 +0200 Subject: [PATCH] Add regression test for #3951 --- spacy/tests/regression/test_issue3951.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spacy/tests/regression/test_issue3951.py diff --git a/spacy/tests/regression/test_issue3951.py b/spacy/tests/regression/test_issue3951.py new file mode 100644 index 00000000000..f9912c494ec --- /dev/null +++ b/spacy/tests/regression/test_issue3951.py @@ -0,0 +1,22 @@ +# coding: utf8 +from __future__ import unicode_literals + +import pytest +from spacy.matcher import Matcher +from spacy.tokens import Doc + + +@pytest.mark.xfail +def test_issue3951(en_vocab): + """Test that combinations of optional rules are matched correctly.""" + matcher = Matcher(en_vocab) + pattern = [ + {"LOWER": "hello"}, + {"LOWER": "this", "OP": "?"}, + {"OP": "?"}, + {"LOWER": "world"}, + ] + matcher.add("TEST", None, pattern) + doc = Doc(en_vocab, words=["Hello", "my", "new", "world"]) + matches = matcher(doc) + assert len(matches) == 0