From 8d6954e0e720637b76b4f4f6f768fadadf03bc06 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 27 Feb 2019 10:25:39 +0100 Subject: [PATCH] Fix matcher bug #3328 --- spacy/matcher/matcher.pyx | 5 +++-- spacy/tests/regression/test_issue3328.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/matcher/matcher.pyx b/spacy/matcher/matcher.pyx index 5f17ec867..17b0a4a36 100644 --- a/spacy/matcher/matcher.pyx +++ b/spacy/matcher/matcher.pyx @@ -60,9 +60,10 @@ cdef find_matches(TokenPatternC** patterns, int n, Doc doc, extensions=None, for i in range(doc.length): for j in range(n): states.push_back(PatternStateC(patterns[j], i, 0)) - transition_states(states, matches, &predicate_cache[i], + transition_states(states, matches, predicate_cache, doc[i], extra_attr_values, predicates) extra_attr_values += nr_extra_attr + predicate_cache += len(predicates) # Handle matches that end in 0-width patterns finish_states(matches, states) output = [] @@ -105,7 +106,6 @@ cdef void transition_states(vector[PatternStateC]& states, vector[MatchC]& match if states[i].pattern.nr_py >= 1: update_predicate_cache(cached_py_predicates, states[i].pattern, token, py_predicates) - for i in range(states.size()): action = get_action(states[i], token.c, extra_attrs, cached_py_predicates) if action == REJECT: @@ -127,6 +127,7 @@ cdef void transition_states(vector[PatternStateC]& states, vector[MatchC]& match PatternStateC(pattern=state.pattern+1, start=state.start, length=state.length+1)) states[q].pattern += 1 + if states[q].pattern.nr_py != 0: update_predicate_cache(cached_py_predicates, states[q].pattern, token, py_predicates) diff --git a/spacy/tests/regression/test_issue3328.py b/spacy/tests/regression/test_issue3328.py index fce25ca1c..904b6feab 100644 --- a/spacy/tests/regression/test_issue3328.py +++ b/spacy/tests/regression/test_issue3328.py @@ -6,7 +6,6 @@ from spacy.matcher import Matcher from spacy.tokens import Doc -@pytest.mark.xfail def test_issue3328(en_vocab): doc = Doc(en_vocab, words=["Hello", ",", "how", "are", "you", "doing", "?"]) matcher = Matcher(en_vocab)