public function __construct($dataDir) { $this->categories = $this->readCategorys($dataDir); $fmis = new FileMappedInputStream($dataDir . "/code2category"); $this->char2id = $fmis->getIntArrayInstance($fmis->size() / 4 / 2); $this->eqlMasks = $fmis->getIntArrayInstance($fmis->size() / 4 / 2); $fmis->close(); }
public function __construct($filePath) { $fmis = new FileMappedInputStream($filePath); $nodeSz = $fmis->getInt(); $tindSz = $fmis->getInt(); $tailSz = $fmis->getInt(); $this->keySetSize = $tindSz; $this->begs = $fmis->getIntArrayInstance($tindSz); $this->base = $fmis->getIntArrayInstance($nodeSz); $this->lens = $fmis->getShortArrayInstance($tindSz); $this->chck = $fmis->getCharArrayInstance($nodeSz); $this->tail = array_values(unpack("S*", $fmis->getString($tailSz))); $fmis->close(); }
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(); }