Beispiel #1
0
function get_gramtab_map($language)
{
    $rml = new phpMorphy_Rml_IniFile();
    $gramtab_file = $rml->getGramTabPath($language);
    $gramtab = new phpMorphy_GramTab_File($gramtab_file, phpMorphy_Mwz_File::getEncodingForLang($language), new phpMorphy_GramTab_GramInfoFactory($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;
}
Beispiel #2
0
 protected function getGramTabPath($lang)
 {
     $rml = new phpMorphy_Rml_IniFile();
     return $rml->getGramTabPath($lang);
 }