Example #1
0
 protected function processLine($line)
 {
     $line = $this->iconv($line);
     $result = new phpMorphy_Dict_PrefixSet($this->getPosition());
     $result->import(new ArrayIterator(array_map('trim', explode(',', $line))));
     return $result;
 }
 /**
  * @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);
 }
Example #3
0
 protected function readNext(XMLReader $reader)
 {
     do {
         if ($this->isStartElement('prefix_model')) {
             $prefix_model = new phpMorphy_Dict_PrefixSet($reader->getAttribute('id'));
             while ($this->read()) {
                 if ($this->isStartElement('prefix')) {
                     $prefix_model->append($reader->getAttribute('value'));
                 } elseif ($this->isEndElement('prefix_model')) {
                     break;
                 }
             }
             unset($this->current);
             $this->current = $prefix_model;
             break;
         }
     } while ($this->read());
 }
 /**
  * @param phpMorphy_Dict_PrefixSet $set
  * @return string
  */
 function formatPrefixSet(phpMorphy_Dict_PrefixSet $set)
 {
     return $this->formatSimpleModel('PrefixSet', array('id' => $set->getId(), 'prefixes' => implode(', ', $set->getPrefixes())));
 }