From e6acd3bbf2b938a8b28549e97757083d6aaa5219 Mon Sep 17 00:00:00 2001 From: ines Date: Tue, 23 May 2017 11:36:02 +0200 Subject: [PATCH] Fix matcher tests and matcher docs --- spacy/tests/regression/test_issue429.py | 2 +- website/docs/api/matcher.jade | 2 +- website/docs/usage/rule-based-matching.jade | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spacy/tests/regression/test_issue429.py b/spacy/tests/regression/test_issue429.py index 2782a0fb2..0a9273f4e 100644 --- a/spacy/tests/regression/test_issue429.py +++ b/spacy/tests/regression/test_issue429.py @@ -17,7 +17,7 @@ def test_issue429(EN): doc = EN('a') matcher = Matcher(EN.vocab) - matcher.add('TEST', on_match=merge_phrases, [{'ORTH': 'a'}]) + matcher.add('TEST', merge_phrases, [{'ORTH': 'a'}]) doc = EN.tokenizer('a b c') EN.tagger(doc) matcher(doc) diff --git a/website/docs/api/matcher.jade b/website/docs/api/matcher.jade index 5e15f852c..5d0e8af95 100644 --- a/website/docs/api/matcher.jade +++ b/website/docs/api/matcher.jade @@ -52,7 +52,7 @@ p Find all token sequences matching the supplied patterns on the #[code Doc]. matcher = Matcher(nlp.vocab) pattern = [{'LOWER': "hello"}, {'LOWER': "world"}] - matcher.add("HelloWorld", on_match=None, pattern) + matcher.add("HelloWorld", None, pattern) doc = nlp(u'hello world!') matches = matcher(doc) diff --git a/website/docs/usage/rule-based-matching.jade b/website/docs/usage/rule-based-matching.jade index e476d7c07..a54b70b89 100644 --- a/website/docs/usage/rule-based-matching.jade +++ b/website/docs/usage/rule-based-matching.jade @@ -47,8 +47,8 @@ p nlp = spacy.load('en') matcher = Matcher(nlp.vocab) # add match ID "HelloWorld" with no callback and one pattern - matcher.add('HelloWorld', on_match=None, - [{'LOWER': 'hello'}, {'IS_PUNCT': True}, {'LOWER': 'world'}]) + pattern = [{'LOWER': 'hello'}, {'IS_PUNCT': True}, {'LOWER': 'world'}] + matcher.add('HelloWorld', None, pattern) doc = nlp(u'Hello, world! Hello world!') matches = matcher(doc) @@ -61,7 +61,7 @@ p | without punctuation between "hello" and "world": +code. - matcher.add('HelloWorld', on_match=None, + matcher.add('HelloWorld', None, [{'LOWER': 'hello'}, {'IS_PUNCT': True}, {'LOWER': 'world'}], [{'LOWER': 'hello'}, {'LOWER': 'world'}]) @@ -104,7 +104,7 @@ p match_id, start, end = matches[i] doc.ents += ((EVENT, start, end),) - matcher.add('GoogleIO', on_match=add_event_ent, + matcher.add('GoogleIO', add_event_ent, [{'ORTH': 'Google'}, {'UPPER': 'I'}, {'ORTH': '/'}, {'UPPER': 'O'}], [{'ORTH': 'Google'}, {'UPPER': 'I'}, {'ORTH': '/'}, {'UPPER': 'O'}, {'IS_DIGIT': True}]) @@ -127,7 +127,7 @@ p span.merge(is_stop=True) # merge (and mark it as a stop word, just in case) span.set_flag(BAD_HTML_FLAG, True) # set BAD_HTML_FLAG - matcher.add('BAD_HTML', on_match=merge_and_flag, + matcher.add('BAD_HTML', merge_and_flag, [{'ORTH': '<'}, {'LOWER': 'br'}, {'ORTH': '>'}], [{'ORTH': '<'}, {'LOWER': 'br/'}, {'ORTH': '>'}])