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

Strange Matcher behavior with * quantifier and two rules #2005

Closed
litemotif opened this issue Feb 20, 2018 · 2 comments
Closed

Strange Matcher behavior with * quantifier and two rules #2005

litemotif opened this issue Feb 20, 2018 · 2 comments
Labels
bug Bugs and behaviour differing from documentation

Comments

@litemotif
Copy link

I'm not sure why these two rules are resulting in a match on the given text. Is this a bug or am I doing something wrong?

nlp = spacy.load('en')
doc = nlp("I took out the trash.")
matcher = Matcher(nlp.vocab)
matcher.add("rule1", None, [
	{'TAG': 'VBD'},
	{'LOWER': 'the'},
	{'POS': 'NOUN'}
])
matcher.add("rule2", None, [
	{'TAG': 'VBD'},
	{'IS_ALPHA': True, 'OP': '*'},
	{'LOWER': 'any'},
	{'LOWER': 'words'}
])
matches = matcher(doc)
for (match_id, start, end) in matches:
	span = doc[start:end]
	
	label = doc.vocab.strings[match_id]
	
	print(label)
	print(str(span))

The result is a match on rule 1:

rule1
took out the trash

But rule 1 shouldn't allow the word "out." Removing either rule results in no matches.

Your Environment

  • Operating System: macOS 10.13.3
  • Python Version Used: 3.6.4
  • spaCy Version Used: 2.0.8
@ines ines added the bug Bugs and behaviour differing from documentation label Feb 21, 2018
@ines
Copy link
Member

ines commented Feb 21, 2018

Thanks for your report – this issue has since been fixed on the feature/better-faster-matcher branch. It will be included in the upcoming v2.1.0, together with various other improvements and bug fixes to the matcher. For more details on this, check out the Matcher master issue in #1971.

(Closing this and merging with #1971 to keep things in one place!)

@ines ines closed this as completed Feb 21, 2018
@lock
Copy link

lock bot commented May 7, 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 7, 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