Ejemplo n.º 1
0
 static function create(phpMorphy_Storage $storage, $lazy)
 {
     if ($lazy) {
         return new phpMorphy_Fsa_Proxy($storage);
     }
     $header = phpMorphy_Fsa::readHeader($storage->read(0, self::HEADER_SIZE, true));
     if (!phpMorphy_Fsa::validateHeader($header)) {
         throw new phpMorphy_Exception('Invalid fsa format');
     }
     if ($header['flags']['is_sparse']) {
         $type = 'sparse';
     } else {
         if ($header['flags']['is_tree']) {
             $type = 'tree';
         } else {
             throw new phpMorphy_Exception('Only sparse or tree fsa`s supported');
         }
     }
     $storage_type = $storage->getTypeAsString();
     $file_path = dirname(__FILE__) . "/access/fsa_{$type}_{$storage_type}.php";
     $clazz = 'phpMorphy_Fsa_' . ucfirst($type) . '_' . ucfirst($storage_type);
     require_once $file_path;
     return new $clazz($storage->getResource(), $header);
 }
Ejemplo n.º 2
0
 function __construct(phpMorphy_Storage $ancodesMap)
 {
     if (false === ($this->ancodes_map = unserialize($ancodesMap->read(0, $ancodesMap->getFileSize())))) {
         throw new phpMorphy_Exception("Can`t open phpMorphy => Dialing ancodes map");
     }
     $this->reverse_map = array_flip($this->ancodes_map);
 }
Ejemplo n.º 3
0
 static function create(phpMorphy_Storage $storage, $lazy)
 {
     if ($lazy) {
         return new phpMorphy_GramInfo_Proxy($storage);
     }
     $header = phpMorphy_GramInfo::readHeader($storage->read(0, self::HEADER_SIZE));
     if (!phpMorphy_GramInfo::validateHeader($header)) {
         throw new phpMorphy_Exception('Invalid graminfo format');
     }
     $storage_type = $storage->getTypeAsString();
     $file_path = dirname(__FILE__) . "/access/graminfo_{$storage_type}.php";
     $clazz = '\\phpMorphy\\phpMorphy_GramInfo_' . ucfirst($storage_type);
     require_once $file_path;
     return new $clazz($storage->getResource(), $header);
 }
Ejemplo n.º 4
0
 protected function __construct(phpMorphy_Storage $storage)
 {
     $this->data = unserialize($storage->read(0, $storage->getFileSize()));
     if (false === $this->data) {
         throw new phpMorphy_Exception("Broken gramtab data");
     }
     $this->grammems = $this->data['grammems'];
     $this->poses = $this->data['poses'];
     $this->ancodes = $this->data['ancodes'];
 }
Ejemplo n.º 5
0
 function __construct($fileName, $shmCache)
 {
     $this->cache = $shmCache;
     parent::__construct($fileName);
 }