/** * @param phpMorphy_Paradigm_ParadigmInterface $paradigm * @param string $base * @param string $additionalCommonPrefix * @return phpMorphy_Dict_Lemma */ protected function createLemma(phpMorphy_Paradigm_ParadigmInterface $paradigm) { $flexia_model = $this->createFlexiaModel($paradigm); $base = $paradigm->getPseudoRoot(); $common_prefix = $paradigm[0]->getCommonPrefix(); $lemma = new phpMorphy_Dict_Lemma($base, $flexia_model->getId(), null); if (strlen($common_prefix)) { $prefix_set = new phpMorphy_Dict_PrefixSet(null); $prefix_set->append($common_prefix); $prefix_set_id = $this->source->appendPrefix($prefix_set)->getId(); $lemma->setPrefixId($prefix_set_id); } if (count($paradigm->getCommonGrammems())) { $common_ancode = $this->createAncode(null, $paradigm->getCommonGrammems()); $lemma->setAncodeId($common_ancode->getId()); } return $this->source->appendLemma($lemma); }
protected function processLine($line) { //if(6 != count($tokens = array_map('trim', explode(' ', $line)))) { $line = $this->iconv($line); if (6 != count($tokens = explode(' ', $line))) { throw new phpMorphy_Aot_Mrd_Exception("Invalid lemma str('{$line}'), too few tokens"); } $base = trim($tokens[0]); if ($base === '#') { $base = ''; } $lemma = new phpMorphy_Dict_Lemma($base, (int) $tokens[1], (int) $tokens[2]); if ('-' !== $tokens[4]) { $lemma->setAncodeId($tokens[4]); } if ('-' !== $tokens[5]) { $lemma->setPrefixId((int) $tokens[5]); } return $lemma; }
public function __toString() { $result = $this->object->__toString(); return $result === $this->object ? $this : $result; }
/** * @param phpMorphy_Dict_Lemma $lemma * @return string */ function formatLemma(phpMorphy_Dict_Lemma $lemma) { return $this->formatSimpleModel('Lemma', array('id' => $lemma->getId(), 'base' => $lemma->getBase(), 'flexia_id' => $lemma->getFlexiaId(), 'common_ancode_id' => $lemma->hasAncodeId() ? $lemma->getAncodeId() : null, 'common_prefix_id' => $lemma->hasPrefixId() ? $lemma->getPrefixId() : null, 'accent_id' => $lemma->getAccentId())); }
private function checkConsistencyForLemma(phpMorphy_Dict_Lemma $lemma) { if ($lemma->hasAncodeId()) { if (!$this->ancodes->hasId($lemma->getAncodeId())) { return false; } } if ($lemma->hasPrefixId()) { if (!$this->prefixes->hasId($lemma->getPrefixId())) { return false; } } if (!$this->flexias->hasId($lemma->getFlexiaId())) { return false; } return true; }