static function singleton($opt = null) { if (!self::$Instance) { self::$Instance = new self($opt); } return self::$Instance; }
function __construct($name) { $this->name = $name; $this->filter = new IpcaImage(); $this->filter->load_1Line1Element(ConfPath::keywordsFilter(), 0, 1); $this->keywords = KeywordsTable::singleton(); $this->keywords->loadTable(ConfPath::keywords()); $this->ipca = Ipca::singleton(); $this->ipca->load(self::DIMANSION_MAX); }
protected function initLearn() { if ($this->initialized) { return; } $this->state = new BlockState(); $this->state->loadMatrix(ConfPath::stateMatrix($this->name)); $this->state->loadText2id(ConfPath::stateTexts($this->name)); $this->keywords = KeywordsTable::singleton(); $this->keywords->loadTable(ConfPath::keywords()); $this->filter = new IpcaImage(); $this->filter->load_1Line1Element(ConfPath::keywordsFilter(), 0, 1); $this->ipca = Ipca::singleton(); $this->ipca->load(3); $this->initialized = true; }
function __construct($options = null) { $this->m_Keywords = $options['Keywords'] ? $options['Keywords'] : KeywordsTable::singleton($options); }
fprintf($file, "score=%f,%s\n", $score, implode(",", $list)); } fclose($file); } } ///// run ! $users = array(); for ($i = 1; $argv[$i]; $i++) { $users[] = $argv[$i]; } //$users = array(241032387);//hajimeh0shi //$users = array(4029081);//hajimehoshi //$users = array(19187659);//shokos $users = array(212653601, 1); //kawango $table = KeywordsTable::singleton(); $table->loadTable(ConfPath::keywords()); $loader = new TwitterLog(); $score = new ScoreLogs(); $score->setTarget(3); $score->setFilter(ConfPath::keywordsFilter()); foreach (glob(ConfPath::rawStatusList()) as $path) { $loader->open($path); while ($loader->read1Line()) { $info = $loader->getArray(); if (!in_array($info['user_id'], $users)) { continue; } $mecab = mecab($info['text']); $info['mecab'] = $table->addKeywordIntoMecabInfo($mecab); $score->score($info);