Example #1
0
 private function readCategorys($dataDir)
 {
     $data = FileMappedInputStream::_getIntArray($dataDir . "/char.category");
     $size = count($data) / 4;
     $ary = array();
     for ($i = 0; $i < $size; $i++) {
         $ary[$i] = new Category($data[$i * 4], $data[$i * 4 + 1], $data[$i * 4 + 2] === 1, $data[$i * 4 + 3] === 1);
     }
     return $ary;
 }
Example #2
0
 public function __construct($dataDir)
 {
     $this->trie = new Searcher($dataDir . "/word2id");
     $this->data = FileMappedInputStream::_getString($dataDir . "/word.dat");
     $this->indices = FileMappedInputStream::_getIntArray($dataDir . "/word.ary.idx");
     $fmis = new FileMappedInputStream($dataDir . "/word.inf");
     $wordCount = $fmis->size() / (4 + 2 + 2 + 2);
     $this->dataOffsets = $fmis->getIntArrayInstance($wordCount);
     //単語の素性データの開始位置
     $this->leftIds = $fmis->getShortArrayInstance($wordCount);
     //単語の左文脈ID
     $this->rightIds = $fmis->getShortArrayInstance($wordCount);
     //単語の右文脈ID
     $this->costs = $fmis->getShortArrayInstance($wordCount);
     //単語のコスト
     $fmis->close();
 }