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; }
$max = 1; $min = 1; foreach ($this->m_Keywords->m_Table as $word => $record) { if ($this->isIgnored($record)) { continue; } $count = $record['count']; if ($max < $count) { $max = $count; } } foreach ($this->m_Keywords->m_Table as $word => $record) { if ($this->isIgnored($record)) { continue; } $index = $record['index']; $count = $record['count']; if (!$index || !$count) { continue; } $rate = log($max / $count) / log($max / $min); fprintf($f, "%d,%f,%s\n", $index, $rate, $word); } fclose($f); } } $keywords = KeywordsTable::singleton(); $keywords->loadTable(ConfPath::keywords()); $instance = new MakeFilter(array('Keywords' => $keywords)); $instance->run_idf(ConfPath::keywordsFilter()); print "WARN: Add special person value, like hajimehoshi, shokos etc.";
///// 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); } $score->printCount(); $loader->close(); } $score->save();