2017-03-12 15:07:28 +03:00
|
|
|
# coding: utf8
|
2017-02-05 13:47:07 +03:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
SV_TOKEN_EXCEPTION_TESTS = [
|
2018-11-27 03:09:36 +03:00
|
|
|
(
|
|
|
|
"Smörsåsen används bl.a. till fisk",
|
|
|
|
["Smörsåsen", "används", "bl.a.", "till", "fisk"],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Jag kommer först kl. 13 p.g.a. diverse förseningar",
|
|
|
|
["Jag", "kommer", "först", "kl.", "13", "p.g.a.", "diverse", "förseningar"],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Anders I. tycker om ord med i i.",
|
|
|
|
["Anders", "I.", "tycker", "om", "ord", "med", "i", "i", "."],
|
|
|
|
),
|
2017-02-05 13:47:07 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text,expected_tokens", SV_TOKEN_EXCEPTION_TESTS)
|
2018-07-25 00:38:44 +03:00
|
|
|
def test_sv_tokenizer_handles_exception_cases(sv_tokenizer, text, expected_tokens):
|
2017-02-05 13:47:07 +03:00
|
|
|
tokens = sv_tokenizer(text)
|
|
|
|
token_list = [token.text for token in tokens if not token.is_space]
|
|
|
|
assert expected_tokens == token_list
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
@pytest.mark.parametrize("text", ["driveru", "hajaru", "Serru", "Fixaru"])
|
2018-07-25 00:38:44 +03:00
|
|
|
def test_sv_tokenizer_handles_verb_exceptions(sv_tokenizer, text):
|
2017-02-05 13:47:07 +03:00
|
|
|
tokens = sv_tokenizer(text)
|
|
|
|
assert len(tokens) == 2
|
|
|
|
assert tokens[1].text == "u"
|