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