Exemplo n.º 1
0
 protected function readNext(XMLReader $reader)
 {
     do {
         if ($this->isStartElement('ancode')) {
             $pos_id = (int) $reader->getAttribute('pos_id');
             if (!isset($this->poses[$pos_id])) {
                 throw new Exception("Invalid pos id '{$pos_id}' found in ancode '" . $reader->getAttribute('id') . "'");
             }
             $pos = $this->poses[$pos_id];
             $ancode = new phpMorphy_Dict_Ancode($reader->getAttribute('id'), $pos['name'], $pos['is_predict']);
             while ($this->read()) {
                 if ($this->isStartElement('grammem')) {
                     $grammem_id = (int) $reader->getAttribute('id');
                     if (!isset($this->grammems[$grammem_id])) {
                         throw new Exception("Invalid grammem id '{$grammem_id}' found in ancode '" . $ancode->getId() . "'");
                     }
                     $ancode->addGrammem($this->grammems[$grammem_id]['name']);
                 } elseif ($this->isEndElement('ancode')) {
                     break;
                 }
             }
             unset($this->current);
             $this->current = $ancode;
             break;
         }
     } while ($this->read());
 }
Exemplo n.º 2
0
 protected function createAncode(phpMorphy_Dict_Ancode $ancode)
 {
     return new phpMorphy_Dict_Ancode_Normalized($this->registerAncodeId($ancode->getId()), $ancode->getId(), $this->registerPos($ancode->getPartOfSpeech(), $ancode->isPredict()), $this->registerGrammems($ancode->getGrammems()), $ancode->getId());
 }
 /**
  * @param phpMorphy_Dict_Ancode $ancode
  * @return string
  */
 function formatAncode(phpMorphy_Dict_Ancode $ancode)
 {
     return $this->formatSimpleModel('Ancode', array('id' => $ancode->getId(), 'part_of_speech' => $ancode->getPartOfSpeech(), 'grammems' => implode(', ', $ancode->getGrammems())));
 }
Exemplo n.º 4
0
 function insert(phpMorphy_Dict_Ancode $ancode)
 {
     $pos_id = $this->insertPos($ancode->getPartOfSpeech(), $ancode->isPredict());
     $grammems_ids = $this->insertGrammems($ancode->getGrammems());
     $this->ancodes_map[$ancode->getId()] = array('pos_id' => $pos_id, 'grammems_ids' => $grammems_ids);
 }