mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 22:14:57 +03:00
chart decoder search graph viz and other fixes to web interface of ems
This commit is contained in:
parent
bc866f37ff
commit
8bb49c9053
@ -869,9 +869,12 @@ function rule_summary() {
|
||||
printf("tree depth: %.2f<br>\n",$depth);
|
||||
printf("nt/rule: %.2f<br>\n",$nt_count/$total);
|
||||
print "<table>\n";
|
||||
arsort($count_nt);
|
||||
$i=0;
|
||||
foreach ($count_nt as $rule => $count) {
|
||||
printf("<tr><td>%s</td><td align=right>%d</td><td align=right>%.1f%s</td></tr>\n",$rule,$count,$count/$total*100,'%');
|
||||
if ($i++ < 5) { printf("<tr><td>%s</td><td align=right>%d</td><td align=right>%.1f%s</td></tr>\n",$rule,$count,$count/$total*100,'%'); }
|
||||
}
|
||||
if (count($count_nt)>5) { print "<tr><td align=center>...</td><td align=center>...</td><td align=center>...</td></tr>\n"; }
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
@ -920,6 +923,7 @@ function bleu_show() {
|
||||
if ($filter != "") {
|
||||
print "; filter: '$filter'";
|
||||
}
|
||||
|
||||
sentence_annotation($count,$filter);
|
||||
print "<p align=center><A HREF=\"javascript:show('bleu','" . $_GET['sort'] . "',5+$count,'".base64_encode($filter)."')\">5 more</A> | ";
|
||||
print "<A HREF=\"javascript:show('bleu','" . $_GET['sort'] . "',10+$count,'".base64_encode($filter)."')\">10 more</A> | ";
|
||||
@ -1126,6 +1130,12 @@ function sentence_annotation($count,$filter) {
|
||||
//print "<div id=\"debug\">$sort / $offset</div>";
|
||||
for($i=$offset;$i<$count+$offset && $i<count($bleu);$i++) {
|
||||
$line = $bleu[$i];
|
||||
$search_graph_dir = get_current_analysis_filename("basic","search-graph");
|
||||
if (file_exists($search_graph_dir) && file_exists($search_graph_dir."/graph.".$line["id"])) {
|
||||
$state = return_state_for_link();
|
||||
print "<FONT SIZE=-1><A TARGET=_blank HREF=\"?$state&analysis=sgviz&set=$set&id=$id&sentence=".$line["id"]."\">show search graph</a></FONT><br>\n";
|
||||
}
|
||||
|
||||
if ($hierarchical) {
|
||||
annotation_hierarchical($line["id"],$segmentation[$line["id"]],$segmentation_out[$line["id"]],$node[$line["id"]]);
|
||||
}
|
||||
|
@ -116,8 +116,10 @@ function precision_by_coverage_diff() {
|
||||
$log_info[$log_count]["length"] -= $item[3];
|
||||
}
|
||||
|
||||
|
||||
print "<h4>By log<sub>2</sub>-count in the training corpus</h4>";
|
||||
precision_by_coverage_diff_graph("byCoverage",$log_info,$log_info_new,$total,$img_width,SORT_NUMERIC);
|
||||
precision_by_coverage_diff_matrix();
|
||||
|
||||
// load factored data
|
||||
$d = dir("$dir/evaluation/$set.analysis.".get_precision_analysis_version($dir,$set,$id));
|
||||
@ -290,6 +292,244 @@ function precision_by_word_diff($type) {
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
function precision_by_coverage_diff_matrix() {
|
||||
global $id,$id2;
|
||||
print "<h4>Impact of Change in Coverage</h4>";
|
||||
print "Coverage in run $id is the x-axis, change in coverage in run $id2 is the y-axis. Size of box reflects how many output words are produced, yellow is the number of correct translations, green indicates increase, green decrease. The bleu rectangle below each box indicates number of words dropped, and increase (cyan) or decrease (purple).<p>(";
|
||||
$scale = 30;
|
||||
for($i=1; $i<=5; $i++) {
|
||||
$size = (int)(sqrt($i*$scale));
|
||||
$name = "size-$i";
|
||||
print "<canvas id=\"$name\" width=\"$size\" height=\"$size\"></canvas><script language=\"javascript\">
|
||||
var canvas = document.getElementById(\"$name\");
|
||||
var ctx = canvas.getContext(\"2d\");
|
||||
ctx.fillStyle = \"rgb(0,0,0)\";
|
||||
ctx.fillRect (0, 0, $size, $size);
|
||||
</script> = $i word";
|
||||
if ($i>1) { print "s"; }
|
||||
if ($i<5) { print ", "; }
|
||||
}
|
||||
print ")<p>";
|
||||
# get base data
|
||||
$data = file(get_current_analysis_filename("precision","precision-by-input-word"));
|
||||
$word = array(); $class = array();
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$line = rtrim($data[$i]);
|
||||
$item = split("\t",$line);
|
||||
$surface = $item[5];
|
||||
$word[$surface] = array();
|
||||
$word[$surface]["precision"] = $item[0]; # number of precise translations
|
||||
$word[$surface]["delete"] = $item[1]; # number of deleted
|
||||
$word[$surface]["total"] = $item[2]; # number of all translations
|
||||
$word[$surface]["coverage"] = $item[4]; # count in training corpus
|
||||
if ($item[4] == 0) { $log_count = -1; }
|
||||
else { $log_count = (int) (log($item[4])/log(2)); }
|
||||
$word[$surface]["log_count"] = $log_count;
|
||||
if (!array_key_exists($log_count,$class)) { $class[$log_count] = array(); }
|
||||
$class[$log_count][] = $surface;
|
||||
}
|
||||
|
||||
# init matrix
|
||||
$matrix = array();
|
||||
$max_base_log_count = -1;
|
||||
$min_alt_log_count = 99;
|
||||
$max_alt_log_count = -1;
|
||||
foreach(array_keys($class) as $log_count) {
|
||||
$matrix[$log_count] = array();
|
||||
if ($log_count > $max_base_log_count) { $max_base_log_count = $log_count; }
|
||||
}
|
||||
|
||||
# get alternative data
|
||||
$data = file(get_current_analysis_filename2("precision","precision-by-input-word"));
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$line = rtrim($data[$i]);
|
||||
$item = split("\t",$line);
|
||||
$surface = $item[5];
|
||||
if ($item[4] == 0) { $alt = -1; }
|
||||
else { $alt = (int) (log($item[4])/log(2)); }
|
||||
|
||||
$base = -1;
|
||||
if (array_key_exists($surface,$word)) {
|
||||
$base = $word[$surface]["log_count"];
|
||||
}
|
||||
|
||||
$alt -= $base;
|
||||
if ($alt > $max_alt_log_count) { $max_alt_log_count = $alt; }
|
||||
if ($alt < $min_alt_log_count) { $min_alt_log_count = $alt; }
|
||||
|
||||
if (!array_key_exists($alt,$matrix[$base])) {
|
||||
$matrix[$base][$alt] = array();
|
||||
$matrix[$base][$alt]["precision1"] = 0;
|
||||
$matrix[$base][$alt]["delete1"] = 0;
|
||||
$matrix[$base][$alt]["total1"] = 0;
|
||||
$matrix[$base][$alt]["coverage1"] = 0;
|
||||
$matrix[$base][$alt]["precision2"] = 0;
|
||||
$matrix[$base][$alt]["delete2"] = 0;
|
||||
$matrix[$base][$alt]["total2"] = 0;
|
||||
$matrix[$base][$alt]["coverage2"] = 0;
|
||||
}
|
||||
# ignore mismatches in source words due to tokenization / casing
|
||||
if (array_key_exists($surface,$word)) {
|
||||
$matrix[$base][$alt]["precision1"] += $word[$surface]["precision"];
|
||||
$matrix[$base][$alt]["delete1"] += $word[$surface]["delete"];
|
||||
$matrix[$base][$alt]["total1"] += $word[$surface]["total"];
|
||||
$matrix[$base][$alt]["coverage1"] += $word[$surface]["count"];
|
||||
$matrix[$base][$alt]["precision2"] += $item[0];
|
||||
$matrix[$base][$alt]["delete2"] += $item[1];
|
||||
$matrix[$base][$alt]["total2"] += $item[2];
|
||||
$matrix[$base][$alt]["coverage2"] += $item[4];
|
||||
}
|
||||
}
|
||||
|
||||
# make table
|
||||
print "<table border=1 cellspacing=0 cellpadding=0><tr><td> </td>";
|
||||
for($base=-1;$base<=$max_base_log_count;$base++) {
|
||||
print "<td align=center>$base</td>";
|
||||
}
|
||||
print "<td></td></tr>";
|
||||
for($alt=$max_alt_log_count;$alt>=$min_alt_log_count;$alt--) {
|
||||
print "<tr><td>$alt</td>";
|
||||
for($base=-1;$base<=$max_base_log_count;$base++) {
|
||||
print "<td align=center valign=center>";
|
||||
if (array_key_exists($base,$matrix) &&
|
||||
array_key_exists($alt,$matrix[$base])) {
|
||||
#print $matrix[$base][$alt]["precision1"]."->".
|
||||
# $matrix[$base][$alt]["precision2"]."<br>";
|
||||
#print $matrix[$base][$alt]["delete1"]."->".
|
||||
# $matrix[$base][$alt]["delete2"]."<br>";
|
||||
#print $matrix[$base][$alt]["total1"]."->".
|
||||
# $matrix[$base][$alt]["total2"]."<br>";
|
||||
$scale = 30;
|
||||
$total = $matrix[$base][$alt]["total1"];
|
||||
if ($matrix[$base][$alt]["total2"] > $total) {
|
||||
$total = $matrix[$base][$alt]["total2"];
|
||||
}
|
||||
$total = (int)(sqrt($total*$scale));
|
||||
if ($total>0) {
|
||||
$prec1 = $matrix[$base][$alt]["precision1"]*$scale;
|
||||
$prec2 = $matrix[$base][$alt]["precision2"]*$scale;
|
||||
if ($prec1 > $prec2) {
|
||||
$prec_base = (int)(sqrt($prec1));
|
||||
$prec_imp = (int)(sqrt($prec1-$prec2));
|
||||
$prec_color = "255,100,100";
|
||||
}
|
||||
else {
|
||||
$prec_base = (int)(sqrt($prec2));
|
||||
$prec_imp = (int)(sqrt($prec2-$prec1));
|
||||
$prec_color = "100,255,100";
|
||||
}
|
||||
$prec_base_top = (int)(($total-$prec_base)/2);
|
||||
$prec_imp_top = (int)(($total-$prec_imp)/2);
|
||||
|
||||
$del1 = $matrix[$base][$alt]["delete1"]*$scale;
|
||||
$del2 = $matrix[$base][$alt]["delete2"]*$scale;
|
||||
if ($del1 > $del2) {
|
||||
$del_base = $del1;
|
||||
$del_imp = $del1-$del2;
|
||||
$del_color = "150,100,255";
|
||||
}
|
||||
else {
|
||||
$del_base = $del2;
|
||||
$del_imp = $del2-$del1;
|
||||
$del_color = "100,200,200";
|
||||
}
|
||||
$del_base_height = (int)($del_base/$total);
|
||||
$del_imp_height = (int)($del_imp/$total);
|
||||
|
||||
$name = "matrix-$base-$alt";
|
||||
#print "$total/$prec1/$prec2 -> $prec_base/$prec_imp<br>";
|
||||
print "<a href=\"javascript:generic_show_diff('CoverageMatrixDetails','base=$base&alt=$alt')\">";
|
||||
print "<canvas id=\"$name\" width=\"$total\" height=\"".($total+$del_base_height+$del_imp_height)."\"></canvas></a>";
|
||||
print "<script language=\"javascript\">
|
||||
var canvas = document.getElementById(\"$name\");
|
||||
var ctx = canvas.getContext(\"2d\");
|
||||
ctx.fillStyle = \"rgb(200,200,200)\";
|
||||
ctx.fillRect (0, 0, $total, $total);
|
||||
ctx.fillStyle = \"rgb(200,200,0)\";
|
||||
ctx.fillRect ($prec_base_top, $prec_base_top, $prec_base, $prec_base);
|
||||
ctx.fillStyle = \"rgb($prec_color)\";
|
||||
ctx.fillRect ($prec_imp_top, $prec_imp_top, $prec_imp, $prec_imp);
|
||||
ctx.fillStyle = \"rgb(100,100,255)\";
|
||||
ctx.fillRect (0, $total, $total, $del_base_height);
|
||||
ctx.fillStyle = \"rgb($del_color)\";
|
||||
ctx.fillRect (0, ".($total+$del_base_height).", $total, $del_imp_height);
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
print "</td>";
|
||||
}
|
||||
print "<td>$alt</td></tr>";
|
||||
}
|
||||
print "<tr><td></td>";
|
||||
for($base=-1;$base<=$max_base_log_count;$base++) {
|
||||
print "<td align=center>$base</td>";
|
||||
}
|
||||
print "<td></td></tr></table><div id=\"CoverageMatrixDetails\"></div>";
|
||||
}
|
||||
|
||||
function precision_by_coverage_diff_matrix_details() {
|
||||
$alt = $_GET["alt"];
|
||||
$base = $_GET["base"];
|
||||
|
||||
$impact_total = 0;
|
||||
$data = file(get_current_analysis_filename("precision","precision-by-input-word"));
|
||||
$word = array(); $class = array();
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$line = rtrim($data[$i]);
|
||||
$item = split("\t",$line);
|
||||
if ($item[4] == 0) { $log_count = -1; }
|
||||
else { $log_count = (int) (log($item[4])/log(2)); }
|
||||
if ($log_count == $base) {
|
||||
$surface = $item[5];
|
||||
$word[$surface] = array();
|
||||
$word[$surface]["precision"] = $item[0]; # number of precise translations
|
||||
$word[$surface]["delete"] = $item[1]; # number of deleted
|
||||
$word[$surface]["total"] = $item[2]; # number of all translations
|
||||
$word[$surface]["coverage"] = $item[4]; # count in training corpus
|
||||
}
|
||||
$impact_total += $item[2];
|
||||
}
|
||||
|
||||
print "<table border=1><tr><td align=center> </td><td align=center colspan=3>Precision</td><td align=center colspan=2>Precision Impact</td><td align=center colspan=3>Delete</td><td align=center colspan=2>Delete Impact</td></tr>\n";
|
||||
|
||||
# get alternative data
|
||||
$data = file(get_current_analysis_filename2("precision","precision-by-input-word"));
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$line = rtrim($data[$i]);
|
||||
$item = split("\t",$line);
|
||||
if ($item[4] == 0) { $log_count = -1; }
|
||||
else { $log_count = (int) (log($item[4])/log(2)); }
|
||||
$surface = $item[5];
|
||||
if ($log_count-$base == $alt && array_key_exists($surface,$word)) {
|
||||
$precision = $item[0]; # number of precise translations
|
||||
$delete = $item[1]; # number of deleted
|
||||
$total = $item[3]; # number of all translations + deletions
|
||||
$coverage = $item[4]; # count in training corpus
|
||||
$surface = $item[5];
|
||||
$out = sprintf("%07d", (1-($precision-$word[$surface]["precision"])/$impact_total)*1000000);
|
||||
$out .= "\t<tr><td align=cente>$surface</td>";
|
||||
$out .= sprintf("<td align=right>%.1f%s</td><td align=right>%+.1f%s</td><td align=right><font size=-1>%+.1f/%d</font></td>",
|
||||
$precision/$total*100,"%",
|
||||
($precision-$word[$surface]["precision"])/$total*100,"%",
|
||||
$precision-$word[$surface]["precision"],$total);
|
||||
$out .= sprintf("<td align=right>%+.2f%s</td><td align=right><font size=-1>%+.1f/%d</font></td>",
|
||||
($precision-$word[$surface]["precision"])/$impact_total*100,"%",
|
||||
$precision-$word[$surface]["precision"],$impact_total);
|
||||
$out .= sprintf("<td align=right>%.1f%s</td><td align=right>%+.1f%s</td><td align=right><font size=-1>%+.1f/%d</font></td>",
|
||||
$delete/$total*100,"%",
|
||||
($delete-$word[$surface]["delete"])/$total*100,"%",
|
||||
$delete-$word[$surface]["delete"],$total);
|
||||
$out .= sprintf("<td align=right>%+.2f%s</td><td align=right><font size=-1>%+.1f/%d</font></td>",
|
||||
($delete-$word[$surface]["delete"])/$impact_total*100,"%",
|
||||
$delete-$word[$surface]["delete"],$impact_total);
|
||||
$out .= "</tr>";
|
||||
$all_out[] = $out;
|
||||
}
|
||||
}
|
||||
sort($all_out);
|
||||
foreach($all_out as $out) { $o = explode("\t",$out); print $o[1]; }
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
function precision_by_coverage_diff_graph($name,$log_info,$log_info_new,$total,$img_width,$sort_type) {
|
||||
$keys = array_keys($log_info);
|
||||
@ -502,12 +742,22 @@ function bleu_diff() {
|
||||
print "</font><BR>\n";
|
||||
|
||||
bleu_diff_annotation();
|
||||
print "<font size=-1>";
|
||||
print "<A HREF=\"javascript:diff('bleu','" . $_GET['sort'] . "',5+$count)\">more</A> ";
|
||||
print "</font><BR>\n";
|
||||
}
|
||||
|
||||
function bleu_diff_annotation() {
|
||||
global $set,$id,$id2,$dir;
|
||||
|
||||
// load data
|
||||
// load input
|
||||
$input_annotation = file(get_analysis_filename($dir,$set,$id,"coverage","input-annotation"));
|
||||
for($i=0;$i<count($input_annotation);$i++) {
|
||||
$item = split("\t",$input_annotation[$i]);
|
||||
$input[$i] = $item[0];
|
||||
}
|
||||
|
||||
// load translations
|
||||
for($idx=0;$idx<2;$idx++) {
|
||||
$data = file(get_analysis_filename($dir,$set,$idx?$id2:$id,"basic","bleu-annotation"));
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
@ -575,6 +825,7 @@ function bleu_diff_annotation() {
|
||||
// display
|
||||
for($i=0;$i<$count && $i<count($annotation);$i++) {
|
||||
$line = $annotation[$i];
|
||||
print "<font size=-2>[src]</font> ".$input[$line["id"]]."<br>";
|
||||
|
||||
$word_with_score1 = split(" ",$line["system1"]);
|
||||
$word_with_score0 = split(" ",$line["system0"]);
|
||||
|
108
scripts/ems/web/base64.js
Normal file
108
scripts/ems/web/base64.js
Normal file
@ -0,0 +1,108 @@
|
||||
var END_OF_INPUT = -1;
|
||||
|
||||
var base64Chars = new Array(
|
||||
'A','B','C','D','E','F','G','H',
|
||||
'I','J','K','L','M','N','O','P',
|
||||
'Q','R','S','T','U','V','W','X',
|
||||
'Y','Z','a','b','c','d','e','f',
|
||||
'g','h','i','j','k','l','m','n',
|
||||
'o','p','q','r','s','t','u','v',
|
||||
'w','x','y','z','0','1','2','3',
|
||||
'4','5','6','7','8','9','+','/'
|
||||
);
|
||||
|
||||
var reverseBase64Chars = new Array();
|
||||
for (var i=0; i < base64Chars.length; i++){
|
||||
reverseBase64Chars[base64Chars[i]] = i;
|
||||
}
|
||||
|
||||
var base64Str;
|
||||
var base64Count;
|
||||
function setBase64Str(str){
|
||||
base64Str = str;
|
||||
base64Count = 0;
|
||||
}
|
||||
function readBase64(){
|
||||
if (!base64Str) return END_OF_INPUT;
|
||||
if (base64Count >= base64Str.length) return END_OF_INPUT;
|
||||
var c = base64Str.charCodeAt(base64Count) & 0xff;
|
||||
base64Count++;
|
||||
return c;
|
||||
}
|
||||
function encodeBase64(str){
|
||||
setBase64Str(str);
|
||||
var result = '';
|
||||
var inBuffer = new Array(3);
|
||||
var lineCount = 0;
|
||||
var done = false;
|
||||
while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
|
||||
inBuffer[1] = readBase64();
|
||||
inBuffer[2] = readBase64();
|
||||
result += (base64Chars[ inBuffer[0] >> 2 ]);
|
||||
if (inBuffer[1] != END_OF_INPUT){
|
||||
result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
|
||||
if (inBuffer[2] != END_OF_INPUT){
|
||||
result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
|
||||
result += (base64Chars [inBuffer[2] & 0x3F]);
|
||||
} else {
|
||||
result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
|
||||
result += ('=');
|
||||
done = true;
|
||||
}
|
||||
} else {
|
||||
result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
|
||||
result += ('=');
|
||||
result += ('=');
|
||||
done = true;
|
||||
}
|
||||
lineCount += 4;
|
||||
if (lineCount >= 76){
|
||||
result += ('\n');
|
||||
lineCount = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function readReverseBase64(){
|
||||
if (!base64Str) return END_OF_INPUT;
|
||||
while (true){
|
||||
if (base64Count >= base64Str.length) return END_OF_INPUT;
|
||||
var nextCharacter = base64Str.charAt(base64Count);
|
||||
base64Count++;
|
||||
if (reverseBase64Chars[nextCharacter]){
|
||||
return reverseBase64Chars[nextCharacter];
|
||||
}
|
||||
if (nextCharacter == 'A') return 0;
|
||||
}
|
||||
return END_OF_INPUT;
|
||||
}
|
||||
function ntos(n){
|
||||
n=n.toString(16);
|
||||
if (n.length == 1) n="0"+n;
|
||||
n="%"+n;
|
||||
return unescape(n);
|
||||
}
|
||||
|
||||
function decodeBase64(str){
|
||||
setBase64Str(str);
|
||||
var result = "";
|
||||
var inBuffer = new Array(4);
|
||||
var done = false;
|
||||
while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
|
||||
&& (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
|
||||
inBuffer[2] = readReverseBase64();
|
||||
inBuffer[3] = readReverseBase64();
|
||||
result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
|
||||
if (inBuffer[2] != END_OF_INPUT){
|
||||
result += ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
|
||||
if (inBuffer[3] != END_OF_INPUT){
|
||||
result += ntos((((inBuffer[2] << 6) & 0xff) | inBuffer[3]));
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
BIN
scripts/ems/web/favicon.ico
Normal file
BIN
scripts/ems/web/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -5,10 +5,12 @@ require("overview.php");
|
||||
require("analysis.php");
|
||||
require("analysis_diff.php");
|
||||
require("diff.php");
|
||||
require("sgviz.php");
|
||||
|
||||
function head($title) {
|
||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html><head><title>'.$title.'</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script language="javascript" src="/javascripts/prototype.js"></script>
|
||||
<script language="javascript" src="/javascripts/scriptaculous.js"></script>
|
||||
<script language="javascript" src="hierarchical-segmentation.js"></script>
|
||||
@ -43,8 +45,11 @@ if (array_key_exists("setup",$_POST) || array_key_exists("setup",$_GET)) {
|
||||
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 == "CoverageMatrixDetails_show") { precision_by_coverage_diff_matrix_details(); }
|
||||
else if ($action == "SegmentationSummary_show") { segmentation_summary(); }
|
||||
else if ($action == "biconcor") { biconcor(base64_decode($_GET["phrase"])); }
|
||||
else if ($action == "sgviz") { sgviz($_GET["sentence"]); }
|
||||
else if ($action == "sgviz_data") { sgviz_data($_GET["sentence"]); }
|
||||
else { print "ERROR! $action"; }
|
||||
}
|
||||
else if (array_key_exists("analysis_diff_home",$_GET)) {
|
||||
|
@ -65,7 +65,13 @@ function load_experiment_info() {
|
||||
}
|
||||
|
||||
krsort($experiment);
|
||||
ksort($evalset);
|
||||
uksort($evalset,"evalsetsort");
|
||||
}
|
||||
|
||||
function evalsetsort($a,$b) {
|
||||
if ($a == "avg") { return -1; }
|
||||
if ($b == "avg") { return 1; }
|
||||
return strcmp($a,$b);
|
||||
}
|
||||
|
||||
function load_parameter($run) {
|
||||
@ -187,7 +193,7 @@ function get_analysis_version($dir,$set,$id) {
|
||||
if (file_exists("$dir/steps/$id/REPORTING_report.$id")) {
|
||||
$report = file("$dir/steps/$id/REPORTING_report.$id.INFO");
|
||||
foreach ($report as $line) {
|
||||
if (preg_match("/\# reuse run (\d+) for EVALUATION:(.+):analysis/",$line,$match) &&
|
||||
if (preg_match("/\# reuse run (\d+) for EVALUATION:(.+):analysis$/",$line,$match) &&
|
||||
$match[2] == $set) {
|
||||
if (file_exists("$prefix.$match[1]/summary")) {
|
||||
$analysis_version[$id][$set]["basic"] = $match[1];
|
||||
|
@ -13,7 +13,7 @@ function setup() {
|
||||
print "<TR><TD><A HREF=\"?setup=$dir[0]\">$dir[0]</A></TD><TD>$dir[1]</TD><TD>$dir[2]</TD><TD>$dir[3]</TD></TR>\n";
|
||||
}
|
||||
print "</TABLE>\n";
|
||||
print "<P>To add experiment, edit setup in web directory";
|
||||
print "<P>To add experiment, edit the file 'setup' in the web directory.";
|
||||
}
|
||||
|
||||
function overview() {
|
||||
@ -134,7 +134,9 @@ function overview() {
|
||||
print "var best_score = [];\n";
|
||||
reset($evalset);
|
||||
while (list($set,$dummy) = each($evalset)) {
|
||||
print "best_score[\"$set\"] = ".$best[$set].";\n";
|
||||
if ($best[$set] != "" && $best[$set]>0) {
|
||||
print "best_score[\"$set\"] = ".$best[$set].";\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -282,28 +284,29 @@ function output_score($id,$info) {
|
||||
|
||||
$each_score = explode(" ; ",$score);
|
||||
for($i=0;$i<count($each_score);$i++) {
|
||||
if (preg_match('/([\d\(\)\.\s]+) (\S*)/',$each_score[$i],$match)) {
|
||||
//if ($i>0) { print " "; }
|
||||
$opened_a_tag = 0;
|
||||
if ($set != "avg") {
|
||||
if (file_exists("$dir/evaluation/$set.cleaned.$id")) {
|
||||
print "<a href=\"?$state&show=evaluation/$set.cleaned.$id\">";
|
||||
$opened_a_tag = 1;
|
||||
}
|
||||
else if (file_exists("$dir/evaluation/$set.output.$id")) {
|
||||
print "<a href=\"?$state&show=evaluation/$set.output.$id\">";
|
||||
$opened_a_tag = 1;
|
||||
}
|
||||
}
|
||||
if ($set == "avg" && count($each_score)>1) { print $match[2].": "; }
|
||||
print "<div title=". $match[2] ." class=". $match[2] .">".$match[1]."</div>";
|
||||
if ($opened_a_tag) { print "</a>"; }
|
||||
if (preg_match('/([\d\(\)\.\s]+) (BLEU[\-c]*)/',$each_score[$i],$match) ||
|
||||
preg_match('/([\d\(\)\.\s]+) (IBM[\-c]*)/',$each_score[$i],$match)) {
|
||||
if ($i>0) { print "<BR>"; }
|
||||
$opened_a_tag = 0;
|
||||
if ($set != "avg") {
|
||||
if (file_exists("$dir/evaluation/$set.cleaned.$id")) {
|
||||
print "<a href=\"?$state&show=evaluation/$set.cleaned.$id\">";
|
||||
$opened_a_tag = 1;
|
||||
}
|
||||
else if (file_exists("$dir/evaluation/$set.output.$id")) {
|
||||
print "<a href=\"?$state&show=evaluation/$set.output.$id\">";
|
||||
$opened_a_tag = 1;
|
||||
}
|
||||
}
|
||||
if ($set == "avg" && count($each_score)>1) { print $match[2].": "; }
|
||||
print $match[1];
|
||||
if ($opened_a_tag) { print "</a>"; }
|
||||
}
|
||||
else {
|
||||
print "-";
|
||||
print "-";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "</td>";
|
||||
if ($has_analysis && array_key_exists($set,$has_analysis)) {
|
||||
print "<td align=center>";
|
||||
|
1703
scripts/ems/web/sgviz.js
Normal file
1703
scripts/ems/web/sgviz.js
Normal file
File diff suppressed because it is too large
Load Diff
65
scripts/ems/web/sgviz.php
Normal file
65
scripts/ems/web/sgviz.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
function sgviz($sentence) {
|
||||
global $setup,$dir,$id,$set;
|
||||
?><html><head><title>Search Graph Visualization, Sentence <?php $sentence ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script language="javascript" src="/javascripts/prototype.js"></script></head>
|
||||
<body><svg id="sg" height="500" width="900" xmlns="http://www.w3.org/2000/svg"><g id="chart"></g></svg>
|
||||
<script>
|
||||
var sg = document.getElementById("sg");
|
||||
sg.setAttribute("width", window.innerWidth-20);
|
||||
sg.setAttribute("height",window.innerHeight-20);
|
||||
<?php
|
||||
// read input sentence
|
||||
$handle = fopen(get_current_analysis_filename("coverage","input-annotation"),"r");
|
||||
for($i=0;$i<$sentence;$i++) { $line = fgets($handle); }
|
||||
$line = fgets($handle);
|
||||
fclose($handle);
|
||||
$l = explode("\t",$line);
|
||||
print "input=[\"<s>\",\"".join("\",\"",explode(" ",addslashes($l[0])))."\",\"</s>\"];\n";
|
||||
?>
|
||||
</script>
|
||||
<script language="javascript" src="sgviz.js"></script>
|
||||
<script>
|
||||
var edge = new Array();
|
||||
function test() {
|
||||
alert("test");
|
||||
}
|
||||
new Ajax.Request('?analysis=sgviz_data'
|
||||
+ '&setup=<?php print $setup ?>'
|
||||
+ '&id=<?php print $id ?>'
|
||||
+ '&set=<?php print $set ?>'
|
||||
+ '&sentence=<?php print $sentence; ?>',
|
||||
{
|
||||
onSuccess: function(transport) {
|
||||
var json = transport.responseText.evalJSON();
|
||||
edge = json.edge;
|
||||
process_hypotheses();
|
||||
},
|
||||
method: "post"
|
||||
});
|
||||
</script></body></html>
|
||||
<?php
|
||||
// read graph
|
||||
//$file = get_current_analysis_filename("basic","search-graph")."/graph.$sentence";
|
||||
//$handle = fopen($file,"r");
|
||||
//while (($line = fgets($handle)) !== false) {
|
||||
// $e = explode("\t",addslashes(chop($line)));
|
||||
// print "edge[$e[0]]=new Array($e[1],$e[2],$e[3],\"$e[4]\",\"$e[5]\",\"$e[6]\",$e[7],$e[8],$e[9],\"$e[10]\");\n";
|
||||
//}
|
||||
//fclose($handle);
|
||||
}
|
||||
|
||||
function sgviz_data($sentence) {
|
||||
header('Content-type: application/json');
|
||||
$file = get_current_analysis_filename("basic","search-graph")."/graph.$sentence";
|
||||
|
||||
$handle = fopen($file,"r");
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$e = explode("\t",addslashes(chop($line)));
|
||||
$edge[$e[0]] = array($e[1],$e[2],$e[3],$e[4],$e[5],$e[6],$e[7],$e[8],$e[9],$e[10]);
|
||||
}
|
||||
$return['edge'] = $edge;
|
||||
print json_encode($return);
|
||||
exit();
|
||||
}
|
Loading…
Reference in New Issue
Block a user