2022-08-22 13:04:30 +03:00
|
|
|
import pytest
|
2021-06-11 11:19:22 +03:00
|
|
|
|
2023-06-26 12:41:03 +03:00
|
|
|
from spacy.tokens import Doc
|
2021-06-11 11:19:22 +03:00
|
|
|
|
2022-08-22 13:04:30 +03:00
|
|
|
pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning")
|
|
|
|
|
|
|
|
|
2021-06-11 11:19:22 +03:00
|
|
|
def test_uk_lemmatizer(uk_lemmatizer):
|
|
|
|
"""Check that the default uk lemmatizer runs."""
|
|
|
|
doc = Doc(uk_lemmatizer.vocab, words=["a", "b", "c"])
|
2022-11-25 13:12:46 +03:00
|
|
|
assert uk_lemmatizer.mode == "pymorphy3"
|
2021-06-11 11:19:22 +03:00
|
|
|
uk_lemmatizer(doc)
|
2022-10-12 13:18:39 +03:00
|
|
|
assert [token.lemma for token in doc]
|
|
|
|
|
|
|
|
|
2022-11-25 13:12:46 +03:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"word,lemma",
|
|
|
|
(
|
|
|
|
("якийсь", "якийсь"),
|
|
|
|
("розповідають", "розповідати"),
|
|
|
|
("розповіси", "розповісти"),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
def test_uk_lookup_lemmatizer(uk_lookup_lemmatizer, word, lemma):
|
|
|
|
assert uk_lookup_lemmatizer.mode == "pymorphy3_lookup"
|
|
|
|
doc = Doc(uk_lookup_lemmatizer.vocab, words=[word])
|
|
|
|
assert uk_lookup_lemmatizer(doc)[0].lemma_ == lemma
|