示例#1
0
require_once '../lib/db.php';
require_once '../lib/simple_validate.php';
require_once '../lib/stoper.php';
require_once '../lib/tokenizer.php';
require_once '../fsa/fsaa-opt.php';
require_once '../fsa/fsal-opt.php';
require_once '../fsa/fsas-opt.php';
// konfiguracja //
$cfg_serv = 'localhost';
$cfg_user = '******';
$cfg_pass = '';
$cfg_db = 'swk';
$cfg_tab = '3';
//////////////////
// po³±cz z baz± danych
$db = DBHelper::connect($cfg_serv, $cfg_user, $cfg_pass, $cfg_db);
// zainicjalizuj pozosta³e klasy
$validation = new Validation('../dict/vulgarism.txt');
$tokenizer = new Tokenizer('../dict/stoplist.txt');
$fsaa = new Fsaa('../dict/lort_acc_full.fsa');
$fsas = new Fsas('../dict/lort_acc_full.fsa');
$fsal = new Fsal('../dict/llems_full.fsa');
$pspell_config = pspell_config_create("pl");
pspell_config_ignore($pspell_config, 4);
pspell_config_mode($pspell_config, PSPELL_FAST);
pspell_config_runtogether($pspell_config, false);
$pspell_link = pspell_new_config($pspell_config);
// uruchomienie stopera, rozpoczêcie zbierania danych czasowych
$stoper = new Timer();
// pobierz zbiór wyników
$res = $db->query("SELECT * FROM comment_{$cfg_tab} WHERE type = 'OK' ORDER BY id");
require_once dirname(__FILE__) . '/../lib/winnow.php';
require_once dirname(__FILE__) . '/../lib/dcmplus.php';
require_once dirname(__FILE__) . '/../lib/icnn.php';
require_once dirname(__FILE__) . '/../lib/knn.php';
// konfiguracja testu
$suppressThreshold = false;
$initialComments = 50;
$maxAnalizedComments = 1000;
$TestDirTemp = 'Wtest_%d_%d_%d';
// prog, pocz. koment., maks analiz
$resultsFileTemp = 'results_%d_%s_%d.txt';
// idc, klasyf., nr testu
$timeFileTemp = 'speed_%d.txt';
// idc
////// konfiguracja podstawowa i g³ówne tablice
$db = DBHelper::connect('localhost', 'swk', '', 'swk');
$dictionaries = dirname(__FILE__) . '/../dict';
$copyUnknown = false;
$subTests = 1;
$times = array();
$curTimes = array();
$curResults = array();
$partialResults = array();
$summedResults = array();
$classObj = array();
// konfiguracja klasyfikatorów
$classifiers = array('Winnow' => array('1' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5), '2' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5), '3' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5)), 'DCMPlus' => array('1' => array('threshold' => 0.05), '2' => array('threshold' => 0.02), '3' => array('threshold' => 0.1)), 'Icnn' => array('1' => array('threshold' => 0.5, 'similarity' => 0.05), '2' => array('threshold' => 0.2, 'similarity' => 0.05), '3' => array('threshold' => 0.8, 'similarity' => 0.05)), 'Knn' => array('1' => array('threshold' => 0.5, 'k' => 10, 'maxComments' => 200), '2' => array('threshold' => 0.2, 'k' => 10, 'maxComments' => 200), '3' => array('threshold' => 0.7, 'k' => 10, 'maxComments' => 200)));
// utwórz folder dla testów
$tmps = $suppressThreshold ? 0 : 1;
$directory = sprintf($TestDirTemp, $tmps, $initialComments, $maxAnalizedComments);
if (!file_exists($directory)) {
示例#3
0
<?php

include "DBHelper.php";
$dbConfig = json_decode(file_get_contents("dbConfig.json"), true);
$dsn = $dbConfig["dsn"];
$user = $dbConfig["user"];
$pass = $dbConfig["pass"];
$dbh = DBHelper::connect($dsn, $user, $pass);
if (is_array($dbh)) {
    $result = $dbh;
} else {
    $result = DBHelper::executeQuery($dbh, "SHOW DATABASES");
    DBHelper::disconnect($dbh);
}
echo json_encode($result);
示例#4
0
</head>
<div>
<h2>Demonstracja systemu weryfikacji komentarzy<sup>*</sup></h2>
<!--Klasyfikuj-->
<?php 
if (isset($_POST['verify']) && array_key_exists($_POST['set'], $acomments) && array_key_exists($_POST['classifier'], $aclassifiers) && trim($_POST['comment']) != '') {
    // includy
    @ini_set('memory_limit', '25M');
    require_once dirname(__FILE__) . '/../lib/stoper.php';
    require_once dirname(__FILE__) . '/../lib/winnow.php';
    require_once dirname(__FILE__) . '/../lib/dcmplus.php';
    require_once dirname(__FILE__) . '/../lib/icnn.php';
    require_once dirname(__FILE__) . '/../lib/knn.php';
    // konfiguracja testu
    $suppressThreshold = $_POST['reject'] == '1' ? false : true;
    $db = DBHelper::connect('localhost', 'test', '123qwe', 'test');
    $dictionaries = dirname(__FILE__) . '/../dict';
    $results = array();
    $times = array();
    $values = array();
    $classObj = array();
    $prepText = null;
    $prepResult = array();
    // konfiguracja klasyfikatorów
    $pclassifiers = array('Winnow' => array('1' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5), '2' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5), '3' => array('alpha' => 2, 'beta' => 0.5, 'irrelevant1' => 0.005, 'irrelevant2' => 2, 'threshold' => 0.5)), 'DCMPlus' => array('1' => array('threshold' => 0.05), '2' => array('threshold' => 0.02), '3' => array('threshold' => 0.1)), 'Icnn' => array('1' => array('threshold' => 0.5, 'similarity' => 0.05), '2' => array('threshold' => 0.2, 'similarity' => 0.05), '3' => array('threshold' => 0.8, 'similarity' => 0.05)), 'Knn' => array('1' => array('threshold' => 0.5, 'k' => 10, 'maxComments' => 200), '2' => array('threshold' => 0.2, 'k' => 10, 'maxComments' => 200), '3' => array('threshold' => 0.7, 'k' => 10, 'maxComments' => 200)));
    // utwórz tablicê z parametrami do testu
    $classifiers = array();
    if ($_POST['classifier'] != 'all') {
        $classifiers[$_POST['classifier']] = $pclassifiers[$_POST['classifier']][$_POST['set']];
        if ($suppressThreshold) {
            $classifiers[$_POST['classifier']]['threshold'] = 0.0;