Skip to content

Commit

Permalink
Fix for pluralization of nouns of 3rd declension
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Aug 8, 2017
1 parent 29e0cf3 commit fdfd1e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Russian/NounPluralization.php
Expand Up @@ -128,12 +128,12 @@ protected static function declinateSubstative($word, $animateness)
} elseif ($declension == NounDeclension::FIRST_DECLENSION) {
$soft_last = self::checkLastConsonantSoftness($word);
} else {
$soft_last = S::slice($word, -2) == 'сь';
$soft_last = in_array(S::slice($word, -2), ['чь', 'сь', 'ть', 'нь']);
}

$forms = array();

if ($last == 'ч' || in_array(S::slice($word, -2), array('чь', 'сь')) || (self::isVowel($last) && in_array(S::slice($word, -2, -1), array('ч', 'к')))) { // before ч, чь, сь, ч+vowel, к+vowel
if ($last == 'ч' || in_array(S::slice($word, -2), array('чь', 'сь', 'ть', 'нь')) || (self::isVowel($last) && in_array(S::slice($word, -2, -1), array('ч', 'к')))) { // before ч, чь, сь, ч+vowel, к+vowel
$forms[Cases::IMENIT] = $prefix.'и';
} elseif ($last == 'н' || $last == 'ц') {
$forms[Cases::IMENIT] = $prefix.'ы';
Expand Down Expand Up @@ -165,7 +165,7 @@ protected static function declinateSubstative($word, $animateness)
$forms[Cases::RODIT] = $prefix;
} elseif (in_array($last, array('я'))) { // молния
$forms[Cases::RODIT] = $prefix.'й';
} elseif (RussianLanguage::isHissingConsonant($last) || ($soft_last && $last != 'й') || in_array(S::slice($word, -2), array('чь', 'сь'))) {
} elseif (RussianLanguage::isHissingConsonant($last) || ($soft_last && $last != 'й') || in_array(S::slice($word, -2), array('чь', 'сь', 'ть', 'нь'))) {
$forms[Cases::RODIT] = $prefix.'ей';
} elseif ($last == 'й' || S::slice($word, -2) == 'яц') { // месяц
$forms[Cases::RODIT] = $prefix.'ев';
Expand All @@ -181,7 +181,7 @@ protected static function declinateSubstative($word, $animateness)

// TVORIT
// my personal rule
if ($last == 'ь' && $declension == NounDeclension::THIRD_DECLENSION && !in_array(S::slice($word, -2), array('чь', 'сь'))) {
if ($last == 'ь' && $declension == NounDeclension::THIRD_DECLENSION && !in_array(S::slice($word, -2), array('чь', 'сь', 'ть', 'нь'))) {
$forms[Cases::TVORIT] = $prefix.'ми';
} else {
$forms[Cases::TVORIT] = self::chooseVowelAfterConsonant($last, $soft_last && S::slice($word, -2, -1) != 'ч', $prefix.'ями', $prefix.'ами');
Expand Down
2 changes: 2 additions & 0 deletions tests/Russian/NounPluralizationTest.php
Expand Up @@ -81,6 +81,8 @@ public function pluralWordsProvider()
array('волчище', false, array('волчища', 'волчищ', 'волчищам', 'волчища', 'волчищами', 'о волчищах')),
array('год', false, array('года', 'годов', 'годам', 'года', 'годами', 'о годах')),
array('месяц', false, array('месяцы', 'месяцев', 'месяцам', 'месяцы', 'месяцами', 'о месяцах')),
array('новость', false, array('новости', 'новостей', 'новостям', 'новости', 'новостями', 'о новостях')),
array('тень', false, array('тени', 'теней', 'теням', 'тени', 'тенями', 'о тенях')),

// Адъективное склонение
// мужской род
Expand Down

0 comments on commit fdfd1e1

Please sign in to comment.