From 19dab28ecb530d0f6b620b092003fce9d97d9e1c Mon Sep 17 00:00:00 2001 From: erjemin Date: Wed, 30 Jul 2025 19:27:21 +0300 Subject: [PATCH] =?UTF-8?q?mod:=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=B0=D0=BD=D0=B3=D0=BB=D0=B8=D0=B9=D1=81=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B2=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_hyphenation.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_hyphenation.py b/tests/test_hyphenation.py index 2c25d17..c9089cf 100644 --- a/tests/test_hyphenation.py +++ b/tests/test_hyphenation.py @@ -1,6 +1,7 @@ # tests/test_hyphenation.py import pytest from etpgrf import Hyphenator +from tests.test_unbreakables import ENGLISH_PREPOSITIONS_TO_TEST # --- Тестовые данные для русского языка --- # Формат: (входное_слово, ожидаемый_результат_с_переносами) @@ -45,4 +46,31 @@ def test_russian_word_hyphenation(input_word, expected_output): assert actual_output == expected_output +ENGLISH_HYPHENATION_CASES = [ + ("color", "color"), # Короткое слово, не должно меняться + ("throughout", "throughout"), # Длинное слово, но из-за икс-графа "ough" не будет переноситься + ("ambrella", "amb\u00ADrella"), + ("unbelievable", "unbel\u00ADiev\u00ADable"), # Проверка переноса перед суффиксом "able" + ("acknowledgment", "ack\u00ADnow\u00ADledg\u00ADment"), # Проверка переноса перед суффиксом "ment" + ("friendship", "frien\u00ADdship"), # Проверка переноса перед суффиксом "ship" + ("thoughtful", "though\u00ADtful"), # + ("psychology", "psy\u00ADcho\u00ADlogy"), # Проверка переноса после "psy" + ("extraordinary", "ext\u00ADraor\u00ADdin\u00ADary"), # Проверка сложного слова + ("unbreakable", "unb\u00ADrea\u00ADkable"), # Проверка переноса перед "able" + ("acknowledgement", "ack\u00ADnow\u00ADledge\u00ADment"), # Проверка икс-графа "dge" + ("misunderstanding", "mis\u00ADunder\u00ADstan\u00ADding"), # Проверка сложного слова + ("floccinaucinihilipilification", "floc\u00ADcin\u00ADauc\u00ADinih\u00ADili\u00ADpili\u00ADfica\u00ADtion"), +] + +@pytest.mark.parametrize("input_word, expected_output", ENGLISH_HYPHENATION_CASES) +def test_english_word_hyphenation(input_word, expected_output): + """ + Проверяет ПОВЕДЕНИЕ: правильная расстановка переносов в отдельных английских словах. + """ + # Arrange (подготовка) + hyphenator_en = Hyphenator(langs='en', max_unhyphenated_len=5, min_tail_len=3) + # Act (действие) - тестируем самый "атомарный" метод + actual_output = hyphenator_en.hyp_in_word(input_word) + # Assert (проверка) + assert actual_output == expected_output