2017-01-05 17:11:25 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["auf'm", "du's", "über'm", "wir's"])
|
2017-06-03 19:07:44 +00:00
|
|
|
def test_de_tokenizer_splits_contractions(de_tokenizer, text):
|
2017-01-05 17:11:25 +00:00
|
|
|
tokens = de_tokenizer(text)
|
|
|
|
assert len(tokens) == 2
|
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize("text", ["z.B.", "d.h.", "Jan.", "Dez.", "Chr."])
|
2017-06-03 19:07:44 +00:00
|
|
|
def test_de_tokenizer_handles_abbr(de_tokenizer, text):
|
2017-01-05 17:11:25 +00:00
|
|
|
tokens = de_tokenizer(text)
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
2017-06-03 19:07:44 +00:00
|
|
|
def test_de_tokenizer_handles_exc_in_text(de_tokenizer):
|
2017-01-05 17:11:25 +00:00
|
|
|
text = "Ich bin z.Zt. im Urlaub."
|
|
|
|
tokens = de_tokenizer(text)
|
|
|
|
assert len(tokens) == 6
|
|
|
|
assert tokens[2].text == "z.Zt."
|
|
|
|
assert tokens[2].lemma_ == "zur Zeit"
|
2017-06-03 19:07:44 +00:00
|
|
|
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"text,norms", [("vor'm", ["vor", "dem"]), ("du's", ["du", "es"])]
|
|
|
|
)
|
2017-06-03 19:07:44 +00:00
|
|
|
def test_de_tokenizer_norm_exceptions(de_tokenizer, text, norms):
|
|
|
|
tokens = de_tokenizer(text)
|
|
|
|
assert [token.norm_ for token in tokens] == norms
|
|
|
|
|
|
|
|
|
2019-08-20 15:36:34 +00:00
|
|
|
@pytest.mark.parametrize("text,norm", [("daß", "dass")])
|
2017-06-03 19:07:44 +00:00
|
|
|
def test_de_lex_attrs_norm_exceptions(de_tokenizer, text, norm):
|
|
|
|
tokens = de_tokenizer(text)
|
|
|
|
assert tokens[0].norm_ == norm
|