Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 3
0
        $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.";
Ejemplo n.º 4
0
<?php

require_once '../configure.php';
require_once CONF_DIR . 'path.php';
require_once INCLUDE_DIR . 'keywords/KeywordsTable.class.php';
require_once INCLUDE_DIR . 'twitter/twitter.class.php';
$table = KeywordsTable::singleton();
$loader = new TwitterLog();
foreach (glob(ConfPath::rawStatusList()) as $path) {
    $loader->open($path);
    while ($loader->read1Line()) {
        $info = $loader->getArrayPassedMecab();
        $table->addRecordByMecab($info['mecab']);
    }
    $loader->close();
}
$table->saveTable(ConfPath::keywords());