2017-01-24 09:55:02 +00:00
|
|
|
|
import pytest
|
2018-07-24 18:09:06 +00:00
|
|
|
|
|
2017-01-24 09:55:02 +00:00
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
|
@pytest.mark.parametrize(
|
2018-12-18 12:48:10 +00:00
|
|
|
|
"text",
|
|
|
|
|
[
|
2019-08-20 15:36:34 +00: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-20 21:10:13 +00:00
|
|
|
|
# u"K-POP",
|
|
|
|
|
# u"K-Pop",
|
|
|
|
|
# u"K-pop",
|
2019-08-20 15:36:34 +00: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 12:48:10 +00:00
|
|
|
|
],
|
2018-11-27 00:09:36 +00:00
|
|
|
|
)
|
2018-07-24 21:38:44 +00:00
|
|
|
|
def test_fr_tokenizer_infix_exceptions(fr_tokenizer, text):
|
2017-01-24 09:55:02 +00:00
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
|
|
2020-09-29 19:39:28 +00:00
|
|
|
|
@pytest.mark.parametrize("text", ["janv.", "juill.", "Dr.", "av.", "sept."])
|
2020-07-22 21:09:01 +00:00
|
|
|
|
def test_fr_tokenizer_handles_abbr(fr_tokenizer, text):
|
2017-01-24 09:55:02 +00:00
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
|
|
2018-07-24 21:38:44 +00:00
|
|
|
|
def test_fr_tokenizer_handles_exc_in_text(fr_tokenizer):
|
2017-01-24 09:55:02 +00: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 12:17:05 +00:00
|
|
|
|
|
|
|
|
|
|
2018-07-24 21:38:44 +00:00
|
|
|
|
def test_fr_tokenizer_handles_exc_in_text_2(fr_tokenizer):
|
2017-02-10 12:17:05 +00: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 08:59:38 +00:00
|
|
|
|
assert tokens[9].text == "italo-mexicain"
|
|
|
|
|
|
2018-07-24 21:38:44 +00:00
|
|
|
|
|
|
|
|
|
def test_fr_tokenizer_handles_title(fr_tokenizer):
|
2017-04-27 08:59:38 +00:00
|
|
|
|
text = "N'est-ce pas génial?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 6
|
|
|
|
|
assert tokens[0].text == "N'"
|
2017-04-27 09:52:14 +00:00
|
|
|
|
assert tokens[1].text == "est"
|
2017-04-27 08:59:38 +00:00
|
|
|
|
assert tokens[2].text == "-ce"
|
|
|
|
|
|
2018-07-24 21:38:44 +00:00
|
|
|
|
|
|
|
|
|
def test_fr_tokenizer_handles_title_2(fr_tokenizer):
|
2017-04-27 08:59:38 +00:00
|
|
|
|
text = "Est-ce pas génial?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
2020-07-20 12:49:54 +00:00
|
|
|
|
assert len(tokens) == 5
|
2017-04-27 08:59:38 +00:00
|
|
|
|
assert tokens[0].text == "Est"
|
2020-07-20 12:49:54 +00:00
|
|
|
|
assert tokens[1].text == "-ce"
|
2017-04-27 08:59:38 +00:00
|
|
|
|
|
2018-07-24 21:38:44 +00:00
|
|
|
|
|
2018-11-27 00:09:36 +00:00
|
|
|
|
def test_fr_tokenizer_handles_title_3(fr_tokenizer):
|
2017-04-27 08:59:38 +00:00
|
|
|
|
text = "Qu'est-ce que tu fais?"
|
|
|
|
|
tokens = fr_tokenizer(text)
|
|
|
|
|
assert len(tokens) == 7
|
|
|
|
|
assert tokens[0].text == "Qu'"
|