/** * Українські чоловічі імена, що в називному відмінку однини закінчуються на приголосний та -о, * відмінюються як відповідні іменники ІІ відміни. * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function manRule3() { //Предпоследний символ $BeforeLast = $this->Last(2, 1); 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, 'Гліб')) { $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) != 'сь') { $delim = NCLStr::strrpos($osnova, 'е'); $osnova = NCLStr::substr($osnova, 0, $delim) . NCLStr::substr($osnova, $delim + 1, NCLStr::strlen($osnova) - $delim); } if ($group == 1) { //Тверда група //Слова що закінчуються на ок 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('Лев', 'Остромов'))) { $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('ін'))) { $this->wordForms($this->workingWord, array('а', 'у', 'а', 'ом', 'у', 'е')); $this->Rule(303); return true; } else { $this->wordForms($osnova, array($osLast . 'а', $osLast . 'ові', $osLast . 'а', $osLast . 'ом', $osLast . 'ові', $this->inverse2($osLast) . 'е'), 1); $this->Rule(304); return true; } } if ($group == 2) { //Мішана група $this->wordForms($osnova, array('а', 'еві', 'а', 'ем', 'еві', 'е')); $this->Rule(305); return true; } if ($group == 3) { //М’яка група //Соловей 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 == 'і') { $this->wordForms($this->workingWord, array('я', 'єві', 'я', 'єм', 'єві', 'ю'), 1); $this->Rule(307); return true; } elseif ($this->workingWord == 'швець') { $this->wordForms($this->workingWord, array('евця', 'евцеві', 'евця', 'евцем', 'евцеві', 'евцю'), 4); $this->Rule(308); return true; } elseif ($this->Last(3) == 'ець') { $this->wordForms($this->workingWord, array('ця', 'цеві', 'ця', 'цем', 'цеві', 'цю'), 3); $this->Rule(309); return true; } elseif ($this->in($this->Last(3), array('єць', 'яць'))) { $this->wordForms($this->workingWord, array('йця', 'йцеві', 'йця', 'йцем', 'йцеві', 'йцю'), 3); $this->Rule(310); return true; } else { $this->wordForms($osnova, array('я', 'еві', 'я', 'ем', 'еві', 'ю')); $this->Rule(311); return true; } } } return false; }
/** * Функция проверяет, входит ли имя <var>$nameNeedle</var> в перечень имен <var>$names</var>. * @param string $nameNeedle - имя которое нужно найти * @param array $names - перечень имен в котором нужно найти имя * @return bool */ protected function inNames($nameNeedle, $names) { if (!is_array($names)) { $names = array($names); } foreach ($names as $name) { if (NCLStr::strtolower($nameNeedle) == NCLStr::strtolower($name)) { return true; } } return false; }
/** * Проверяет в нижнем ли регистре находится строка * @param string $phrase строка * @return bool в нижнем ли регистре строка */ static function isLowerCase($phrase) { return $phrase == NCLStr::strtolower($phrase); }
/** * Создание нового обьекта со словом <var>$word</var> * @param string $word слово */ public function __construct($word) { $this->generateMask($word); $this->word = NCLStr::strtolower($word); }