protected function evaluateDimension($text)
 {
     $mecab = mecab($text);
     $mecab = $this->keywords->addKeywordIntoMecabInfo($mecab, array('動詞', '名詞', '形容詞', '形容動詞'));
     $img = new IpcaImage();
     $img->load_mecab($mecab);
     $img->mul($this->filter);
     $this->ipca->project($img->data, $vec);
     return $vec;
 }
 public function evaluateLikelihood($text)
 {
     $mecab = mecab($text);
     $mecab = $this->keywords->addKeywordIntoMecabInfo($mecab, array('動詞', '名詞', '形容詞', '形容動詞'));
     $img = new IpcaImage();
     $img->load_mecab($mecab);
     $img->mul($this->filter);
     $res = new IpcaImage();
     $this->ipca->reflectProject($img->data, $res->data, $this->target);
     return $res->data[$this->target];
 }
 function learn($text)
 {
     $mecab = mecab($text);
     $blocks = $this->mecab2blocks($mecab);
     $pre = null;
     foreach ($blocks as $block) {
         if (is_null($block)) {
             continue;
         }
         if (is_null($pre)) {
             $pre = $this->getBlockId($block);
             continue;
         }
         $now = $this->getBlockId($block);
         //var_dump($block);
         $this->matrix[$pre][$now]++;
         $pre = $now;
     }
 }
Esempio n. 4
0
///// 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();