mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 05:37:03 +03:00
Fix #605: Acceptor now rejects matches as expected.
This commit is contained in:
parent
cf6caa3d92
commit
5cd3acb265
|
@ -382,11 +382,12 @@ cdef class Matcher:
|
||||||
ent_id = state.second[1].attrs[0].value
|
ent_id = state.second[1].attrs[0].value
|
||||||
label = state.second[1].attrs[1].value
|
label = state.second[1].attrs[1].value
|
||||||
acceptor = self._acceptors.get(ent_id)
|
acceptor = self._acceptors.get(ent_id)
|
||||||
if acceptor is not None:
|
if acceptor is None:
|
||||||
|
matches.append((ent_id, label, start, end))
|
||||||
|
else:
|
||||||
match = acceptor(doc, ent_id, label, start, end)
|
match = acceptor(doc, ent_id, label, start, end)
|
||||||
if match:
|
if match:
|
||||||
ent_id, label, start, end = match
|
matches.append(match)
|
||||||
matches.append((ent_id, label, start, end))
|
|
||||||
partials.resize(q)
|
partials.resize(q)
|
||||||
# Check whether we open any new patterns on this token
|
# Check whether we open any new patterns on this token
|
||||||
for pattern in self.patterns:
|
for pattern in self.patterns:
|
||||||
|
@ -411,8 +412,13 @@ cdef class Matcher:
|
||||||
end = token_i+1
|
end = token_i+1
|
||||||
ent_id = pattern[1].attrs[0].value
|
ent_id = pattern[1].attrs[0].value
|
||||||
label = pattern[1].attrs[1].value
|
label = pattern[1].attrs[1].value
|
||||||
if acceptor is None or acceptor(doc, ent_id, label, start, end):
|
acceptor = self._acceptors.get(ent_id)
|
||||||
|
if acceptor is None:
|
||||||
matches.append((ent_id, label, start, end))
|
matches.append((ent_id, label, start, end))
|
||||||
|
else:
|
||||||
|
match = acceptor(doc, ent_id, label, start, end)
|
||||||
|
if match:
|
||||||
|
matches.append(match)
|
||||||
for i, (ent_id, label, start, end) in enumerate(matches):
|
for i, (ent_id, label, start, end) in enumerate(matches):
|
||||||
on_match = self._callbacks.get(ent_id)
|
on_match = self._callbacks.get(ent_id)
|
||||||
if on_match is not None:
|
if on_match is not None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user