Пример #1
0
function range_string_to_array($range_string)
{
    $result = array();
    if (is_cs_natural_numbers($range_string)) {
        $parts = explode(',', $range_string);
        foreach ($parts as $part) {
            if (is_natural_number_range(trim($part))) {
                $range = explode('..', $part);
                if ($range[0] < $range[1]) {
                    for ($i = trim($range[0]); $i <= trim($range[1]); ++$i) {
                        $result[] = $i;
                    }
                }
            } elseif (is_natural_number(trim($part))) {
                $result[] = trim($part);
            }
        }
        sort($result, SORT_NUMERIC);
        $result = array_unique($result, SORT_NUMERIC);
    }
    return $result;
}
Пример #2
0
     $tfr = $this->input->post('target_feature_right');
     $tfe = $this->input->post('target_feature_event');
     $source_data = $this->input->post('source_data');
     if ($tfl == false && $tfr == false || $tfe == false || $source_data == false) {
         // illegal request, return nothing
         $sql = 'SELECT * FROM dataset WHERE 0;';
     } else {
         $sql = 'SELECT `d`.`did` AS `source_data`, `fl`.`name` AS `target_feature_left`, ' . '`fr`.`name` AS `target_feature_right`, ' . '`fe`.`name` AS `target_feature_event` ' . 'FROM `data_feature` `fe`, `dataset` `d` ' . 'LEFT JOIN `data_feature` `fl` ON `d`.`did` = `fl`.`did` AND `fl`.`name` = "' . $tfl . '" ' . 'LEFT JOIN `data_feature` `fr` ON `d`.`did` = `fr`.`did` AND `fr`.`name` = "' . $tfr . '" ' . 'WHERE `d`.`did` = `fe`.`did` AND `fe`.`name` = "' . $tfe . '" ' . 'AND ' . $constraints . ' ';
     }
 }
 $datasets = $this->Dataset->query($sql . 'ORDER BY `source_data`;');
 // sanity check input
 $input_safe = true;
 // first sanitize custom testset
 if ($this->input->post('custom_testset')) {
     if (is_cs_natural_numbers($inputs['custom_testset'])) {
         $inputs['custom_testset'] = implode(',', range_string_to_array($inputs['custom_testset']));
     } else {
         unset($inputs['custom_testset']);
         $input_safe = false;
     }
 }
 // TODO: Check input $this->input->post('cost_matrix')
 $results = array();
 // resulting task configurations
 $dids = array();
 // used dataset ids
 $new_tasks = array();
 if (is_array($datasets)) {
     foreach ($datasets as $dataset) {
         $current = $inputs;
Пример #3
0
 private function generate($task_id, $filepath = false)
 {
     $task = $this->Task->getById($task_id);
     if ($task === false || in_array($task->ttid, $this->task_types) === false) {
         die('Task not providing datasplits.');
     }
     $values = $this->Task_inputs->getTaskValuesAssoc($task_id);
     $estimation_procedure = null;
     if (array_key_exists('estimation_procedure', $values)) {
         $estimation_procedure = $this->Estimation_procedure->getById($values['estimation_procedure']);
     }
     if ($estimation_procedure == false) {
         die('estimation procedure not found');
     }
     $dataset = $this->Dataset->getById($values['source_data']);
     $epstr = $this->Estimation_procedure->toString($estimation_procedure);
     $target_feature = $task->ttid == 7 ? $values['target_feature_event'] : $values['target_feature'];
     // TODO: very important. sanity check input
     $testset_str = array_key_exists('custom_testset', $values) && is_cs_natural_numbers($values['custom_testset']) ? '-test "' . $values['custom_testset'] . '"' : '';
     $command = 'java -jar ' . $this->evaluation . ' -f "generate_folds" -d "' . $dataset->url . '" -e "' . $epstr . '" -c "' . $target_feature . '" -r "' . safe($dataset->row_id_attribute) . '" ' . $testset_str . $this->config;
     if (array_key_exists('custom_testset', $values)) {
         $command .= '-test "' . $values['custom_testset'] . '" ';
     }
     if ($filepath) {
         $command .= ' -o ' . $filepath;
     }
     //if( $md5 ) $command .= ' -m';
     $this->Log->cmd('API Splits::get(' . $task_id . ')', $command);
     if (function_enabled('system')) {
         header('Content-type: text/plain');
         system(CMD_PREFIX . $command);
     } else {
         die('failed to generate arff file: php "system" function disabled. ');
     }
 }