mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 10:26:35 +03:00
addeb34bc4
Even if the issue number is already in the file, I still decorated them just to follow the convention found in test_issue8168.py
31 lines
872 B
Python
31 lines
872 B
Python
from spacy.util import filter_spans
|
|
from pydantic import ValidationError
|
|
from spacy.schemas import TokenPattern, TokenPatternSchema
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.issue(6207)
|
|
def test_issue6207(en_tokenizer):
|
|
doc = en_tokenizer("zero one two three four five six")
|
|
|
|
# Make spans
|
|
s1 = doc[:4]
|
|
s2 = doc[3:6] # overlaps with s1
|
|
s3 = doc[5:7] # overlaps with s2, not s1
|
|
|
|
result = filter_spans((s1, s2, s3))
|
|
assert s1 in result
|
|
assert s2 not in result
|
|
assert s3 in result
|
|
|
|
|
|
@pytest.mark.issue(6258)
|
|
def test_issue6258():
|
|
"""Test that the non-empty constraint pattern field is respected"""
|
|
# These one is valid
|
|
TokenPatternSchema(pattern=[TokenPattern()])
|
|
# But an empty pattern list should fail to validate
|
|
# based on the schema's constraint
|
|
with pytest.raises(ValidationError):
|
|
TokenPatternSchema(pattern=[])
|