Example #1
0
function ngram_summary()
{
    global $experiment, $evalset, $dir, $set, $id;
    //# load data
    $data = file(get_current_analysis_filename("basic", "summary"));
    for ($i = 0; $i < count($data); $i++) {
        $item = split(": ", $data[$i]);
        $info[$item[0]] = $item[1];
    }
    print "<table cellspacing=5 width=100%><tr><td valign=top align=center bgcolor=#eeeeee>";
    //#foreach (array("precision","recall") as $type) {
    print "<b>Precision of Output</b>\n";
    $type = "precision";
    print "<table><tr><td>{$type}</td><td>1-gram</td><td>2-gram</td><td>3-gram</td><td>4-gram</td></tr>\n";
    printf("<tr><td>correct</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>\n", $info["{$type}-1-correct"], $info["{$type}-2-correct"], $info["{$type}-3-correct"], $info["{$type}-4-correct"]);
    printf("<tr><td>&nbsp;</td><td>%.1f%s</td><td>%.1f%s</td><td>%.1f%s</td><td>%.1f%s</td></tr>\n", $info["{$type}-1-correct"] / $info["{$type}-1-total"] * 100, '%', $info["{$type}-2-correct"] / $info["{$type}-2-total"] * 100, '%', $info["{$type}-3-correct"] / $info["{$type}-3-total"] * 100, '%', $info["{$type}-4-correct"] / $info["{$type}-4-total"] * 100, '%');
    printf("<tr><td>wrong</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>\n", $info["{$type}-1-total"] - $info["{$type}-1-correct"], $info["{$type}-2-total"] - $info["{$type}-2-correct"], $info["{$type}-3-total"] - $info["{$type}-3-correct"], $info["{$type}-4-total"] - $info["{$type}-4-correct"]);
    print "</table>";
    //}
    print "<A HREF=\"javascript:generic_show('PrecisionRecallDetails','')\">details</A> ";
    if (file_exists(get_current_analysis_filename("precision", "precision-by-corpus-coverage"))) {
        print "| <A HREF=\"javascript:generic_show('PrecisionByCoverage','')\">precision of input by coverage</A> ";
    }
    print "</td><td valign=top valign=top align=center bgcolor=#eeeeee>";
    $each_score = explode(" ; ", $experiment[$id]->result[$set]);
    $header = "";
    $score_line = "";
    for ($i = 0; $i < count($each_score); $i++) {
        if (preg_match('/([\\d\\(\\)\\.\\s]+) (BLEU[\\-c]*)/', $each_score[$i], $match) || preg_match('/([\\d\\(\\)\\.\\s]+) (IBM[\\-c]*)/', $each_score[$i], $match) || preg_match('/([\\d\\(\\)\\.\\s]+) (METEOR[\\-c]*)/', $each_score[$i], $match)) {
            $header .= "<td>{$match['2']}</td>";
            $score_line .= "<td>{$match['1']}</td>";
        }
    }
    print "<b>Metrics</b><table border=1><tr>" . $header . "</tr><tr>" . $score_line . "</tr></table>";
    printf("<p>length-diff: %d (%.1f%s)", $info["precision-1-total"] - $info["recall-1-total"], ($info["precision-1-total"] - $info["recall-1-total"]) / $info["recall-1-total"] * 100, "%");
    // coverage
    if (file_exists(get_current_analysis_filename("coverage", "corpus-coverage-summary"))) {
        print "</td><td valign=top align=center bgcolor=#eeeeee>";
        print "<div id=\"CoverageSummary\">";
        coverage_summary();
        print "</div>";
    }
    // phrase segmentation
    if (file_exists(get_current_analysis_filename("basic", "segmentation")) || file_exists(get_current_analysis_filename("basic", "rule"))) {
        print "</td><td valign=top align=center bgcolor=#eeeeee>";
        print "<div id=\"SegmentationSummary\">";
        segmentation_summary();
        print "</div>";
    }
    // rules
    if (file_exists(get_current_analysis_filename("basic", "rule"))) {
        print "</td><td valign=top align=center bgcolor=#eeeeee>";
        print "<div id=\"RuleSummary\">";
        rule_summary();
        print "</div>";
    }
    print "</td></tr></table>";
}
Example #2
0
                 precision_by_coverage();
             } else {
                 if ($action == "PrecisionByCoverageDiff_show") {
                     precision_by_coverage_diff();
                 } else {
                     if (preg_match("/PrecisionByWordDiff(.+)_show/", $action, $match)) {
                         precision_by_word_diff($match[1]);
                     } else {
                         if (preg_match("/PrecisionByWord(.+)_show/", $action, $match)) {
                             precision_by_word($match[1]);
                         } else {
                             if ($action == "CoverageDetails_show") {
                                 coverage_details();
                             } else {
                                 if ($action == "SegmentationSummary_show") {
                                     segmentation_summary();
                                 } else {
                                     if ($action == "biconcor") {
                                         biconcor(base64_decode($_GET["phrase"]));
                                     } else {
                                         print "ERROR! {$action}";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }