-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathtest_mk.py
37 lines (30 loc) · 1.41 KB
/
test_mk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding: utf-8
from __future__ import unicode_literals
import pytest
@pytest.mark.parametrize("text", ["побрзо", "најбрзо", "подобро", "најдобро"])
def test_mk_lemmatizer_handles_irreg_adverbs(mk_lookup_nlp, text):
for token in mk_lookup_nlp(text):
assert token.lemma_ in ["брзо", "добро"]
@pytest.mark.parametrize(
"string,lemma",
[
("најадекватен", "адекватен"),
("моите", "мое"),
("читавме", "чита"),
("изеде", "јаде"),
("изоди", "оди"),
("мислеше", "мисли")
],
)
def test_mk_lemmatizer_lookup_assigns(mk_lookup_nlp, string, lemma):
assert mk_lookup_nlp(string)[0].lemma_ == lemma
@pytest.mark.parametrize(
"string,lemma",
[
("Еј здр, как си? Јави се на мојот моб, бројот почиња со кец. Можит да дојдам со кола, позз.",
["еј", "здраво", ",", "како", "си", "?", "јави", "се", "на", "мојот", "мобилен", ",", "бројот", "започнува",
"со", "единица", ".", "Може", "да", "дојдам", "со", "автомобил", ",", "поздрав", "."])
]
)
def test_mk_tokenizer_norm_exceptions(mk_lookup_nlp, string, lemma):
assert [token.norm_ for token in mk_lookup_nlp(string)] == lemma