function get_gramtab_map($language) { $rml = new phpMorphy_Aot_Rml_IniFile(); $gramtab_file = $rml->getGramTabPath($language); $gramtab = new phpMorphy_Aot_GramTab_File($gramtab_file, phpMorphy_Aot_Mwz_File::getEncodingForLang($language), new phpMorphy_Aot_GramTab_GramInfoFactory(phpMorphy_Aot_GramTab_GramInfoHelperAbstract::createByLanguage($language))); $gramtab_map = array(); foreach ($gramtab as $ancode => $obj) { $grammems = $obj->getGrammems(); sort($grammems); $key = $obj->getPartOfSpeech() . ' ' . implode(',', $grammems); if (isset($gramtab_map[$key])) { throw new Exception("Duplicate ancode contents for {$ancode} => {$key}"); } $key = mb_strtoupper($key, 'utf-8'); $gramtab_map[$key] = $ancode; } return $gramtab_map; }
protected function createGramInfoFactory($lang) { return new phpMorphy_Aot_GramTab_GramInfoFactory(phpMorphy_Aot_GramTab_GramInfoHelperAbstract::createByLanguage($lang)); }