mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 10:26:35 +03:00
61b04a70d5
* Add regression test * Run PhraseMatcher on Spans * Add test for PhraseMatcher on Spans and Docs * Add SCA * Add test with 3 matches in Doc, 1 match in Span * Update docs * Use doc.length for find_matches in tokenizer Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com>
16 lines
512 B
Python
16 lines
512 B
Python
from spacy.tokens import Doc
|
|
from spacy.matcher import PhraseMatcher
|
|
|
|
|
|
def test_span_in_phrasematcher(en_vocab):
|
|
"""Ensure that PhraseMatcher accepts Span as input"""
|
|
doc = Doc(en_vocab,
|
|
words=["I", "like", "Spans", "and", "Docs", "in", "my", "input", ",", "and", "nothing", "else", "."])
|
|
span = doc[:8]
|
|
pattern = Doc(en_vocab, words=["Spans", "and", "Docs"])
|
|
matcher = PhraseMatcher(en_vocab)
|
|
matcher.add("SPACY", [pattern])
|
|
matches = matcher(span)
|
|
assert matches
|
|
|