spaCy/spacy/tests/regression/test_issue605.py

22 lines
586 B
Python
Raw Normal View History

2017-01-10 21:24:10 +03:00
# coding: utf-8
from __future__ import unicode_literals
from ...attrs import ORTH
2016-11-06 12:42:32 +03:00
from ...matcher import Matcher
from ..util import get_doc
2016-11-06 12:42:32 +03:00
def test_issue605(en_vocab):
def return_false(doc, ent_id, label, start, end):
return False
2016-11-06 12:42:32 +03:00
words = ["The", "golf", "club", "is", "broken"]
pattern = [{ORTH: "golf"}, {ORTH: "club"}]
label = "Sport_Equipment"
doc = get_doc(en_vocab, words)
2016-11-06 12:42:32 +03:00
matcher = Matcher(doc.vocab)
matcher.add_entity(label, acceptor=return_false)
matcher.add_pattern(label, pattern)
2016-11-06 12:42:32 +03:00
match = matcher(doc)
assert match == []