print $LOG_FILE; break; case "Tune": $args = array("flag_training" => 0, "flag_tuning" => 1, "flag_recaser" => 0, "id" => $_POST["train_id"], "lm_factor" => $_POST["lm_factor"], "lm_order" => $_POST["lm_order"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_training" => $_POST["train_corpus_name"], "corpus_tuning" => $_POST["tune_corpus_name"], "alignment" => $_POST["alignment"], "reordering" => $_POST["reordering"], "with_irstlm" => $_POST["irstlm"], "with_kenlm" => $_POST["kenlm"]); saveConfig(getTrainingConfigFullPath(), $args); MosesCmdRun(getTrainingScriptFullPath(), getTrainingConfigFullPath()); print $LOG_FILE; break; case "Train+Tune": $args = array("flag_training" => 1, "flag_tuning" => 1, "flag_recaser" => 0, "id" => $_POST["train_id"], "lm_factor" => $_POST["lm_factor"], "lm_order" => $_POST["lm_order"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_training" => $_POST["train_corpus_name"], "corpus_tuning" => $_POST["tune_corpus_name"], "alignment" => $_POST["alignment"], "reordering" => $_POST["reordering"], "with_irstlm" => $_POST["irstlm"], "with_kenlm" => $_POST["kenlm"]); saveConfig(getTrainingConfigFullPath(), $args); MosesCmdRun(getTrainingScriptFullPath(), getTrainingConfigFullPath()); print $LOG_FILE; break; case "Evaluate": $args = array("id" => $_POST["train_id"], "flag_recaser" => $_POST["recasing"], "flag_evaluation" => $_POST["evaluate"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_recaser" => $_POST["recase_corpus_name"], "corpus_eval_src" => $_POST["eval_src_corpus_name"], "corpus_eval_ref" => $_POST["eval_ref_corpus_name"], "corpus_eval_tst" => $_POST["eval_tst_corpus_name"], "evaluation_tool" => $_POST["evaluation_tool"]); saveConfig(getEvaluationConfigFullPath(), $args); MosesCmdRun(getEvaluationScriptFullPath(), getEvaluationConfigFullPath()); print $LOG_FILE; break; case "getTrainingList": print getTrainingList($_POST["src_lang"], $_POST["tar_lang"]); break; case "getAllResults": print getEvalResults($_POST["src_lang"], $_POST["tar_lang"]); break; case "getResult": getLog($_POST["log_file"]); break; } return 0;
function getEvalResults($src, $tar) { global $TRAIN_DATA_ROOT; $train_list = getTrainingList($src, $tar); $train_list = explode(",", $train_list); $results = ""; if (sizeof($train_list) > 0) { array_pop($train_list); for ($i = 0; $i < sizeof($train_list); $i++) { $result_file = $TRAIN_DATA_ROOT . strtoupper($src) . "-" . strtoupper($tar) . "/" . $train_list[$i] . "/score.log"; if (file_exists($result_file)) { $results .= file_get_contents($result_file); $results .= "\n"; } else { $results .= sprintf("\n%s hasn't been scored yet. \n\n", $train_list[$i]); } } } return $results; }