Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceptor Function Not Rejecting Matches #605

Closed
aikramer2 opened this issue Nov 4, 2016 · 2 comments
Closed

Acceptor Function Not Rejecting Matches #605

aikramer2 opened this issue Nov 4, 2016 · 2 comments
Labels
bug Bugs and behaviour differing from documentation

Comments

@aikramer2
Copy link
Contributor

aikramer2 commented Nov 4, 2016

I'm trying to make use the acceptor function for a matcher, and am getting behavior that I would not expect. My assumption is if an acceptor returns a falsy value (I'm using False), then a match should be rejected. The assertion below fails:

import spacy 
from spacy.attrs import LOWER, ORTH

nlp = spacy.en.English()
text = u"""The golf club is broken"""
doc = nlp(text)

golf_pattern =     [ 
        { ORTH: "golf"},
        { ORTH: "club"}
    ]

def return_false(doc, ent_id, label, start, end):
    return False

matcher = spacy.matcher.Matcher(nlp.vocab)
matcher.add_entity('Sport_Equipment'
                   , acceptor=return_false
                  )
matcher.add_pattern("Sport_Equipment", golf_pattern)
match = matcher(doc)

assert match == []

Inspecting the match, the entity associated with the given ID does indeed have the correct acceptor function registered:

ent_id = match[0][0]
print matcher._acceptors.get(ent_id)

Your Environment

  • Ubuntu
  • Python Version: 2.7
  • Spacy Version: 1.1.2
@honnibal honnibal added the bug Bugs and behaviour differing from documentation label Nov 4, 2016
@honnibal
Copy link
Member

honnibal commented Nov 4, 2016

Definitely a bug, thanks. Will look at this tomorrow.

@lock
Copy link

lock bot commented May 9, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation
Projects
None yet
Development

No branches or pull requests

2 participants