Esempio n. 1
0
        if ($value == 0) {
            $blank++;
        }
        if ($value >= 1) {
            $hit++;
        }
    }
    $global_lines += $hit + $miss;
    $global_hits += $hit;
    return $hit / ($hit + $miss);
}
print "<h2>Summary</h2>";
print "<table>";
print "<tr><td>Filename</td><td>Coverage</td></tr>";
foreach ($files as $file => $coverage) {
    $csum = coverage_summary($file, $coverage) * 100;
    printf("<tr style='background: %s'><td><a href='#%s'>%s</a></td><td>%4.2f</td></tr>", "hsl(" . max($csum - 40, 0) * 1.6 . ", 50%, 75%)", urlencode(rel($file)), rel($file), $csum);
}
if ($global_lines > 0) {
    printf("<tr><td>Total</td><td><b>%4.2f</b></td></tr>", $global_hits / $global_lines * 100);
}
print "</table>";
foreach ($files as $file => $coverage) {
    print "<h2><a name='" . urlencode(rel($file)) . "'>" . rel($file) . "</a></h2>";
    print "<pre>";
    $lines = explode("\n", file_get_contents($file));
    for ($i = 0; $i < count($lines); $i++) {
        $exes = isset($coverage[$i + 1]) ? $coverage[$i + 1] : -2;
        if ($exes == -1 && blank($lines[$i])) {
            $exes = 0;
        }
Esempio n. 2
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>";
}
Esempio n. 3
0
     $id2 = $_GET["id2"];
 }
 if ($action == "show") {
     show_analysis();
 } else {
     if ($action == "bleu_show") {
         bleu_show();
     } else {
         if ($action == "ngram_precision_show") {
             ngram_show("precision");
         } else {
             if ($action == "ngram_recall_show") {
                 ngram_show("recall");
             } else {
                 if ($action == "CoverageSummary_show") {
                     coverage_summary();
                 } else {
                     if ($action == "PrecisionRecallDetails_show") {
                         precision_recall_details();
                     } else {
                         if ($action == "PrecisionRecallDetailsDiff_show") {
                             precision_recall_details_diff();
                         } else {
                             if ($action == "PrecisionByCoverage_show") {
                                 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]);