2017-01-24 12:55:02 +03:00
|
|
|
|
import pytest
|
2018-07-24 21:09:06 +03:00
|
|
|
|
|
2017-01-24 12:55:02 +03:00
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
|
@pytest.mark.parametrize(
|
2018-12-18 15:48:10 +03:00
|
|
|
|
"text",
|
|
|
|
|
[
|
2019-08-20 18:36:34 +03:00
|
|
|
|
"aujourd'hui",
|
|
|
|
|
"Aujourd'hui",
|
|
|
|
|
"prud'hommes",
|
|
|
|
|
"prud’hommal",
|
|
|
|
|
"audio-numérique",
|
|
|
|
|
"Audio-numérique",
|
|
|
|
|
"entr'amis",
|
|
|
|
|
"entr'abat",
|
|
|
|
|
"rentr'ouvertes",
|
|
|
|
|
"grand'hamien",
|
|
|
|
|
"Châteauneuf-la-Forêt",
|
|
|
|
|
"Château-Guibert",
|
|
|
|
|
"refox-trottâmes",
|
2019-02-21 00:10:13 +03:00
|
|
|
|
# u"K-POP",
|
|
|
|
|
# u"K-Pop",
|
|
|
|
|
# u"K-pop",
|
2019-08-20 18:36:34 +03:00
|
|
|
|
"z'yeutes",
|
|
|
|
|
"black-outeront",
|
|
|
|
|
"états-unienne",
|
|
|
|
|
"courtes-pattes",
|
|
|
|
|
"court-pattes",
|
|
|
|
|
"saut-de-ski",
|
|
|
|
|
"Écourt-Saint-Quentin",
|
|
|
|
|
"Bout-de-l'Îlien",
|
|
|
|
|
"pet-en-l'air",
|
2018-12-18 15:48:10 +03:00
|
|
|
|
],
|
2018-11-27 03:09:36 +03:00
|
|
|
|
)
|
2018-07-25 00:38:44 +03:00
|
|
|
|
def test_fr_tokenizer_infix_exceptions(fr_tokenizer, text):
|
2017-01-24 12:55:02 +03:00
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
|
@pytest.mark.parametrize(
|
2020-07-23 00:09:01 +03:00
|
|
|
|
"text", ["janv.", "juill.", "Dr.", "av.", "sept."],
|
2018-11-27 03:09:36 +03:00
|
|
|
|
)
|
2020-07-23 00:09:01 +03:00
|
|
|
|
def test_fr_tokenizer_handles_abbr(fr_tokenizer, text):
|
2017-01-24 12:55:02 +03:00
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
|
|
2018-07-25 00:38:44 +03:00
|
|
|
|
def test_fr_tokenizer_handles_exc_in_text(fr_tokenizer):
|
2017-01-24 12:55:02 +03:00
|
|
|
|
text = "Je suis allé au mois de janv. aux prud’hommes."
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 10
|
|
|
|
|
assert tokens[6].text == "janv."
|
|
|
|
|
assert tokens[8].text == "prud’hommes"
|
2017-02-10 15:17:05 +03:00
|
|
|
|
|
|
|
|
|
|
2018-07-25 00:38:44 +03:00
|
|
|
|
def test_fr_tokenizer_handles_exc_in_text_2(fr_tokenizer):
|
2017-02-10 15:17:05 +03:00
|
|
|
|
text = "Cette après-midi, je suis allé dans un restaurant italo-mexicain."
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 11
|
|
|
|
|
assert tokens[1].text == "après-midi"
|
2017-04-27 11:59:38 +03:00
|
|
|
|
assert tokens[9].text == "italo-mexicain"
|
|
|
|
|
|
2018-07-25 00:38:44 +03:00
|
|
|
|
|
|
|
|
|
def test_fr_tokenizer_handles_title(fr_tokenizer):
|
2017-04-27 11:59:38 +03:00
|
|
|
|
text = "N'est-ce pas génial?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 6
|
|
|
|
|
assert tokens[0].text == "N'"
|
2017-04-27 12:52:14 +03:00
|
|
|
|
assert tokens[1].text == "est"
|
2017-04-27 11:59:38 +03:00
|
|
|
|
assert tokens[2].text == "-ce"
|
|
|
|
|
|
2018-07-25 00:38:44 +03:00
|
|
|
|
|
|
|
|
|
def test_fr_tokenizer_handles_title_2(fr_tokenizer):
|
2017-04-27 11:59:38 +03:00
|
|
|
|
text = "Est-ce pas génial?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
2020-07-20 15:49:54 +03:00
|
|
|
|
assert len(tokens) == 5
|
2017-04-27 11:59:38 +03:00
|
|
|
|
assert tokens[0].text == "Est"
|
2020-07-20 15:49:54 +03:00
|
|
|
|
assert tokens[1].text == "-ce"
|
2017-04-27 11:59:38 +03:00
|
|
|
|
|
2018-07-25 00:38:44 +03:00
|
|
|
|
|
2018-11-27 03:09:36 +03:00
|
|
|
|
def test_fr_tokenizer_handles_title_3(fr_tokenizer):
|
2017-04-27 11:59:38 +03:00
|
|
|
|
text = "Qu'est-ce que tu fais?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 7
|
|
|
|
|
assert tokens[0].text == "Qu'"
|