From efe7790439798a97d4e1ea1a8476db2fc9642aec Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 6 Nov 2016 11:21:36 +0100 Subject: [PATCH] Test #590: Order dependence in Matcher rules. --- spacy/tests/regression/test_issue590.py | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spacy/tests/regression/test_issue590.py diff --git a/spacy/tests/regression/test_issue590.py b/spacy/tests/regression/test_issue590.py new file mode 100644 index 000000000..a35d5d1a4 --- /dev/null +++ b/spacy/tests/regression/test_issue590.py @@ -0,0 +1,34 @@ +from __future__ import unicode_literals +from ...attrs import * +from ...matcher import Matcher +from ...tokens import Doc +from ...en import English + +def test_overlapping_matches(): + vocab = English.Defaults.create_vocab() + doc = Doc(vocab, words=['n', '=', '1', ';', 'a', ':', '5', '%']) + + matcher = Matcher(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