1 | <?php |
||
7 | class GeneralDeclension extends \morphos\GeneralDeclension implements Cases { |
||
8 | use RussianLanguage; |
||
9 | |||
10 | const FIRST_DECLENSION = 1; |
||
11 | const SECOND_DECLENSION = 2; |
||
12 | const THIRD_DECLENSION = 3; |
||
13 | |||
14 | const FIRST_SCHOOL_DECLENSION = 2; |
||
15 | const SECOND_SCHOOL_DECLENSION = 1; |
||
16 | const THIRD_SCHOOL_DECLENSION = 3; |
||
17 | |||
18 | protected $abnormalExceptions = array( |
||
19 | 'бремя', |
||
20 | 'вымя', |
||
21 | 'темя', |
||
22 | 'пламя', |
||
23 | 'стремя', |
||
24 | 'пламя', |
||
25 | 'время', |
||
26 | 'знамя', |
||
27 | 'имя', |
||
28 | 'племя', |
||
29 | 'семя', |
||
30 | ); |
||
31 | |||
32 | static protected $masculineWithSoft = array( |
||
33 | 'камень', |
||
34 | 'олень', |
||
35 | 'конь', |
||
36 | 'ячмень', |
||
37 | 'путь', |
||
38 | 'парень', |
||
39 | 'зверь', |
||
40 | 'шкворень', |
||
41 | 'пень', |
||
42 | 'пельмень', |
||
43 | 'тюлень', |
||
44 | 'выхухоль', |
||
45 | 'табель', |
||
46 | 'рояль', |
||
47 | 'шампунь', |
||
48 | 'конь', |
||
49 | 'лось', |
||
50 | 'гвоздь', |
||
51 | 'медведь', |
||
52 | ); |
||
53 | |||
54 | public function hasForms($word, $animateness = false) { |
||
60 | |||
61 | static public function getDeclension($word) { |
||
72 | |||
73 | public function getForms($word, $animateness = false) { |
||
97 | |||
98 | public function declinateFirstDeclension($word, $animateness = false) { |
||
141 | |||
142 | public function declinateSecondDeclension($word) { |
||
143 | $word = lower($word); |
||
144 | $prefix = slice($word, 0, -1); |
||
145 | $last = slice($word, -1); |
||
146 | $soft_last = $this->checkLastConsonantSoftness($word); |
||
147 | $forms = array( |
||
148 | Cases::IMENIT_1 => $word, |
||
149 | ); |
||
150 | |||
151 | // RODIT_2 |
||
152 | $forms[Cases::RODIT_2] = $this->chooseVowelAfterConsonant($last, $soft_last || (in_array(slice($word, -2, -1), array('г', 'к', 'х'))), $prefix.'и', $prefix.'ы'); |
||
153 | |||
154 | // DAT_3 |
||
155 | $forms[Cases::DAT_3] = self::getPredCaseOf12Declensions($word, $last, $prefix); |
||
156 | |||
157 | // VINIT_4 |
||
158 | $forms[Cases::VINIT_4] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix.'ю', $prefix.'у'); |
||
159 | |||
160 | // TVORIT_5 |
||
161 | if ($last == 'ь') |
||
162 | $forms[Cases::TVORIT_5] = $prefix.'ой'; |
||
163 | else { |
||
164 | $forms[Cases::TVORIT_5] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix.'ей', $prefix.'ой'); |
||
165 | } |
||
166 | |||
167 | // if ($last == 'й' || (self::isConsonant($last) && !RussianLanguage::isHissingConsonant($last)) || $this->checkLastConsonantSoftness($word)) |
||
168 | // $forms[Cases::TVORIT_5] = $prefix.'ей'; |
||
169 | // else |
||
170 | // $forms[Cases::TVORIT_5] = $prefix.'ой'; # http://morpher.ru/Russian/Spelling.aspx#sibilant |
||
171 | |||
172 | // PREDLOJ_6 the same as DAT_3 |
||
173 | $forms[Cases::PREDLOJ_6] = $this->choosePrepositionByFirstLetter($forms[Cases::DAT_3], 'об', 'о').' '.$forms[Cases::DAT_3]; |
||
174 | return $forms; |
||
175 | } |
||
176 | |||
177 | public function declinateThirdDeclension($word) { |
||
189 | |||
190 | public function getForm($word, $form, $animateness = false) { |
||
194 | |||
195 | static public function getPrefixOfFirstDeclension($word, $last) { |
||
202 | |||
203 | static public function getVinitCaseByAnimateness(array $forms, $animate) { |
||
209 | |||
210 | static public function getPredCaseOf12Declensions($word, $last, $prefix) { |
||
220 | } |
||
221 |