From ac7a8c2ff8b13b459074ce23fdb86d0f47c77ff8 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Thu, 28 Dec 2023 11:48:59 +0300 Subject: [PATCH 01/17] Add PSR-4 support --- .gitignore | 3 + Library/NCL/NCL.php | 2 + Library/NCL/NCLNameCaseCore.php | 9 +- Library/NCL/NCLNameCaseWord.php | 1 + Library/NCL/NCLStr.php | 1 + Library/NCLNameCaseRu.php | 571 +++++++----------- Library/NCLNameCaseUa.php | 392 +++++------- README.md | 4 + Tests/Library/NCLNameCaseRuTestFatherboy.php | 2 +- Tests/Library/NCLNameCaseRuTestFathergirl.php | 2 +- Tests/Library/NCLNameCaseRuTestNamesgirl.php | 2 +- .../Library/NCLNameCaseRuTestSirnamesboy.php | 2 +- .../Library/NCLNameCaseRuTestSirnamesgirl.php | 2 +- Tests/testPSR4.php | 23 + composer.json | 25 + 15 files changed, 435 insertions(+), 606 deletions(-) create mode 100644 .gitignore create mode 100644 Tests/testPSR4.php create mode 100644 composer.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..962f254 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +vendor/ +.idea/ \ No newline at end of file diff --git a/Library/NCL/NCL.php b/Library/NCL/NCL.php index a8a0d2f..8c20a97 100644 --- a/Library/NCL/NCL.php +++ b/Library/NCL/NCL.php @@ -1,4 +1,6 @@ NCL NameCase Core diff --git a/Library/NCL/NCLNameCaseWord.php b/Library/NCL/NCLNameCaseWord.php index ed81e95..38f1424 100644 --- a/Library/NCL/NCLNameCaseWord.php +++ b/Library/NCL/NCLNameCaseWord.php @@ -1,4 +1,5 @@ NCL NameCase Russian Language - * + * * Русские правила склонения ФИО * Правила определения пола человека по ФИО для русского языка * Система разделения фамилий имен и отчеств для русского языка - * + * * @author Андрей Чайка * @version 0.4.1 * @package NameCaseLib @@ -25,7 +29,7 @@ class NCLNameCaseRu extends NCLNameCaseCore /** * Версия языкового файла - * @var string + * @var string */ protected $languageBuild = '11072716'; /** @@ -35,26 +39,26 @@ class NCLNameCaseRu extends NCLNameCaseCore protected $CaseCount = 6; /** * Список гласных русского языка - * @var string + * @var string */ private $vowels = "аеёиоуыэюя"; /** * Список согласных русского языка - * @var string + * @var string */ private $consonant = "бвгджзйклмнпрстфхцчшщ"; /** * Окончания имен/фамилий, который не склоняются - * @var array + * @var array */ private $ovo = array('ово', 'аго', 'яго', 'ирь'); /** * Окончания имен/фамилий, который не склоняются - * @var array + * @var array */ private $ih = array('их', 'ых', 'ко', 'уа'/*Бенуа, Франсуа*/); /** - * Список окончаний характерных для фамилий + * Список окончаний характерных для фамилий * По шаблону {letter}* где * любой символ кроме тех, что в {exclude} * @var array of {letter}=>{exclude} */ @@ -94,38 +98,33 @@ class NCLNameCaseRu extends NCLNameCaseCore 'я' => 'нс' ); - private $names_man=array('Вова', 'Анри', 'Питер', 'Пауль', 'Франц', 'Вильям', 'Уильям', - 'Альфонс', 'Ганс', 'Франс', 'Филиппо', 'Андреа', 'Корнелис', 'Фрэнк', 'Леонардо', - 'Джеймс', 'Отто', 'жан-пьер', 'Джованни', 'Джозеф', 'Педро', 'Адольф', 'Уолтер', - 'Антонио', 'Якоб', 'Эсташ', 'Адрианс', 'Франческо', 'Доменико', 'Ханс', 'Гун', - 'Шарль', 'Хендрик', 'Амброзиус', 'Таддео', 'Фердинанд', 'Джошуа', 'Изак', 'Иоганн', - 'Фридрих', 'Эмиль', 'Умберто', 'Франсуа', 'Ян', 'Эрнст', 'Георг', 'Карл' - ); + private $names_man = array('Вова', 'Анри', 'Питер', 'Пауль', 'Франц', 'Вильям', 'Уильям', + 'Альфонс', 'Ганс', 'Франс', 'Филиппо', 'Андреа', 'Корнелис', 'Фрэнк', 'Леонардо', + 'Джеймс', 'Отто', 'жан-пьер', 'Джованни', 'Джозеф', 'Педро', 'Адольф', 'Уолтер', + 'Антонио', 'Якоб', 'Эсташ', 'Адрианс', 'Франческо', 'Доменико', 'Ханс', 'Гун', + 'Шарль', 'Хендрик', 'Амброзиус', 'Таддео', 'Фердинанд', 'Джошуа', 'Изак', 'Иоганн', + 'Фридрих', 'Эмиль', 'Умберто', 'Франсуа', 'Ян', 'Эрнст', 'Георг', 'Карл' + ); /** - * Мужские имена, оканчивающиеся на любой ь и -й, + * Мужские имена, оканчивающиеся на любой ь и -й, * скло­няются так же, как обычные существительные мужского рода - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule1() { - if ($this->in($this->Last(1), 'ьй')) - { - if ($this->inNames($this->workingWord, array('Дель'))) - { + if ($this->in($this->Last(1), 'ьй')) { + if ($this->inNames($this->workingWord, array('Дель'))) { $this->Rule(101); $this->makeResultTheSame(); return true; } - if ($this->Last(2, 1) != "и") - { + if ($this->Last(2, 1) != "и") { $this->wordForms($this->workingWord, array('я', 'ю', 'я', 'ем', 'е'), 1); $this->Rule(102); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('я', 'ю', 'я', 'ем', 'и'), 1); $this->Rule(103); return true; @@ -135,34 +134,26 @@ protected function manRule1() } /** - * Мужские имена, оканчивающиеся на любой твердый согласный, + * Мужские имена, оканчивающиеся на любой твердый согласный, * склоняются так же, как обычные существительные мужского рода - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule2() { - if ($this->in($this->Last(1), $this->consonant)) - { - if ($this->inNames($this->workingWord, "Павел")) - { + if ($this->in($this->Last(1), $this->consonant)) { + if ($this->inNames($this->workingWord, "Павел")) { $this->lastResult = array("Павел", "Павла", "Павлу", "Павла", "Павлом", "Павле"); $this->Rule(201); return true; - } - elseif ($this->inNames($this->workingWord, "Лев")) - { + } elseif ($this->inNames($this->workingWord, "Лев")) { $this->lastResult = array("Лев", "Льва", "Льву", "Льва", "Львом", "Льве"); $this->Rule(202); return true; - } - elseif ($this->inNames($this->workingWord, 'ван')) - { + } elseif ($this->inNames($this->workingWord, 'ван')) { $this->Rule(203); $this->makeResultTheSame(); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'е')); $this->Rule(204); return true; @@ -172,37 +163,29 @@ protected function manRule2() } /** - * Мужские и женские имена, оканчивающиеся на -а, склоняются, как и любые + * Мужские и женские имена, оканчивающиеся на -а, склоняются, как и любые * существительные с таким же окончанием - * Мужские и женские имена, оканчивающиеся иа -я, -ья, -ия, -ея, независимо от языка, + * Мужские и женские имена, оканчивающиеся иа -я, -ья, -ия, -ея, независимо от языка, * из которого они происходят, склоняются как существительные с соответствующими окончаниями - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule3() { - if ($this->Last(1) == "а") - { - if ($this->inNames($this->workingWord, array('фра', 'Дега', 'Андреа', 'Сёра', 'Сера'))) - { + if ($this->Last(1) == "а") { + if ($this->inNames($this->workingWord, array('фра', 'Дега', 'Андреа', 'Сёра', 'Сера'))) { $this->Rule(301); $this->makeResultTheSame(); return true; - } - elseif (!$this->in($this->Last(2, 1), 'кшгх')) - { + } elseif (!$this->in($this->Last(2, 1), 'кшгх')) { $this->wordForms($this->workingWord, array('ы', 'е', 'у', 'ой', 'е'), 1); $this->Rule(302); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ой', 'е'), 1); $this->Rule(303); return true; } - } - elseif ($this->Last(1) == "я") - { + } elseif ($this->Last(1) == "я") { $this->wordForms($this->workingWord, array('и', 'е', 'ю', 'ей', 'е'), 1); $this->Rule(303); return true; @@ -211,50 +194,38 @@ protected function manRule3() } /** - * Мужские фамилии, оканчивающиеся на -ь -й, склоняются так же, + * Мужские фамилии, оканчивающиеся на -ь -й, склоняются так же, * как обычные существительные мужского рода - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule4() { - if ($this->in($this->Last(1), 'ьй')) - { + if ($this->in($this->Last(1), 'ьй')) { //Слова типа Воробей - if ($this->Last(3) == 'бей') - { + if ($this->Last(3) == 'бей') { $this->wordForms($this->workingWord, array('ья', 'ью', 'ья', 'ьем', 'ье'), 2); $this->Rule(400); return true; - } - elseif ($this->Last(3, 1) == 'а' or $this->in($this->Last(2, 1), 'ел')) - { + } elseif ($this->Last(3, 1) == 'а' or $this->in($this->Last(2, 1), 'ел')) { $this->wordForms($this->workingWord, array('я', 'ю', 'я', 'ем', 'е'), 1); $this->Rule(401); return true; - } -//Толстой -» ТолстЫм - elseif ($this->Last(2, 1) == 'ы' or $this->Last(3, 1) == 'т') - { + } //Толстой -» ТолстЫм + elseif ($this->Last(2, 1) == 'ы' or $this->Last(3, 1) == 'т') { $this->wordForms($this->workingWord, array('ого', 'ому', 'ого', 'ым', 'ом'), 2); $this->Rule(402); return true; - } -//Лесничий - elseif ($this->Last(3) == 'чий') - { + } //Лесничий + elseif ($this->Last(3) == 'чий') { $this->wordForms($this->workingWord, array('ьего', 'ьему', 'ьего', 'ьим', 'ьем'), 2); $this->Rule(403); return true; - } - elseif (!$this->in($this->Last(2, 1), $this->vowels) or $this->Last(2, 1) == 'и') - { + } elseif (!$this->in($this->Last(2, 1), $this->vowels) or $this->Last(2, 1) == 'и') { $this->wordForms($this->workingWord, array('ого', 'ому', 'ого', 'им', 'ом'), 2); $this->Rule(404); return true; - } - else - { + } else { $this->makeResultTheSame(); $this->Rule(405); return true; @@ -265,27 +236,24 @@ protected function manRule4() /** * Мужские фамилии, оканчивающиеся на -к - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule5() { - if ($this->Last(1) == 'к') - { + if ($this->Last(1) == 'к') { //Если перед слово на ок, то нужно убрать о - if ($this->Last(4)=='енок' || $this->Last(4)=='ёнок')//Поллок + if ($this->Last(4) == 'енок' || $this->Last(4) == 'ёнок')//Поллок { $this->wordForms($this->workingWord, array('ка', 'ку', 'ка', 'ком', 'ке'), 2); $this->Rule(501); return true; } - if ($this->Last(2, 1) == 'е' && !in_array($this->Last(3, 1), array('р')))//Лотрек + if ($this->Last(2, 1) == 'е' && !in_array($this->Last(3, 1), array('р')))//Лотрек { $this->wordForms($this->workingWord, array('ька', 'ьку', 'ька', 'ьком', 'ьке'), 2); $this->Rule(502); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'е')); $this->Rule(503); return true; @@ -296,31 +264,24 @@ protected function manRule5() /** * Мужские фамили на согласный выбираем ем/ом/ым - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule6() { - if ($this->Last(1) == 'ч') - { + if ($this->Last(1) == 'ч') { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ем', 'е')); $this->Rule(601); return true; - } -//е перед ц выпадает - elseif ($this->Last(2) == 'ец') - { + } //е перед ц выпадает + elseif ($this->Last(2) == 'ец') { $this->wordForms($this->workingWord, array('ца', 'цу', 'ца', 'цом', 'це'), 2); $this->Rule(604); return true; - } - elseif ($this->in($this->Last(1), 'цсршмхт')) - { + } elseif ($this->in($this->Last(1), 'цсршмхт')) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'е')); $this->Rule(602); return true; - } - elseif ($this->in($this->Last(1), $this->consonant)) - { + } elseif ($this->in($this->Last(1), $this->consonant)) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ым', 'е')); $this->Rule(603); return true; @@ -330,42 +291,33 @@ protected function manRule6() /** * Мужские фамили на -а -я - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule7() { - if ($this->Last(1) == "а") - { - if ($this->inNames($this->workingWord, array('да'))) - { - $this->Rule(701); - $this->makeResultTheSame(); - return true; - } + if ($this->Last(1) == "а") { + if ($this->inNames($this->workingWord, array('да'))) { + $this->Rule(701); + $this->makeResultTheSame(); + return true; + } //Если основа на ш, то нужно и, ей - if ($this->Last(2, 1) == 'ш') - { + if ($this->Last(2, 1) == 'ш') { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ей', 'е'), 1); - $this->Rule(702); + $this->Rule(702); return true; - } - elseif ($this->in($this->Last(2, 1), 'хкг')) - { + } elseif ($this->in($this->Last(2, 1), 'хкг')) { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ой', 'е'), 1); - $this->Rule(703); + $this->Rule(703); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('ы', 'е', 'у', 'ой', 'е'), 1); - $this->Rule(704); + $this->Rule(704); return true; } - } - elseif ($this->Last(1) == "я") - { + } elseif ($this->Last(1) == "я") { $this->wordForms($this->workingWord, array('ой', 'ой', 'ую', 'ой', 'ой'), 2); - $this->Rule(705); + $this->Rule(705); return true; } return false; @@ -373,13 +325,12 @@ protected function manRule7() /** * Не склоняются мужский фамилии - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function manRule8() { - if ($this->in($this->Last(3), $this->ovo) || $this->in($this->Last(2), $this->ih)) - { - if ( $this->inNames($this->workingWord, array('рерих')) ) return false; + if ($this->in($this->Last(3), $this->ovo) || $this->in($this->Last(2), $this->ih)) { + if ($this->inNames($this->workingWord, array('рерих'))) return false; $this->Rule(8); $this->makeResultTheSame(); return true; @@ -388,31 +339,24 @@ protected function manRule8() } /** - * Мужские и женские имена, оканчивающиеся на -а, склоняются, + * Мужские и женские имена, оканчивающиеся на -а, склоняются, * как и любые существительные с таким же окончанием - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function womanRule1() { - if ($this->Last(1) == "а" and $this->Last(2, 1) != 'и') - { - if (!$this->in($this->Last(2, 1), 'шхкг')) - { + if ($this->Last(1) == "а" and $this->Last(2, 1) != 'и') { + if (!$this->in($this->Last(2, 1), 'шхкг')) { $this->wordForms($this->workingWord, array('ы', 'е', 'у', 'ой', 'е'), 1); $this->Rule(101); return true; - } - else - { + } else { //ей посля шиплячего - if ($this->Last(2, 1) == 'ш') - { + if ($this->Last(2, 1) == 'ш') { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ей', 'е'), 1); $this->Rule(102); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ой', 'е'), 1); $this->Rule(103); return true; @@ -423,22 +367,18 @@ protected function womanRule1() } /** - * Мужские и женские имена, оканчивающиеся иа -я, -ья, -ия, -ея, независимо от языка, + * Мужские и женские имена, оканчивающиеся иа -я, -ья, -ия, -ея, независимо от языка, * из которого они происходят, склоняются как сущест­вительные с соответствующими окончаниями - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function womanRule2() { - if ($this->Last(1) == "я") - { - if ($this->Last(2, 1) <> "и") - { + if ($this->Last(1) == "я") { + if ($this->Last(2, 1) <> "и") { $this->wordForms($this->workingWord, array('и', 'е', 'ю', 'ей', 'е'), 1); $this->Rule(201); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('и', 'и', 'ю', 'ей', 'и'), 1); $this->Rule(202); return true; @@ -448,14 +388,13 @@ protected function womanRule2() } /** - * Русские женские имена, оканчивающиеся на мягкий согласный, склоняются, + * Русские женские имена, оканчивающиеся на мягкий согласный, склоняются, * как существительные женского рода типа дочь, тень - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function womanRule3() { - if ($this->Last(1) == "ь") - { + if ($this->Last(1) == "ь") { $this->wordForms($this->workingWord, array('и', 'и', 'ь', 'ью', 'и'), 1); $this->Rule(3); return true; @@ -466,34 +405,26 @@ protected function womanRule3() /** * Женские фамилия, оканчивающиеся на -а -я, склоняются, * как и любые существительные с таким же окончанием - * @return bool true если правило было задействовано и false если нет. + * @return bool true если правило было задействовано и false если нет. */ protected function womanRule4() { - if ($this->Last(1) == "а") - { - if ($this->in($this->Last(2, 1), 'гк')) - { + if ($this->Last(1) == "а") { + if ($this->in($this->Last(2, 1), 'гк')) { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ой', 'е'), 1); $this->Rule(401); return true; - } - elseif ($this->in($this->Last(2, 1), 'ш')) - { + } elseif ($this->in($this->Last(2, 1), 'ш')) { $this->wordForms($this->workingWord, array('и', 'е', 'у', 'ей', 'е'), 1); $this->Rule(402); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array('ой', 'ой', 'у', 'ой', 'ой'), 1); $this->Rule(403); return true; } - } - elseif ($this->Last(1) == "я") - { + } elseif ($this->Last(1) == "я") { $this->wordForms($this->workingWord, array('ой', 'ой', 'ую', 'ой', 'ой'), 2); $this->Rule(404); return true; @@ -507,13 +438,11 @@ protected function womanRule4() */ protected function manFirstName() { - if ($this->inNames($this->workingWord, array('Старший', 'Младший'))) - { + if ($this->inNames($this->workingWord, array('Старший', 'Младший'))) { $this->wordForms($this->workingWord, array('его', 'ему', 'его', 'им', 'ем'), 2); return true; } - if ($this->inNames($this->workingWord, array('Мариа'))) - { + if ($this->inNames($this->workingWord, array('Мариа'))) { //Альфонс Мария Муха $this->wordForms($this->workingWord, array('и', 'и', 'ю', 'ей', 'ии'), 1); return true; @@ -553,15 +482,12 @@ protected function womanSecondName() * @return boolean true - если слово было успешно изменено, false - если не получилось этого сделать */ protected function manFatherName() - { + { //Проверяем действительно ли отчество - if ($this->inNames($this->workingWord, 'Ильич')) - { + if ($this->inNames($this->workingWord, 'Ильич')) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'е')); return true; - } - elseif ($this->Last(2) == 'ич') - { + } elseif ($this->Last(2) == 'ич') { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ем', 'е')); return true; } @@ -575,8 +501,7 @@ protected function manFatherName() protected function womanFatherName() { //Проверяем действительно ли отчество - if ($this->Last(2) == 'на') - { + if ($this->Last(2) == 'на') { $this->wordForms($this->workingWord, array('ы', 'е', 'у', 'ой', 'е'), 1); return true; } @@ -595,73 +520,59 @@ protected function GenderByFirstName(NCLNameCaseWord $word) $woman = 0; //Женщина //Попробуем выжать максимум из имени //Если имя заканчивается на й, то скорее всего мужчина - if ($this->Last(1) == 'й') - { - $man+=0.9; + if ($this->Last(1) == 'й') { + $man += 0.9; } - if ($this->in($this->Last(2), array('он', 'ов', 'ав', 'ам', 'ол', 'ан', 'рд', 'мп', 'по'/*Филиппо*/, 'до'/*Леонардо*/, 'др', 'рт'))) - { - $man+=0.3; + if ($this->in($this->Last(2), array('он', 'ов', 'ав', 'ам', 'ол', 'ан', 'рд', 'мп', 'по'/*Филиппо*/, 'до'/*Леонардо*/, 'др', 'рт'))) { + $man += 0.3; } - if ($this->in($this->Last(1), $this->consonant)) - { - $man+=0.01; + if ($this->in($this->Last(1), $this->consonant)) { + $man += 0.01; } - if ($this->Last(1) == 'ь') - { - $man+=0.02; + if ($this->Last(1) == 'ь') { + $man += 0.02; } - if ($this->in($this->Last(2), array('вь', 'фь', 'ль', 'на'))) - { - $woman+=0.1; + if ($this->in($this->Last(2), array('вь', 'фь', 'ль', 'на'))) { + $woman += 0.1; } - if ($this->in($this->Last(2), array('ла'))) - { - $woman+=0.04; + if ($this->in($this->Last(2), array('ла'))) { + $woman += 0.04; } - if ($this->in($this->Last(2), array('то', 'ма'))) - { - $man+=0.01; + if ($this->in($this->Last(2), array('то', 'ма'))) { + $man += 0.01; } - if ($this->in($this->Last(3), array('лья', 'вва', 'ока', 'ука', 'ита', 'эль'/*Рафаэль, Габриэль*/, 'реа'/*Андреа*/))) - { - $man+=0.2; + if ($this->in($this->Last(3), array('лья', 'вва', 'ока', 'ука', 'ита', 'эль'/*Рафаэль, Габриэль*/, 'реа'/*Андреа*/))) { + $man += 0.2; } - if ($this->in($this->Last(3), array('има'))) - { - $woman+=0.15; + if ($this->in($this->Last(3), array('има'))) { + $woman += 0.15; } - if ($this->in($this->Last(3), array('лия', 'ния', 'сия', 'дра', 'лла', 'кла', 'опа', 'вия'))) - { - $woman+=0.5; + if ($this->in($this->Last(3), array('лия', 'ния', 'сия', 'дра', 'лла', 'кла', 'опа', 'вия'))) { + $woman += 0.5; } - if ($this->in($this->Last(4), array('льда', 'фира', 'нина', 'лита', 'алья'))) - { - $woman+=0.5; + if ($this->in($this->Last(4), array('льда', 'фира', 'нина', 'лита', 'алья'))) { + $woman += 0.5; } - - if ($this->inNames($this->workingWord, $this->names_man)) - { + + if ($this->inNames($this->workingWord, $this->names_man)) { $man += 10; } - - if ($this->inNames($this->workingWord, array('Бриджет', 'Элизабет', 'Маргарет', 'Джанет', 'Жаклин', 'Эвелин'))) - { + + if ($this->inNames($this->workingWord, array('Бриджет', 'Элизабет', 'Маргарет', 'Джанет', 'Жаклин', 'Эвелин'))) { $woman += 10; } - //Исключение для Берил Кук, которая женщина - if ($this->inNames($this->workingWord, array('Берил'))) - { - $woman += 0.05; - } + //Исключение для Берил Кук, которая женщина + if ($this->inNames($this->workingWord, array('Берил'))) { + $woman += 0.05; + } $word->setGender($man, $woman); } @@ -677,19 +588,16 @@ protected function GenderBySecondName(NCLNameCaseWord $word) $man = 0; //Мужчина $woman = 0; //Женщина - if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'ий', 'ёв', 'ый', 'ын', 'ой'))) - { - $man+=0.4; + if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'ий', 'ёв', 'ый', 'ын', 'ой'))) { + $man += 0.4; } - if ($this->in($this->Last(3), array('ова', 'ина', 'ева', 'ёва', 'ына', 'мин'))) - { - $woman+=0.4; + if ($this->in($this->Last(3), array('ова', 'ина', 'ева', 'ёва', 'ына', 'мин'))) { + $woman += 0.4; } - if ($this->in($this->Last(2), array('ая'))) - { - $woman+=0.4; + if ($this->in($this->Last(2), array('ая'))) { + $woman += 0.4; } $word->setGender($man, $woman); @@ -703,18 +611,16 @@ protected function GenderByFatherName(NCLNameCaseWord $word) { $this->setWorkingWord($word->getWord()); - if ($this->Last(2) == 'ич') - { + if ($this->Last(2) == 'ич') { $word->setGender(10, 0); // мужчина } - if ($this->Last(2) == 'на') - { + if ($this->Last(2) == 'на') { $word->setGender(0, 12); // женщина } } /** - * Идетифицирует слово определяе имя это, или фамилия, или отчество + * Идетифицирует слово определяе имя это, или фамилия, или отчество * - N - имя * - S - фамилия * - F - отчество @@ -732,45 +638,37 @@ protected function detectNamePart(NCLNameCaseWord $word) $father = 0; //если смахивает на отчество - if ($this->in($this->Last(3), array('вна', 'чна', 'вич', 'ьич'))) - { - $father+=3; + if ($this->in($this->Last(3), array('вна', 'чна', 'вич', 'ьич'))) { + $father += 3; } - if ($this->in($this->Last(2), array('ша'))) - { - $first+=0.5; + if ($this->in($this->Last(2), array('ша'))) { + $first += 0.5; } - if ($this->in($this->Last(3), array('эль'/*Рафаэль, Габриэль*/))) - { - $first+=0.5; + if ($this->in($this->Last(3), array('эль'/*Рафаэль, Габриэль*/))) { + $first += 0.5; } /** - * буквы на которые никогда не заканчиваются имена + * буквы на которые никогда не заканчиваются имена */ - if ($this->in($this->Last(1), 'еёжхцочшщъыэю')) - { - /** - * Просто исключения - */ - if ($this->inNames($namepart, array('Мауриц'))) - { - $first += 10; - } - else { - $second += 0.3; - } - } + if ($this->in($this->Last(1), 'еёжхцочшщъыэю')) { + /** + * Просто исключения + */ + if ($this->inNames($namepart, array('Мауриц'))) { + $first += 10; + } else { + $second += 0.3; + } + } /** * Используем массив характерных окончаний */ - if (isset($this->splitSecondExclude[$this->Last(2, 1)])) - { - if (!$this->in($this->Last(1), $this->splitSecondExclude[$this->Last(2, 1)])) - { + if (isset($this->splitSecondExclude[$this->Last(2, 1)])) { + if (!$this->in($this->Last(1), $this->splitSecondExclude[$this->Last(2, 1)])) { $second += 0.4; } } @@ -778,56 +676,45 @@ protected function detectNamePart(NCLNameCaseWord $word) /** * Сокращенные ласкательные имена типя Аня Галя и.т.д. */ - if ($this->Last(1) == 'я' and $this->in($this->Last(3, 1), $this->vowels)) - { + if ($this->Last(1) == 'я' and $this->in($this->Last(3, 1), $this->vowels)) { $first += 0.5; } /** * Не бывает имен с такими предпоследними буквами */ - if ($this->in($this->Last(2, 1), 'жчщъэю')) - { + if ($this->in($this->Last(2, 1), 'жчщъэю')) { $second += 0.3; } /** * Слова на мягкий знак. Существует очень мало имен на мягкий знак. Все остальное фамилии */ - if ($this->Last(1) == 'ь') - { + if ($this->Last(1) == 'ь') { /** * Имена типа нинЕЛь адЕЛь асЕЛь */ - if ($this->Last(3, 2) == 'ел') - { + if ($this->Last(3, 2) == 'ел') { $first += 0.7; - } - /** + } /** * Просто исключения */ - elseif ($this->inNames($namepart, array('Лазарь', 'Игорь', 'Любовь'))) - { + elseif ($this->inNames($namepart, array('Лазарь', 'Игорь', 'Любовь'))) { $first += 10; - } - /** + } /** * Если не то и не другое, тогда фамилия */ - else - { + else { $second += 0.3; } - } - /** + } /** * Если две последних букв согласные то скорее всего это фамилия */ - elseif ($this->in($this->Last(1), $this->consonant . 'ь') and $this->in($this->Last(2, 1), $this->consonant . 'ь')) - { + elseif ($this->in($this->Last(1), $this->consonant . 'ь') and $this->in($this->Last(2, 1), $this->consonant . 'ь')) { /** * Практически все кроме тех которые оканчиваются на следующие буквы */ - if (!$this->in($this->Last(2), array('др', 'кт', 'лл', 'пп', 'рд', 'рк', 'рп', 'рт', 'тр'))) - { + if (!$this->in($this->Last(2), array('др', 'кт', 'лл', 'пп', 'рд', 'рк', 'рп', 'рт', 'тр'))) { $second += 0.25; } } @@ -835,47 +722,40 @@ protected function detectNamePart(NCLNameCaseWord $word) /** * Слова, которые заканчиваются на тин */ - if ($this->Last(3) == 'тин' and $this->in($this->Last(4, 1), 'нст')) - { + if ($this->Last(3) == 'тин' and $this->in($this->Last(4, 1), 'нст')) { $first += 0.5; } //Исключения if ($this->inNames($namepart, array('Лев', 'Яков', 'Вова', 'Маша', 'Ольга', 'Еремей', - 'Исак', 'Исаак', 'Ева', 'Ирина', 'Элькин', 'Мерлин', 'Макс', 'Алекс', - 'Мариа'/*Альфонс Мариа Муха*/, - 'Бриджет', 'Элизабет', 'Маргарет', 'Джанет', 'Жаклин', 'Эвелин'/*женские иностранные*/)) - || $this->inNames($namepart, $this->names_man) - ) - { - $first+=10; + 'Исак', 'Исаак', 'Ева', 'Ирина', 'Элькин', 'Мерлин', 'Макс', 'Алекс', + 'Мариа'/*Альфонс Мариа Муха*/, + 'Бриджет', 'Элизабет', 'Маргарет', 'Джанет', 'Жаклин', 'Эвелин'/*женские иностранные*/)) + || $this->inNames($namepart, $this->names_man) + ) { + $first += 10; } - /** * Фамилии которые заканчиваются на -ли кроме тех что типа натАли и.т.д. */ - if ($this->Last(2) == 'ли' and $this->Last(3, 1) != 'а') - { - $second+=0.4; + if ($this->Last(2) == 'ли' and $this->Last(3, 1) != 'а') { + $second += 0.4; } /** * Фамилии на -як кроме тех что типа Касьян Куприян + Ян и.т.д. */ - if ($this->Last(2) == 'ян' and $length > 2 and !$this->in($this->Last(3, 1), 'ьи')) - { - $second+=0.4; + if ($this->Last(2) == 'ян' and $length > 2 and !$this->in($this->Last(3, 1), 'ьи')) { + $second += 0.4; } /** * Фамилии на -ур кроме имен Артур Тимур */ - if ($this->Last(2) == 'ур') - { - if (!$this->inNames($namepart, array('Артур', 'Тимур'))) - { + if ($this->Last(2) == 'ур') { + if (!$this->inNames($namepart, array('Артур', 'Тимур'))) { $second += 0.4; } } @@ -883,17 +763,13 @@ protected function detectNamePart(NCLNameCaseWord $word) /** * Разбор ласкательных имен на -ик */ - if ($this->Last(2) == 'ик') - { + if ($this->Last(2) == 'ик') { /** * Ласкательные буквы перед ик */ - if ($this->in($this->Last(3, 1), 'лшхд')) - { + if ($this->in($this->Last(3, 1), 'лшхд')) { $first += 0.3; - } - else - { + } else { $second += 0.4; } } @@ -901,27 +777,21 @@ protected function detectNamePart(NCLNameCaseWord $word) /** * Разбор имен и фамилий, который заканчиваются на ина */ - if ($this->Last(3) == 'ина') - { + if ($this->Last(3) == 'ина') { /** * Все похожие на Катерина и Кристина */ - if ($this->in($this->Last(7), array('атерина', 'ристина'))) - { - $first+=10; - } - /** + if ($this->in($this->Last(7), array('атерина', 'ристина'))) { + $first += 10; + } /** * Исключения */ - elseif ($this->inNames($namepart, array('Мальвина', 'Антонина', 'Альбина', 'Агриппина', 'Фаина', 'Карина', 'Марина', 'Валентина', 'Калина', 'Аделина', 'Алина', 'Ангелина', 'Галина', 'Каролина', 'Павлина', 'Полина', 'Элина', 'Мина', 'Нина', 'Дина'))) - { - $first+=10; - } - /** + elseif ($this->inNames($namepart, array('Мальвина', 'Антонина', 'Альбина', 'Агриппина', 'Фаина', 'Карина', 'Марина', 'Валентина', 'Калина', 'Аделина', 'Алина', 'Ангелина', 'Галина', 'Каролина', 'Павлина', 'Полина', 'Элина', 'Мина', 'Нина', 'Дина'))) { + $first += 10; + } /** * Иначе фамилия */ - else - { + else { $second += 0.4; } } @@ -929,47 +799,38 @@ protected function detectNamePart(NCLNameCaseWord $word) /** * Имена типа Николай */ - if ($this->Last(4) == 'олай') - { + if ($this->Last(4) == 'олай') { $first += 0.6; } /** * Фамильные окончания */ - if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'ёв', 'ый', 'ын', 'ой', 'ук', 'як', 'ца', 'ун', 'ок', 'ая', 'ёк', 'ив', 'ус', 'ак', 'яр', 'уз', 'ах', 'ай'))) - { - $second+=0.4; + if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'ёв', 'ый', 'ын', 'ой', 'ук', 'як', 'ца', 'ун', 'ок', 'ая', 'ёк', 'ив', 'ус', 'ак', 'яр', 'уз', 'ах', 'ай'))) { + $second += 0.4; } - if ($this->in($this->Last(3), array('ова', 'ева', 'ёва', 'ына', 'шен', 'мей', 'вка', 'шир', 'бан', 'чий', 'кий', 'бей', 'чан', 'ган', 'ким', 'кан', 'мар', 'лис'))) - { - $second+=0.4; + if ($this->in($this->Last(3), array('ова', 'ева', 'ёва', 'ына', 'шен', 'мей', 'вка', 'шир', 'бан', 'чий', 'кий', 'бей', 'чан', 'ган', 'ким', 'кан', 'мар', 'лис'))) { + $second += 0.4; } - if ($this->in($this->Last(4), array('шена'))) - { - $second+=0.4; + if ($this->in($this->Last(4), array('шена'))) { + $second += 0.4; } - //исключения и частички - if ($this->inNames($namepart, array('да', 'валадон', 'Данбар'))){ - $second += 10; - } + //исключения и частички + if ($this->inNames($namepart, array('да', 'валадон', 'Данбар'))) { + $second += 10; + } $max = max(array($first, $second, $father)); - if ($first == $max) - { + if ($first == $max) { $word->setNamePart('N'); - } - elseif ($second == $max) - { + } elseif ($second == $max) { $word->setNamePart('S'); - } - else - { + } else { $word->setNamePart('F'); } } diff --git a/Library/NCLNameCaseUa.php b/Library/NCLNameCaseUa.php index 4a4dcd3..387d459 100644 --- a/Library/NCLNameCaseUa.php +++ b/Library/NCLNameCaseUa.php @@ -4,18 +4,23 @@ * @license Dual licensed under the MIT or GPL Version 2 licenses. * @package NameCaseLib */ + /** - * + * */ -require_once dirname(__FILE__) . '/NCL/NCLNameCaseCore.php'; + +namespace seagullua\NameCaseLib; + +use seagullua\NameCaseLib\NCL\NCLNameCaseCore; +use seagullua\NameCaseLib\NCL\NCLNameCaseWord; /** * NCL NameCase Ukranian Language - * - * Украинские правила склонений ФИО. + * + * Украинские правила склонений ФИО. * Правила определения пола человека по ФИО для украинского языка - * Система разделения фамилий имен и отчеств для украинского языка - * + * Система разделения фамилий имен и отчеств для украинского языка + * * @author Андрей Чайка * @version 0.4.1 * @package NameCaseLib @@ -25,7 +30,7 @@ class NCLNameCaseUa extends NCLNameCaseCore /** * Версия языкового файла - * @var string + * @var string */ protected $languageBuild = '11071222'; /** @@ -35,32 +40,32 @@ class NCLNameCaseUa extends NCLNameCaseCore protected $CaseCount = 7; /** * Список гласных украинского языка - * @var string + * @var string */ private $vowels = 'аеиоуіїєюя'; /** * Список согласных украинского языка - * @var string + * @var string */ private $consonant = "бвгджзйклмнпрстфхцчшщ"; /** - * Українські шиплячі приголосні - * @var string + * Українські шиплячі приголосні + * @var string */ private $shyplyachi = "жчшщ"; /** * Українські нешиплячі приголосні - * @var string + * @var string */ private $neshyplyachi = "бвгдзклмнпрстфхц"; /** * Українські завжди м’які звуки - * @var string + * @var string */ private $myaki = 'ьюяєї'; /** * Українські губні звуки - * @var string + * @var string */ private $gubni = 'мвпбф'; @@ -72,11 +77,13 @@ class NCLNameCaseUa extends NCLNameCaseCore */ private function inverseGKH($letter) { - switch ($letter) - { - case 'г': return 'з'; - case 'к': return 'ц'; - case 'х': return 'с'; + switch ($letter) { + case 'г': + return 'з'; + case 'к': + return 'ц'; + case 'х': + return 'с'; } return $letter; } @@ -84,12 +91,11 @@ private function inverseGKH($letter) /** * Перевіряє чи символ є апострофом чи не є * @param string(1) $char симпол для перевірки - * @return bool true якщо символ є апострофом + * @return bool true якщо символ є апострофом */ private function isApostrof($char) { - if ($this->in($char, ' ' . $this->consonant . $this->vowels)) - { + if ($this->in($char, ' ' . $this->consonant . $this->vowels)) { return false; } return true; @@ -99,14 +105,15 @@ private function isApostrof($char) * Чергування українських приголосних * Чергування г к —» ж ч * @param string $letter літера, яку необхідно перевірити на чергування - * @return string літера, де вже відбулося чергування + * @return string літера, де вже відбулося чергування */ private function inverse2($letter) { - switch ($letter) - { - case 'к': return 'ч'; - case 'г': return 'ж'; + switch ($letter) { + case 'к': + return 'ч'; + case 'г': + return 'ж'; } return $letter; } @@ -116,46 +123,39 @@ private function inverse2($letter) * 1 - тверда * 2 - мішана * 3 - м’яка - * + * * Правило: - * - Іменники з основою на твердий нешиплячий належать до твердої групи: + * - Іменники з основою на твердий нешиплячий належать до твердої групи: * береза, дорога, Дніпро, шлях, віз, село, яблуко. - * - Іменники з основою на твердий шиплячий належать до мішаної групи: + * - Іменники з основою на твердий шиплячий належать до мішаної групи: * пожеж-а, пущ-а, тиш-а, алич-а, вуж, кущ, плющ, ключ, плече, прізвище. - * - Іменники з основою на будь-який м'який чи пом'якше­ний належать до м'якої групи: - * земля [земл'а], зоря [зор'а], армія [арм'ійа], сім'я [с'імйа], серпень, фахівець, + * - Іменники з основою на будь-який м'який чи пом'якше­ний належать до м'якої групи: + * земля [земл'а], зоря [зор'а], армія [арм'ійа], сім'я [с'імйа], серпень, фахівець, * трамвай, су­зір'я [суз'ірйа], насіння [насін'н'а], узвишшя Іузвиш'ш'а * @param string $word іменник, групу якого необхідно визначити - * @return int номер групи іменника + * @return int номер групи іменника */ private function detect2Group($word) { $osnova = $word; $stack = array(); //Ріжемо слово поки не зустрінемо приголосний і записуемо в стек всі голосні які зустріли - while ($this->in(NCLStr::substr($osnova, -1, 1), $this->vowels . 'ь')) - { + while ($this->in(NCLStr::substr($osnova, -1, 1), $this->vowels . 'ь')) { $stack[] = NCLStr::substr($osnova, -1, 1); $osnova = NCLStr::substr($osnova, 0, NCLStr::strlen($osnova) - 1); } $stacksize = count($stack); $Last = 'Z'; //нульове закінчення - if ($stacksize) - { + if ($stacksize) { $Last = $stack[count($stack) - 1]; } $osnovaEnd = NCLStr::substr($osnova, -1, 1); - if ($this->in($osnovaEnd, $this->neshyplyachi) and !$this->in($Last, $this->myaki)) - { + if ($this->in($osnovaEnd, $this->neshyplyachi) and !$this->in($Last, $this->myaki)) { return 1; - } - elseif ($this->in($osnovaEnd, $this->shyplyachi) and !$this->in($Last, $this->myaki)) - { + } elseif ($this->in($osnovaEnd, $this->shyplyachi) and !$this->in($Last, $this->myaki)) { return 2; - } - else - { + } else { return 3; } } @@ -169,11 +169,9 @@ private function detect2Group($word) private function FirstLastVowel($word, $vowels) { $length = NCLStr::strlen($word); - for ($i = $length - 1; $i > 0; $i--) - { + for ($i = $length - 1; $i > 0; $i--) { $char = NCLStr::substr($word, $i, 1); - if ($this->in($char, $vowels)) - { + if ($this->in($char, $vowels)) { return $char; } } @@ -189,8 +187,7 @@ private function getOsnova($word) { $osnova = $word; //Ріжемо слово поки не зустрінемо приголосний - while ($this->in(NCLStr::substr($osnova, -1, 1), $this->vowels . 'ь')) - { + while ($this->in(NCLStr::substr($osnova, -1, 1), $this->vowels . 'ь')) { $osnova = NCLStr::substr($osnova, 0, NCLStr::strlen($osnova) - 1); } return $osnova; @@ -200,10 +197,10 @@ private function getOsnova($word) * Українські чоловічі та жіночі імена, що в називному відмінку однини закінчуються на -а (-я), * відмінються як відповідні іменники І відміни. *
    - *
  • Примітка 1. Кінцеві приголосні основи г, к, х у жіночих іменах - * у давальному та місцевому відмінках однини перед закінченням -і + *
  • Примітка 1. Кінцеві приголосні основи г, к, х у жіночих іменах + * у давальному та місцевому відмінках однини перед закінченням -і * змінюються на з, ц, с: Ольга - Ользі, Палажка - Палажці, Солоха - Солосі.
  • - *
  • Примітка 2. У жіночих іменах типу Одарка, Параска в родовому відмінку множини + *
  • Примітка 2. У жіночих іменах типу Одарка, Параска в родовому відмінку множини * в кінці основи між приголосними з'являється звук о: Одарок, Парасок.
  • *
* @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено @@ -214,24 +211,18 @@ protected function manRule1() $BeforeLast = $this->Last(2, 1); //Останні літера або а - if ($this->Last(1) == 'а') - { + if ($this->Last(1) == 'а') { $this->wordForms($this->workingWord, array($BeforeLast . 'и', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'у', $BeforeLast . 'ою', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'о'), 2); $this->Rule(101); return true; - } - //Остання літера я - elseif ($this->Last(1) == 'я') - { + } //Остання літера я + elseif ($this->Last(1) == 'я') { //Перед останньою літерою стоїть я - if ($BeforeLast == 'і') - { + if ($BeforeLast == 'і') { $this->wordForms($this->workingWord, array('ї', 'ї', 'ю', 'єю', 'ї', 'є'), 1); $this->Rule(102); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array($BeforeLast . 'і', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'ю', $BeforeLast . 'ею', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'е'), 2); $this->Rule(103); return true; @@ -241,25 +232,20 @@ protected function manRule1() } /** - * Імена, що в називному відмінку закінчуються на -р, у родовому мають закінчення -а: + * Імена, що в називному відмінку закінчуються на -р, у родовому мають закінчення -а: * Віктор - Віктора, Макар - Макара, але: Ігор - Ігоря, Лазар - Лазаря. * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function manRule2() { - if ($this->Last(1) == 'р') - { - if ($this->inNames($this->workingWord, array('Ігор', 'Лазар'))) - { + if ($this->Last(1) == 'р') { + if ($this->inNames($this->workingWord, array('Ігор', 'Лазар'))) { $this->wordForms($this->workingWord, array('я', 'еві', 'я', 'ем', 'еві', 'е')); $this->Rule(201); return true; - } - else - { + } else { $osnova = $this->workingWord; - if (NCLStr::substr($osnova, -2, 1) == 'і') - { + if (NCLStr::substr($osnova, -2, 1) == 'і') { $osnova = NCLStr::substr($osnova, 0, NCLStr::strlen($osnova) - 2) . 'о' . NCLStr::substr($osnova, -1, 1); } $this->wordForms($osnova, array('а', 'ові', 'а', 'ом', 'ові', 'е')); @@ -271,115 +257,91 @@ protected function manRule2() } /** - * Українські чоловічі імена, що в називному відмінку однини закінчуються на приголосний та -о, + * Українські чоловічі імена, що в називному відмінку однини закінчуються на приголосний та -о, * відмінюються як відповідні іменники ІІ відміни. - * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено + * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function manRule3() { //Предпоследний символ $BeforeLast = $this->Last(2, 1); - if ($this->in($this->Last(1), $this->consonant . 'оь')) - { + if ($this->in($this->Last(1), $this->consonant . 'оь')) { $group = $this->detect2Group($this->workingWord); $osnova = $this->getOsnova($this->workingWord); //В іменах типу Антін, Нестір, Нечипір, Прокіп, Сидір, Тиміш, Федір голосний і виступає тільки в //називному відмінку, у непрямих - о: Антона, Антонові //Чергування і -» о всередині $osLast = NCLStr::substr($osnova, -1, 1); - if ($osLast != 'й' and NCLStr::substr($osnova, -2, 1) == 'і' and !$this->in(NCLStr::substr(NCLStr::strtolower($osnova), -4, 4), array('світ', 'цвіт')) and !$this->inNames($this->workingWord, 'Гліб') and !$this->in($this->Last(2), array('ік', 'іч'))) - { + if ($osLast != 'й' and NCLStr::substr($osnova, -2, 1) == 'і' and !$this->in(NCLStr::substr(NCLStr::strtolower($osnova), -4, 4), array('світ', 'цвіт')) and !$this->inNames($this->workingWord, 'Гліб') and !$this->in($this->Last(2), array('ік', 'іч'))) { $osnova = NCLStr::substr($osnova, 0, NCLStr::strlen($osnova) - 2) . 'о' . NCLStr::substr($osnova, -1, 1); } //Випадання букви е при відмінюванні слів типу Орел - if (NCLStr::substr($osnova, 0, 1) == 'о' and $this->FirstLastVowel($osnova, $this->vowels . 'гк') == 'е' and $this->Last(2) != 'сь') - { + if (NCLStr::substr($osnova, 0, 1) == 'о' and $this->FirstLastVowel($osnova, $this->vowels . 'гк') == 'е' and $this->Last(2) != 'сь') { $delim = NCLStr::strrpos($osnova, 'е'); $osnova = NCLStr::substr($osnova, 0, $delim) . NCLStr::substr($osnova, $delim + 1, NCLStr::strlen($osnova) - $delim); } - if ($group == 1) - { + if ($group == 1) { //Тверда група //Слова що закінчуються на ок - if ($this->Last(2) == 'ок' and $this->Last(3) != 'оок') - { + if ($this->Last(2) == 'ок' and $this->Last(3) != 'оок') { $this->wordForms($this->workingWord, array('ка', 'кові', 'ка', 'ком', 'кові', 'че'), 2); $this->Rule(301); return true; - } - //Російські прізвища на ов, ев, єв - elseif ($this->in($this->Last(2), array('ов', 'ев', 'єв')) and !$this->inNames($this->workingWord, array('Лев', 'Остромов'))) - { + } //Російські прізвища на ов, ев, єв + elseif ($this->in($this->Last(2), array('ов', 'ев', 'єв')) and !$this->inNames($this->workingWord, array('Лев', 'Остромов'))) { $this->wordForms($osnova, array($osLast . 'а', $osLast . 'у', $osLast . 'а', $osLast . 'им', $osLast . 'у', $this->inverse2($osLast) . 'е'), 1); $this->Rule(302); return true; - } - //Російські прізвища на ін - elseif ($this->in($this->Last(2), array('ін'))) - { + } //Російські прізвища на ін + elseif ($this->in($this->Last(2), array('ін'))) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'у', 'е')); $this->Rule(303); return true; - } - else - { + } else { $this->wordForms($osnova, array($osLast . 'а', $osLast . 'ові', $osLast . 'а', $osLast . 'ом', $osLast . 'ові', $this->inverse2($osLast) . 'е'), 1); $this->Rule(304); return true; } } - if ($group == 2) - { + if ($group == 2) { //Мішана група $this->wordForms($osnova, array('а', 'еві', 'а', 'ем', 'еві', 'е')); $this->Rule(305); return true; } - if ($group == 3) - { + if ($group == 3) { //М’яка група //Соловей - if ($this->Last(2) == 'ей' and $this->in($this->Last(3, 1), $this->gubni)) - { + if ($this->Last(2) == 'ей' and $this->in($this->Last(3, 1), $this->gubni)) { $osnova = NCLStr::substr($this->workingWord, 0, NCLStr::strlen($this->workingWord) - 2) . '’'; $this->wordForms($osnova, array('я', 'єві', 'я', 'єм', 'єві', 'ю')); $this->Rule(306); return true; - } - elseif ($this->Last(1) == 'й' or $BeforeLast == 'і') - { + } elseif ($this->Last(1) == 'й' or $BeforeLast == 'і') { $this->wordForms($this->workingWord, array('я', 'єві', 'я', 'єм', 'єві', 'ю'), 1); $this->Rule(307); return true; - } - //Швець - elseif ($this->workingWord == 'швець') - { + } //Швець + elseif ($this->workingWord == 'швець') { $this->wordForms($this->workingWord, array('евця', 'евцеві', 'евця', 'евцем', 'евцеві', 'евцю'), 4); $this->Rule(308); return true; - } - //Слова що закінчуються на ець - elseif ($this->Last(3) == 'ець') - { + } //Слова що закінчуються на ець + elseif ($this->Last(3) == 'ець') { $this->wordForms($this->workingWord, array('ця', 'цеві', 'ця', 'цем', 'цеві', 'цю'), 3); $this->Rule(309); return true; - } - //Слова що закінчуються на єць яць - elseif ($this->in($this->Last(3), array('єць', 'яць'))) - { + } //Слова що закінчуються на єць яць + elseif ($this->in($this->Last(3), array('єць', 'яць'))) { $this->wordForms($this->workingWord, array('йця', 'йцеві', 'йця', 'йцем', 'йцеві', 'йцю'), 3); $this->Rule(310); return true; - } - else - { + } else { $this->wordForms($osnova, array('я', 'еві', 'я', 'ем', 'еві', 'ю')); $this->Rule(311); return true; @@ -395,8 +357,7 @@ protected function manRule3() */ protected function manRule4() { - if ($this->Last(1) == 'і') - { + if ($this->Last(1) == 'і') { $this->wordForms($this->workingWord, array('их', 'им', 'их', 'ими', 'их', 'і'), 1); $this->Rule(4); return true; @@ -406,12 +367,11 @@ protected function manRule4() /** * Якщо слово закінчується на ий або ой - * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено + * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function manRule5() { - if ($this->in($this->Last(2), array('ий', 'ой'))) - { + if ($this->in($this->Last(2), array('ий', 'ой'))) { $this->wordForms($this->workingWord, array('ого', 'ому', 'ого', 'им', 'ому', 'ий'), 2); $this->Rule(5); return true; @@ -420,14 +380,14 @@ protected function manRule5() } /** - * Українські чоловічі та жіночі імена, що в називному відмінку однини закінчуються на -а (-я), - * відмінються як відповідні іменники І відміни. - * - Примітка 1. Кінцеві приголосні основи г, к, х у жіночих іменах - * у давальному та місцевому відмінках однини перед закінченням -і + * Українські чоловічі та жіночі імена, що в називному відмінку однини закінчуються на -а (-я), + * відмінються як відповідні іменники І відміни. + * - Примітка 1. Кінцеві приголосні основи г, к, х у жіночих іменах + * у давальному та місцевому відмінках однини перед закінченням -і * змінюються на з, ц, с: Ольга - Ользі, Палажка - Палажці, Солоха - Солосі. - * - Примітка 2. У жіночих іменах типу Одарка, Параска в родовому відмінку множини - * в кінці основи між приголосними з'являється звук о: Одарок, Парасок - * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено + * - Примітка 2. У жіночих іменах типу Одарка, Параска в родовому відмінку множини + * в кінці основи між приголосними з'являється звук о: Одарок, Парасок + * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function womanRule1() { @@ -435,33 +395,24 @@ protected function womanRule1() $BeforeLast = $this->Last(2, 1); //Якщо закінчується на ніга -» нога - if ($this->Last(4) == 'ніга') - { + if ($this->Last(4) == 'ніга') { $osnova = NCLStr::substr($this->workingWord, 0, NCLStr::strlen($this->workingWord) - 3) . 'о'; $this->wordForms($osnova, array('ги', 'зі', 'гу', 'гою', 'зі', 'го')); $this->Rule(101); return true; - } - - //Останні літера або а - elseif ($this->Last(1) == 'а') - { + } //Останні літера або а + elseif ($this->Last(1) == 'а') { $this->wordForms($this->workingWord, array($BeforeLast . 'и', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'у', $BeforeLast . 'ою', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'о'), 2); $this->Rule(102); return true; - } - //Остання літера я - elseif ($this->Last(1) == 'я') - { + } //Остання літера я + elseif ($this->Last(1) == 'я') { - if ($this->in($BeforeLast, $this->vowels) or $this->isApostrof($BeforeLast)) - { + if ($this->in($BeforeLast, $this->vowels) or $this->isApostrof($BeforeLast)) { $this->wordForms($this->workingWord, array('ї', 'ї', 'ю', 'єю', 'ї', 'є'), 1); $this->Rule(103); return true; - } - else - { + } else { $this->wordForms($this->workingWord, array($BeforeLast . 'і', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'ю', $BeforeLast . 'ею', $this->inverseGKH($BeforeLast) . 'і', $BeforeLast . 'е'), 2); $this->Rule(104); return true; @@ -471,14 +422,13 @@ protected function womanRule1() } /** - * Українські жіночі імена, що в називному відмінку однини закінчуються на приголосний, + * Українські жіночі імена, що в називному відмінку однини закінчуються на приголосний, * відмінюються як відповідні іменники ІІІ відміни - * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено + * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function womanRule2() { - if ($this->in($this->Last(1), $this->consonant . 'ь')) - { + if ($this->in($this->Last(1), $this->consonant . 'ь')) { $osnova = $this->getOsnova($this->workingWord); $apostrof = ''; $duplicate = ''; @@ -486,27 +436,22 @@ protected function womanRule2() $osBeforeLast = NCLStr::substr($osnova, -2, 1); //Чи треба ставити апостроф - if ($this->in($osLast, 'мвпбф') and ($this->in($osBeforeLast, $this->vowels))) - { + if ($this->in($osLast, 'мвпбф') and ($this->in($osBeforeLast, $this->vowels))) { $apostrof = '’'; } //Чи треба подвоювати - if ($this->in($osLast, 'дтзсцлн')) - { + if ($this->in($osLast, 'дтзсцлн')) { $duplicate = $osLast; } //Відмінюємо - if ($this->Last(1) == 'ь') - { + if ($this->Last(1) == 'ь') { $this->wordForms($osnova, array('і', 'і', 'ь', $duplicate . $apostrof . 'ю', 'і', 'е')); $this->Rule(201); return true; - } - else - { + } else { $this->wordForms($osnova, array('і', 'і', '', $duplicate . $apostrof . 'ю', 'і', 'е')); $this->Rule(202); return true; @@ -517,7 +462,7 @@ protected function womanRule2() /** * Якщо слово на ськ або це російське прізвище - * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено + * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function womanRule3() { @@ -525,16 +470,14 @@ protected function womanRule3() $BeforeLast = $this->Last(2, 1); //Донская - if ($this->Last(2) == 'ая') - { + if ($this->Last(2) == 'ая') { $this->wordForms($this->workingWord, array('ої', 'ій', 'ую', 'ою', 'ій', 'ая'), 2); $this->Rule(301); return true; } //Ті що на ськ - if ($this->Last(1) == 'а' and ($this->in($this->Last(2, 1), 'чнв') or $this->in($this->Last(3, 2), array('ьк')))) - { + if ($this->Last(1) == 'а' and ($this->in($this->Last(2, 1), 'чнв') or $this->in($this->Last(3, 2), array('ьк')))) { $this->wordForms($this->workingWord, array($BeforeLast . 'ої', $BeforeLast . 'ій', $BeforeLast . 'у', $BeforeLast . 'ою', $BeforeLast . 'ій', $BeforeLast . 'о'), 2); $this->Rule(302); return true; @@ -585,8 +528,7 @@ protected function womanSecondName() */ protected function manFatherName() { - if ($this->in($this->Last(2), array('ич', 'іч'))) - { + if ($this->in($this->Last(2), array('ич', 'іч'))) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ем', 'у', 'у')); return true; } @@ -599,8 +541,7 @@ protected function manFatherName() */ protected function womanFatherName() { - if ($this->in($this->Last(3), array('вна'))) - { + if ($this->in($this->Last(3), array('вна'))) { $this->wordForms($this->workingWord, array('и', 'і', 'у', 'ою', 'і', 'о'), 1); return true; } @@ -619,44 +560,36 @@ protected function GenderByFirstName(NCLNameCaseWord $word) $woman = 0; //Женщина //Попробуем выжать максимум из имени //Если имя заканчивается на й, то скорее всего мужчина - if ($this->Last(1) == 'й') - { - $man+=0.9; + if ($this->Last(1) == 'й') { + $man += 0.9; } - if ($this->inNames($this->workingWord, array('Петро', 'Микола'))) - { - $man+=30; + if ($this->inNames($this->workingWord, array('Петро', 'Микола'))) { + $man += 30; } - if ($this->in($this->Last(2), array('он', 'ов', 'ав', 'ам', 'ол', 'ан', 'рд', 'мп', 'ко', 'ло'))) - { - $man+=0.5; + if ($this->in($this->Last(2), array('он', 'ов', 'ав', 'ам', 'ол', 'ан', 'рд', 'мп', 'ко', 'ло'))) { + $man += 0.5; } - if ($this->in($this->Last(3), array('бов', 'нка', 'яра', 'ила', 'опа'))) - { - $woman+=0.5; + if ($this->in($this->Last(3), array('бов', 'нка', 'яра', 'ила', 'опа'))) { + $woman += 0.5; } - if ($this->in($this->Last(1), $this->consonant)) - { - $man+=0.01; + if ($this->in($this->Last(1), $this->consonant)) { + $man += 0.01; } - if ($this->Last(1) == 'ь') - { - $man+=0.02; + if ($this->Last(1) == 'ь') { + $man += 0.02; } - if ($this->in($this->Last(2), array('дь'))) - { - $woman+=0.1; + if ($this->in($this->Last(2), array('дь'))) { + $woman += 0.1; } - if ($this->in($this->Last(3), array('ель', 'бов'))) - { - $woman+=0.4; + if ($this->in($this->Last(3), array('ель', 'бов'))) { + $woman += 0.4; } $word->setGender($man, $woman); @@ -673,19 +606,16 @@ protected function GenderBySecondName(NCLNameCaseWord $word) $man = 0; //Мужчина $woman = 0; //Женщина - if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'єв', 'ін', 'їн', 'ий', 'їв', 'ів', 'ой', 'ей'))) - { - $man+=0.4; + if ($this->in($this->Last(2), array('ов', 'ин', 'ев', 'єв', 'ін', 'їн', 'ий', 'їв', 'ів', 'ой', 'ей'))) { + $man += 0.4; } - if ($this->in($this->Last(3), array('ова', 'ина', 'ева', 'єва', 'іна', 'мін'))) - { - $woman+=0.4; + if ($this->in($this->Last(3), array('ова', 'ина', 'ева', 'єва', 'іна', 'мін'))) { + $woman += 0.4; } - if ($this->in($this->Last(2), array('ая'))) - { - $woman+=0.4; + if ($this->in($this->Last(2), array('ая'))) { + $woman += 0.4; } $word->setGender($man, $woman); @@ -699,12 +629,10 @@ protected function GenderByFatherName(NCLNameCaseWord $word) { $this->setWorkingWord($word->getWord()); - if ($this->Last(2) == 'ич') - { + if ($this->Last(2) == 'ич') { $word->setGender(10, 0); // мужчина } - if ($this->Last(2) == 'на') - { + if ($this->Last(2) == 'на') { $word->setGender(0, 12); // женщина } } @@ -727,56 +655,44 @@ protected function detectNamePart(NCLNameCaseWord $word) $father = 0; //если смахивает на отчество - if ($this->in($this->Last(3), array('вна', 'чна', 'ліч')) or $this->in($this->Last(4), array('ьмич', 'ович'))) - { - $father+=3; + if ($this->in($this->Last(3), array('вна', 'чна', 'ліч')) or $this->in($this->Last(4), array('ьмич', 'ович'))) { + $father += 3; } //Похоже на имя - if ($this->in($this->Last(3), array('тин' /* {endings_sirname3} */)) or $this->in($this->Last(4), array('ьмич', 'юбов', 'івна', 'явка', 'орив', 'кіян' /* {endings_sirname4} */))) - { - $first+=0.5; + if ($this->in($this->Last(3), array('тин' /* {endings_sirname3} */)) or $this->in($this->Last(4), array('ьмич', 'юбов', 'івна', 'явка', 'орив', 'кіян' /* {endings_sirname4} */))) { + $first += 0.5; } //Исключения - if ($this->inNames($namepart, array('Лев', 'Гаїна', 'Афіна', 'Антоніна', 'Ангеліна', 'Альвіна', 'Альбіна', 'Аліна', 'Павло', 'Олесь', 'Микола', 'Мая', 'Англеліна', 'Елькін', 'Мерлін'))) - { - $first+=10; + if ($this->inNames($namepart, array('Лев', 'Гаїна', 'Афіна', 'Антоніна', 'Ангеліна', 'Альвіна', 'Альбіна', 'Аліна', 'Павло', 'Олесь', 'Микола', 'Мая', 'Англеліна', 'Елькін', 'Мерлін'))) { + $first += 10; } //похоже на фамилию - if ($this->in($this->Last(2), array('ов', 'ін', 'ев', 'єв', 'ий', 'ин', 'ой', 'ко', 'ук', 'як', 'ца', 'их', 'ик', 'ун', 'ок', 'ша', 'ая', 'га', 'єк', 'аш', 'ив', 'юк', 'ус', 'це', 'ак', 'бр', 'яр', 'іл', 'ів', 'ич', 'сь', 'ей', 'нс', 'яс', 'ер', 'ай', 'ян', 'ах', 'ць', 'ющ', 'іс', 'ач', 'уб', 'ох', 'юх', 'ут', 'ча', 'ул', 'вк', 'зь', 'уц', 'їн', 'де', 'уз', 'юр', 'ік', 'іч', 'ро' /* {endings_name2} */))) - { - $second+=0.4; + if ($this->in($this->Last(2), array('ов', 'ін', 'ев', 'єв', 'ий', 'ин', 'ой', 'ко', 'ук', 'як', 'ца', 'их', 'ик', 'ун', 'ок', 'ша', 'ая', 'га', 'єк', 'аш', 'ив', 'юк', 'ус', 'це', 'ак', 'бр', 'яр', 'іл', 'ів', 'ич', 'сь', 'ей', 'нс', 'яс', 'ер', 'ай', 'ян', 'ах', 'ць', 'ющ', 'іс', 'ач', 'уб', 'ох', 'юх', 'ут', 'ча', 'ул', 'вк', 'зь', 'уц', 'їн', 'де', 'уз', 'юр', 'ік', 'іч', 'ро' /* {endings_name2} */))) { + $second += 0.4; } - if ($this->in($this->Last(3), array('ова', 'ева', 'єва', 'тих', 'рик', 'вач', 'аха', 'шен', 'мей', 'арь', 'вка', 'шир', 'бан', 'чий', 'іна', 'їна', 'ька', 'ань', 'ива', 'аль', 'ура', 'ран', 'ало', 'ола', 'кур', 'оба', 'оль', 'нта', 'зій', 'ґан', 'іло', 'шта', 'юпа', 'рна', 'бла', 'еїн', 'има', 'мар', 'кар', 'оха', 'чур', 'ниш', 'ета', 'тна', 'зур', 'нір', 'йма', 'орж', 'рба', 'іла', 'лас', 'дід', 'роз', 'аба', 'чан', 'ган' /* {endings_name3} */))) - { - $second+=0.4; + if ($this->in($this->Last(3), array('ова', 'ева', 'єва', 'тих', 'рик', 'вач', 'аха', 'шен', 'мей', 'арь', 'вка', 'шир', 'бан', 'чий', 'іна', 'їна', 'ька', 'ань', 'ива', 'аль', 'ура', 'ран', 'ало', 'ола', 'кур', 'оба', 'оль', 'нта', 'зій', 'ґан', 'іло', 'шта', 'юпа', 'рна', 'бла', 'еїн', 'има', 'мар', 'кар', 'оха', 'чур', 'ниш', 'ета', 'тна', 'зур', 'нір', 'йма', 'орж', 'рба', 'іла', 'лас', 'дід', 'роз', 'аба', 'чан', 'ган' /* {endings_name3} */))) { + $second += 0.4; } - if ($this->in($this->Last(4), array('ьник', 'нчук', 'тник', 'кирь', 'ский', 'шена', 'шина', 'вина', 'нина', 'гана', 'гана', 'хній', 'зюба', 'орош', 'орон', 'сило', 'руба', 'лест', 'мара', 'обка', 'рока', 'сика', 'одна', 'нчар', 'вата', 'ндар', 'грій' /* {endings_name4} */))) - { - $second+=0.4; + if ($this->in($this->Last(4), array('ьник', 'нчук', 'тник', 'кирь', 'ский', 'шена', 'шина', 'вина', 'нина', 'гана', 'гана', 'хній', 'зюба', 'орош', 'орон', 'сило', 'руба', 'лест', 'мара', 'обка', 'рока', 'сика', 'одна', 'нчар', 'вата', 'ндар', 'грій' /* {endings_name4} */))) { + $second += 0.4; } - if ($this->Last(1) == 'і') - { - $second+=0.2; + if ($this->Last(1) == 'і') { + $second += 0.2; } $max = max(array($first, $second, $father)); - if ($first == $max) - { + if ($first == $max) { $word->setNamePart('N'); - } - elseif ($second == $max) - { + } elseif ($second == $max) { $word->setNamePart('S'); - } - else - { + } else { $word->setNamePart('F'); } } diff --git a/README.md b/README.md index df3f888..204e4fb 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ NameCaseLib — библиотека PHP5, предназначенная для - Демонстрация работы - http://namecaselib.com/case/ - Документация - http://namecaselib.com/book/ +## 0.4.2 (2023-12-28) (@nazbav) +- Delete includes +- Add PSR-4 support + ## 0.4.1 (2016-11-23) - Rules updates (5 years of work) - Any pull requests with the new rules updates will be merged now diff --git a/Tests/Library/NCLNameCaseRuTestFatherboy.php b/Tests/Library/NCLNameCaseRuTestFatherboy.php index f864f89..35f6b4c 100644 --- a/Tests/Library/NCLNameCaseRuTestFatherboy.php +++ b/Tests/Library/NCLNameCaseRuTestFatherboy.php @@ -1,6 +1,6 @@ qSecondName("Иванов")); +print_r($nc->qFirstName("Андрей")); +print_r($nc->qFatherName("Алексеевич")); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e6d8c4b --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "nazbav/name-case-lib", + "description": "NameCaseLib — библиотека PHP5, предназначенная для автоматического склонения ФИО в русском и украинском языках. Уникальная особенность состоит в том, что библиотека содержит одинаковые методы для работы с ФИО на русском и украинском языках.", + "minimum-stability": "stable", + "license": "MIT", + "varsion": "0.4.2", + "authors": [ + { + "name": "Andriy Chaika", + "email": "andriy@chaika.in.ua" + }, + { + "name": "Rabotyahoff", + "homepage": "https://github.com/Rabotyahoff" + } + ], + "autoload": { + "psr-4": { + "seagullua\\NameCaseLib\\": "Library/" + } + }, + "require": { + "php": ">=5.6" + } +} \ No newline at end of file From cb6b15eb5a7a28cd3147f28ec4f81e478f9e27bf Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Thu, 28 Dec 2023 11:54:31 +0300 Subject: [PATCH 02/17] Update README.md --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 204e4fb..a467de9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,31 @@ NameCaseLib — библиотека PHP5, предназначенная для - Демонстрация работы - http://namecaselib.com/case/ - Документация - http://namecaselib.com/book/ + +Installation +------------ + +### Install With Composer + +The preferred way to install this extension is through [composer](http://getcomposer.org/download/). + +Either run + +``` +composer require nazbav/name-case-lib "dev-master" +``` + +Or, you may add + +``` +"nazbav/name-case-libn": "dev-master" +``` + +to the require section of your `composer.json` file and execute `php composer.phar update`. + +Change Log +------------ + ## 0.4.2 (2023-12-28) (@nazbav) - Delete includes - Add PSR-4 support From 0984f8d1e450ab539e8e2a78670581d9bc8df38f Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Thu, 28 Dec 2023 12:00:21 +0300 Subject: [PATCH 03/17] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a467de9..f48b067 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ composer require nazbav/name-case-lib "dev-master" Or, you may add ``` -"nazbav/name-case-libn": "dev-master" +"nazbav/name-case-lib": "dev-master" ``` to the require section of your `composer.json` file and execute `php composer.phar update`. From 0070dd7183fb8d51ed992aad977e559310eb3168 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Thu, 28 Dec 2023 12:30:40 +0300 Subject: [PATCH 04/17] Update NCLNameCaseRu.php --- Library/NCLNameCaseRu.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/NCLNameCaseRu.php b/Library/NCLNameCaseRu.php index 1553e20..46b2102 100644 --- a/Library/NCLNameCaseRu.php +++ b/Library/NCLNameCaseRu.php @@ -4,6 +4,7 @@ use seagullua\NameCaseLib\NCL\NCLNameCaseCore; use seagullua\NameCaseLib\NCL\NCLNameCaseWord; +use seagullua\NameCaseLib\NCL\NCLStr; /** * @license Dual licensed under the MIT or GPL Version 2 licenses. From be42c740fd4d2f0cd453875e3c5bec1de18cc004 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 01:59:11 +0300 Subject: [PATCH 05/17] Copy fork from https://github.com/seagullua/NameCaseLib/pull/16 --- Library/NCLNameCaseRu.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Library/NCLNameCaseRu.php b/Library/NCLNameCaseRu.php index 46b2102..bc0b25f 100644 --- a/Library/NCLNameCaseRu.php +++ b/Library/NCLNameCaseRu.php @@ -242,6 +242,15 @@ protected function manRule4() protected function manRule5() { if ($this->Last(1) == 'к') { +//copy fork https://github.com/seagullua/NameCaseLib/pull/16 +// https://www.analizfamilii.ru/Gudachek/skloneniye.html + if ($this->in($this->Last(3), 'чек')) { + $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'е')); + $this->Rule(503); + return true; + } + + //Если перед слово на ок, то нужно убрать о if ($this->Last(4) == 'енок' || $this->Last(4) == 'ёнок')//Поллок { @@ -838,4 +847,4 @@ protected function detectNamePart(NCLNameCaseWord $word) } -?> \ No newline at end of file +?> From 7cb035f8b2414efa0be1c611b026cd12413d7fb1 Mon Sep 17 00:00:00 2001 From: Vadym <33205815+vadykoo@users.noreply.github.com> Date: Sat, 17 Feb 2024 01:06:56 +0200 Subject: [PATCH 06/17] Update NCLNameCaseUa.php --- Library/NCLNameCaseUa.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/NCLNameCaseUa.php b/Library/NCLNameCaseUa.php index 387d459..cd28959 100644 --- a/Library/NCLNameCaseUa.php +++ b/Library/NCLNameCaseUa.php @@ -13,6 +13,7 @@ use seagullua\NameCaseLib\NCL\NCLNameCaseCore; use seagullua\NameCaseLib\NCL\NCLNameCaseWord; +use seagullua\NameCaseLib\NCL\NCLStr; /** * NCL NameCase Ukranian Language @@ -699,4 +700,4 @@ protected function detectNamePart(NCLNameCaseWord $word) } -?> \ No newline at end of file +?> From 61b13ca7556854988f1689126a6ffaf7c710239d Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:09:09 +0300 Subject: [PATCH 07/17] Create php.yml --- .github/workflows/php.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..a7d195f --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,39 @@ +name: PHP Composer + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + # - name: Run test suite + # run: composer run-script test From c35bccd707daba8943984064e7f32cd3de3b7ee9 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:17:26 +0300 Subject: [PATCH 08/17] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e6d8c4b..15a0c22 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "minimum-stability": "stable", "license": "MIT", "varsion": "0.4.2", + "type":"library ", "authors": [ { "name": "Andriy Chaika", @@ -22,4 +23,4 @@ "require": { "php": ">=5.6" } -} \ No newline at end of file +} From e51eabb0fd2ba6505fa3b9c4360c98658cadb2a1 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:18:05 +0300 Subject: [PATCH 09/17] Fix typo composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 15a0c22..5b0f727 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "minimum-stability": "stable", "license": "MIT", "varsion": "0.4.2", - "type":"library ", + "type":"library", "authors": [ { "name": "Andriy Chaika", From 28a821f125abbe997a503fec2be7dfa9d9874289 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:20:36 +0300 Subject: [PATCH 10/17] Patch up https://github.com/nazbav/NameCaseLib/pull/1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5b0f727..e27a327 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "NameCaseLib — библиотека PHP5, предназначенная для автоматического склонения ФИО в русском и украинском языках. Уникальная особенность состоит в том, что библиотека содержит одинаковые методы для работы с ФИО на русском и украинском языках.", "minimum-stability": "stable", "license": "MIT", - "varsion": "0.4.2", + "varsion": "0.4.3", "type":"library", "authors": [ { From fd432d2e57549c69a5284a3df8f03a79416ef266 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:24:22 +0300 Subject: [PATCH 11/17] Update README.md add changes --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f48b067..c0490b6 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ to the require section of your `composer.json` file and execute `php composer.ph Change Log ------------ + +## 0.4.3 (2024-02-17) (@vadykoo) +- use NCLStr; for Ukrainian language, the same as for Russian #1 + ## 0.4.2 (2023-12-28) (@nazbav) - Delete includes - Add PSR-4 support From 873add5a84e7ba61b83c8134ccc0c9b394fd8ef4 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:38:12 +0300 Subject: [PATCH 12/17] Fix typo --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e27a327..536bc6d 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "NameCaseLib — библиотека PHP5, предназначенная для автоматического склонения ФИО в русском и украинском языках. Уникальная особенность состоит в том, что библиотека содержит одинаковые методы для работы с ФИО на русском и украинском языках.", "minimum-stability": "stable", "license": "MIT", - "varsion": "0.4.3", + "version": "0.4.4", "type":"library", "authors": [ { From 2baa0ea6f4687c31946ac20639d7c34fe7ffe2d1 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:42:32 +0300 Subject: [PATCH 13/17] Remove fersion for packagist support --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 536bc6d..7629b0d 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,6 @@ "description": "NameCaseLib — библиотека PHP5, предназначенная для автоматического склонения ФИО в русском и украинском языках. Уникальная особенность состоит в том, что библиотека содержит одинаковые методы для работы с ФИО на русском и украинском языках.", "minimum-stability": "stable", "license": "MIT", - "version": "0.4.4", "type":"library", "authors": [ { From 3ac2a5bb55d4fc2c502469836d4a3bc352eb68fd Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 02:44:16 +0300 Subject: [PATCH 14/17] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c0490b6..71a501a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ to the require section of your `composer.json` file and execute `php composer.ph Change Log ------------ +## 0.4.4 (2024-02-17) (@nazbav) +- remove version field ## 0.4.3 (2024-02-17) (@vadykoo) - use NCLStr; for Ukrainian language, the same as for Russian #1 From de693b28674f8cb5990259355bc53f1225a60991 Mon Sep 17 00:00:00 2001 From: Nazym Bavbekov Date: Sat, 17 Feb 2024 03:06:34 +0300 Subject: [PATCH 15/17] Create config.yml --- .github/config.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/config.yml diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..3499936 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,2 @@ +todo: + keyword: "@makeAnIssue" From 89f6513ee4989ebfe60bd2e4831c4d2085dee5ce Mon Sep 17 00:00:00 2001 From: Hnakra <80700464+Hnakra@users.noreply.github.com> Date: Wed, 29 May 2024 12:14:13 +0300 Subject: [PATCH 16/17] Update NCLNameCaseCore.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Исправлена ошибка Error: Class 'seagullua\NameCaseLib\NCL\NCLNameCaseRu' not found in /var/www/html/my_project/vendor/nazbav/name-case-lib/Library/NCL/NCLNameCaseCore.php:642 --- Library/NCL/NCLNameCaseCore.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/NCL/NCLNameCaseCore.php b/Library/NCL/NCLNameCaseCore.php index f97b604..e28650c 100644 --- a/Library/NCL/NCLNameCaseCore.php +++ b/Library/NCL/NCLNameCaseCore.php @@ -1,6 +1,8 @@ Date: Tue, 18 Jun 2024 10:15:25 +0300 Subject: [PATCH 17/17] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 71a501a..940420a 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ to the require section of your `composer.json` file and execute `php composer.ph Change Log ------------ +## 0.4.5 (2024-06-18) (@Hnakra) +- fix class not found ## 0.4.4 (2024-02-17) (@nazbav) - remove version field