mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 02:16:32 +03:00
db55577c45
* Remove unicode declarations * Remove Python 3.5 and 2.7 from CI * Don't require pathlib * Replace compat helpers * Remove OrderedDict * Use f-strings * Set Cython compiler language level * Fix typo * Re-add OrderedDict for Table * Update setup.cfg * Revert CONTRIBUTING.md * Revert lookups.md * Revert top-level.md * Small adjustments and docs [ci skip]
20 lines
656 B
Python
20 lines
656 B
Python
from spacy.matcher import PhraseMatcher
|
|
from spacy.tokens import Doc
|
|
|
|
|
|
def test_issue3972(en_vocab):
|
|
"""Test that the PhraseMatcher returns duplicates for duplicate match IDs.
|
|
"""
|
|
matcher = PhraseMatcher(en_vocab)
|
|
matcher.add("A", [Doc(en_vocab, words=["New", "York"])])
|
|
matcher.add("B", [Doc(en_vocab, words=["New", "York"])])
|
|
doc = Doc(en_vocab, words=["I", "live", "in", "New", "York"])
|
|
matches = matcher(doc)
|
|
|
|
assert len(matches) == 2
|
|
|
|
# We should have a match for each of the two rules
|
|
found_ids = [en_vocab.strings[ent_id] for (ent_id, _, _) in matches]
|
|
assert "A" in found_ids
|
|
assert "B" in found_ids
|