Skip to content

Commit

Permalink
Fix Орёл misspelling. Fix #45
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Jan 8, 2019
1 parent 15bafb8 commit 0d947c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Russian/GeographicalNamesInflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class GeographicalNamesInflection extends \morphos\BaseInflection implements Cas
protected static $runawayVowelsExceptions = [
'торжо*к',
'волоче*к',
'оре*л',
'орё*л',
];

protected static $misspellings = [
'орел' => 'орёл',
];

/**
Expand Down Expand Up @@ -103,6 +107,7 @@ public static function getCases($name)
{
$name = S::lower($name);

// Проверка на неизменяемость и сложное название
if (in_array($name, self::$immutableParts, true)) {
return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], S::name($name));
}
Expand Down Expand Up @@ -142,6 +147,12 @@ public static function getCases($name)
}
}

// Исправление ошибок
if (array_key_exists($name, static::$misspellings)) {
$name = static::$misspellings[$name];
}

// Само склонение
if (!in_array($name, self::$abbreviations, true)) {
switch (S::slice($name, -2)) {
// Нижний, Русский
Expand Down
2 changes: 1 addition & 1 deletion tests/Russian/GeographicalNamesInflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function wordsProvider()
// с беглой гласной
['Торжок', 'Торжка', 'Торжку', 'Торжок', 'Торжком', 'Торжке'],
['Вышний Волочек', 'Вышнего Волочка', 'Вышнему Волочку', 'Вышний Волочек', 'Вышним Волочком', 'Вышнем Волочке'],
['Орел', 'Орла', 'Орлу', 'Орел', 'Орлом', 'Орле'],
['Орёл', 'Орла', 'Орлу', 'Орёл', 'Орлом', 'Орле'],

// сложные названия
['Санкт-Петербург', 'Санкт-Петербурга', 'Санкт-Петербургу', 'Санкт-Петербург', 'Санкт-Петербургом', 'Санкт-Петербурге'],
Expand Down

0 comments on commit 0d947c3

Please sign in to comment.