Exemplo n.º 1
0
 /**
  * @todo Implement testGetLemma().
  */
 public function testGetLemma()
 {
     $this->assertEquals('testing', $this->object->getLemma());
 }
$source = new phpMorphy_Dict_Source_Xml($xml);
$flexias = remap_to_ids($source->getFlexias());
$ancodes = remap_to_ids($source->getAncodes());
$prefixes = remap_to_ids($source->getPrefixes());
echo "{$xml}: {", PHP_EOL;
$para_no = 1;
/** @var phpMorphy_Dict_Lemma $lemma */
foreach ($source->getLemmas() as $lemma) {
    $common_grammems = array();
    if ($lemma->hasAncodeId()) {
        /** @var phpMorphy_Dict_Ancode $common_ancode */
        $common_ancode = $ancodes[$lemma->getAncodeId()];
        $common_grammems = $common_ancode->getGrammems();
    }
    $flexia_model = $flexias[$lemma->getFlexiaId()];
    $paradigm = new phpMorphy_Paradigm_ArrayBased(false);
    /** @var phpMorphy_Dict_Flexia $flexia */
    foreach ($flexia_model as $flexia) {
        /** @var phpMorphy_Dict_Ancode $ancode */
        $ancode = $ancodes[$flexia->getAncodeId()];
        $wf = new phpMorphy_WordForm_WordForm();
        $wf->setBase($lemma->getBase());
        $wf->setFormPrefix($flexia->getPrefix());
        $wf->setSuffix($flexia->getSuffix());
        $wf->setCommonGrammems($common_grammems);
        $wf->setPartOfSpeech($ancode->getPartOfSpeech());
        $wf->setFormGrammems($ancode->getGrammems());
        $paradigm->append($wf);
    }
    printf("  Paradigm %2d.\n%s", $para_no++, $formatter->format($paradigm, '  '));
}
 /**
  * @param phpMorphy_Paradigm_ParadigmInterface $paradigm
  * @return phpMorphy_Paradigm_ParadigmInterface
  */
 protected function normalizeMorphyParadigmEncoding(phpMorphy_Paradigm_FsaBased $paradigm)
 {
     if (!$this->encoding_converter->isAffect()) {
         return $paradigm;
     }
     $result = new phpMorphy_Paradigm_ArrayBased();
     for ($i = 0, $c = count($paradigm); $i < $c; $i++) {
         $ary = $paradigm->getWordFormAsArray($i);
         foreach ($ary as &$v) {
             if (is_string($v)) {
                 $v = $this->toInternalEncoding($v);
             }
         }
         $result->append(new phpMorphy_WordForm_WordForm($ary));
     }
     return $result;
 }