diff options
author | Jeroen Vermeulen <jtv@precisiontranslationtools.com> | 2015-05-17 16:04:04 +0300 |
---|---|---|
committer | Jeroen Vermeulen <jtv@precisiontranslationtools.com> | 2015-05-17 16:04:04 +0300 |
commit | a25193cc5da6a271c4676e843db80ee19221822a (patch) | |
tree | db764696f2e663016a9ab87a95846501c585b4aa /scripts/ems/web | |
parent | 108da163745699e724f581c3d33b1e8a5e26a9e9 (diff) |
Fix a lot of lint, mostly trailing whitespace.
This is lint reported by the new lint-checking functionality in beautify.py.
(We can change to a different lint checker if we have a better one, but it
would probably still flag these same problems.)
Lint checking can help a lot, but only if we get the lint under control.
Diffstat (limited to 'scripts/ems/web')
-rw-r--r-- | scripts/ems/web/analysis.php | 80 | ||||
-rw-r--r-- | scripts/ems/web/analysis_diff.php | 62 | ||||
-rw-r--r-- | scripts/ems/web/bilingual-concordance.css | 56 | ||||
-rw-r--r-- | scripts/ems/web/comment.php | 2 | ||||
-rw-r--r-- | scripts/ems/web/diff.php | 2 | ||||
-rw-r--r-- | scripts/ems/web/hierarchical-segmentation.css | 8 | ||||
-rw-r--r-- | scripts/ems/web/hierarchical-segmentation.js | 4 | ||||
-rw-r--r-- | scripts/ems/web/index.php | 4 | ||||
-rw-r--r-- | scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js | 132 | ||||
-rw-r--r-- | scripts/ems/web/javascripts/sound.js | 2 | ||||
-rw-r--r-- | scripts/ems/web/javascripts/unittest.js | 132 | ||||
-rw-r--r-- | scripts/ems/web/lib.php | 20 | ||||
-rw-r--r-- | scripts/ems/web/overview.php | 24 | ||||
-rwxr-xr-x | scripts/ems/web/progress.perl | 2 | ||||
-rw-r--r-- | scripts/ems/web/sgviz.js | 178 | ||||
-rw-r--r-- | scripts/ems/web/sgviz.php | 4 |
16 files changed, 356 insertions, 356 deletions
diff --git a/scripts/ems/web/analysis.php b/scripts/ems/web/analysis.php index 00bb9e15f..57776dd22 100644 --- a/scripts/ems/web/analysis.php +++ b/scripts/ems/web/analysis.php @@ -1,4 +1,4 @@ -<?php +<?php # main page frame, triggers the loading of parts function show_analysis() { @@ -122,7 +122,7 @@ function precision_by_coverage() { $log_info[$log_count]["precision"] += $item[1]; $log_info[$log_count]["delete"] += $item[2]; $log_info[$log_count]["length"] += $item[3]; - $log_info[$log_count]["total"] += $item[4]; + $log_info[$log_count]["total"] += $item[4]; } print "<h4>By log<sub>2</sub>-count in the training corpus</h4>"; precision_by_coverage_graph("byCoverage",$log_info,$total,$img_width,SORT_NUMERIC); @@ -159,7 +159,7 @@ function precision_by_coverage_factored($img_width,$total,$file,$factor_id) { $log_info_factored[$factor][$log_count]["precision"] += $item[2]; $log_info_factored[$factor][$log_count]["delete"] += $item[3]; $log_info_factored[$factor][$log_count]["length"] += $item[4]; - $log_info_factored[$factor][$log_count]["total"] += $item[5]; + $log_info_factored[$factor][$log_count]["total"] += $item[5]; } print "<h4>By factor ".factor_name("input",$factor_id)."</h4>"; precision_by_coverage_graph("byFactor",$info_factored_sum,$total,$img_width,SORT_STRING); @@ -203,7 +203,7 @@ function precision_by_word($type) { if ($byCoverage != -2 && $byCoverage != $log_count) { continue; } - + //# filter for factor $word = $item[5]; if ($byFactor != "false" && $byFactor != $item[6]) { @@ -231,7 +231,7 @@ function precision_by_word($type) { function precision_by_coverage_latex($name,$log_info,$total,$img_width,$sort_type) { $keys = array_keys($log_info); sort($keys,$sort_type); - + $img_width /= 100; print "<div id=\"LatexToggle$name\" onClick=\"document.getElementById('Latex$name').style.display = 'block'; this.style.display = 'none';\" style=\"display:none;\"><font size=-2>(show LaTeX)</font></div>\n"; print "<div id=\"Latex$name\" style=\"display:none;\">\n"; @@ -242,7 +242,7 @@ function precision_by_coverage_latex($name,$log_info,$total,$img_width,$sort_typ $height = 1.8-$line/10*1.8; print "\\draw[thin,lightgray] (0.2,-$height) "; print "node[anchor=east,black] {".$line."0\\%} -- "; - print "($img_width,-$height) ;<br>\n"; + print "($img_width,-$height) ;<br>\n"; } print "% co-ordinates for deletion<br>\n"; for($line=0;$line<=3;$line++) { @@ -251,7 +251,7 @@ function precision_by_coverage_latex($name,$log_info,$total,$img_width,$sort_typ if ($line != 0) { print "node[anchor=east,black] {".$line."0\\%} "; } - print "-- ($img_width,-$height) ;<br>\n"; + print "-- ($img_width,-$height) ;<br>\n"; } print "% boxes<br>\n"; @@ -265,13 +265,13 @@ function precision_by_coverage_latex($name,$log_info,$total,$img_width,$sort_typ $width += $x; $height += $y; - + print "\\filldraw[very thin,gray] ($x,-$y) rectangle($width,-$height) ;<br>"; print "\\draw[very thin,black] ($x,-$y) rectangle($width,-$height);<br>"; if ($width-$x>.1) { print "\\draw (".(($x+$width)/2).",-1.8) node[anchor=north,black] {".$i."};<br>"; } - + $del_ratio = $log_info[$i]["delete"]/$log_info[$i]["total"]; $height = $del_ratio*1.80; @@ -281,10 +281,10 @@ function precision_by_coverage_latex($name,$log_info,$total,$img_width,$sort_typ print "\\filldraw[very thin,lightgray] ($x,-2) rectangle($width,-$height);<br>\n"; print "\\draw[very thin,black] ($x,-2) rectangle($width,-$height);<br>\n"; - $total_so_far += $log_info[$i]["total"]; + $total_so_far += $log_info[$i]["total"]; } print "\\end{tikzpicture}</code>"; - print "</div>"; + print "</div>"; } function precision_by_coverage_graph($name,$log_info,$total,$img_width,$sort_type) { @@ -351,7 +351,7 @@ ctx.font = '9px serif'; print "ctx.fillRect ($x, 200, $width, $height);"; $total_so_far += $log_info[$i]["total"]; - + if ($width>3) { print "ctx.fillStyle = \"rgb(0,0,0)\";"; // print "ctx.rotate(-1.5707);"; @@ -410,7 +410,7 @@ function ngram_summary() { $info["$type-1-correct"], $info["$type-2-correct"], $info["$type-3-correct"], - $info["$type-4-correct"]); + $info["$type-4-correct"]); printf("<tr><td> </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,'%', @@ -483,7 +483,7 @@ function ngram_show($type) { $data = file(get_current_analysis_filename("basic","n-gram-$type.$order")); for($i=0;$i<count($data);$i++) { $item = split("\t",$data[$i]); - $line["total"] = $item[0]; + $line["total"] = $item[0]; $line["correct"] = $item[1]; $line["ngram"] = $item[2]; $ngram[] = $line; @@ -496,7 +496,7 @@ function ngram_show($type) { $sort = 'ratio_worst'; $smooth = 1; } - + // sort index for($i=0;$i<count($ngram);$i++) { if ($sort == "abs_worst") { @@ -806,7 +806,7 @@ function segmentation_summary() { if (array_key_exists($in,$count) && array_key_exists($out,$count[$in])) { $c = $count[$in][$out]; - } + } else { $c = 0; } printf("<td align=right nowrap>%d (%.1f%s)</td>",$c,100*$c/$total,"%"); } @@ -885,8 +885,8 @@ function bleu_show() { $count = $_GET['count']; if ($count == 0) { $count = 5; } - $filter = ""; - if (array_key_exists("filter",$_GET)) { + $filter = ""; + if (array_key_exists("filter",$_GET)) { $filter = base64_decode($_GET['filter']); } @@ -924,7 +924,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> | "; @@ -950,28 +950,28 @@ function sentence_annotation($count,$filter) { $word = explode(" ",$item[0]); $keep = 0; for($j=0;$j<count($word);$j++) { - if ($word[$j] == $filter) { - $keep = 1; + if ($word[$j] == $filter) { + $keep = 1; } } - if (!$keep) { $filtered[$i] = 1; } + if (!$keep) { $filtered[$i] = 1; } } - } + } } - - # load bleu scores + + # load bleu scores $data = file(get_current_analysis_filename("basic","bleu-annotation")); for($i=0;$i<count($data);$i++) { $item = split("\t",$data[$i]); if (! array_key_exists($item[1],$filtered)) { - $line["bleu"] = $item[0]; - $line["id"] = $item[1]; + $line["bleu"] = $item[0]; + $line["id"] = $item[1]; $line["system"] = $item[2]; - $line["reference"] = ""; + $line["reference"] = ""; for($j=3;$j<count($item);$j++) { if ($j>3) { $line["reference"] .= "<br>"; }; $line["reference"] .= $item[$j]; - } + } $bleu[] = $line; } } @@ -987,7 +987,7 @@ function sentence_annotation($count,$filter) { else if ($sort == "worst" || $sort == "75") { $a_idx = $a["bleu"]; $b_idx = $b["bleu"]; - if ($a_idx == $b_idx) { + if ($a_idx == $b_idx) { $a_idx = $b["id"]; $b_idx = $a["id"]; } @@ -995,7 +995,7 @@ function sentence_annotation($count,$filter) { else if ($sort == "best" || $sort == "avg" || $sort == "25") { $a_idx = -$a["bleu"]; $b_idx = -$b["bleu"]; - if ($a_idx == $b_idx) { + if ($a_idx == $b_idx) { $a_idx = $a["id"]; $b_idx = $b["id"]; } @@ -1021,7 +1021,7 @@ function sentence_annotation($count,$filter) { $retained = array(); for($i=$offset;$i<$count+$offset && $i<count($bleu);$i++) { - $line = $bleu[$i]; + $line = $bleu[$i]; $retained[$line["id"]] = 1; } @@ -1056,7 +1056,7 @@ function sentence_annotation($count,$filter) { list($sentence,$brackets,$nt,$words) = split("\t",$data[$i]); if ($sentence != $last_sentence) { $span = 0; } $last_sentence = $sentence; - if (array_key_exists($sentence,$retained)) { + if (array_key_exists($sentence,$retained)) { $segmentation[$sentence][$span]["brackets"] = $brackets; # $segmentation[$sentence][$span]["nt"] = $nt; $segmentation[$sentence][$span]["words"] = rtrim($words); @@ -1083,7 +1083,7 @@ function sentence_annotation($count,$filter) { list($sentence,$brackets,$nt,$words) = split("\t",$data[$i]); if ($sentence != $last_sentence) { $span = 0; } $last_sentence = $sentence; - if (array_key_exists($sentence,$retained)) { + if (array_key_exists($sentence,$retained)) { $segmentation_out[$sentence][$span]["brackets"] = $brackets; $segmentation_out[$sentence][$span]["nt"] = $nt; $segmentation_out[$sentence][$span]["words"] = rtrim($words); @@ -1109,7 +1109,7 @@ function sentence_annotation($count,$filter) { list($sentence,$depth,$start_div,$end_div,$start_div_in,$end_div_in,$children) = split(" ",$data[$i]); if ($sentence != $last_sentence) { $n = 0; } $last_sentence = $sentence; - if (array_key_exists($sentence,$retained)) { + if (array_key_exists($sentence,$retained)) { $node[$sentence][$n]['depth'] = $depth; $node[$sentence][$n]['start_div'] = $start_div; $node[$sentence][$n]['end_div'] = $end_div; @@ -1119,10 +1119,10 @@ function sentence_annotation($count,$filter) { $n++; } } - } + } # display - if ($filter != "") { + if ($filter != "") { print " (".(count($input)-count($filtered))." retaining)"; } print "</font><BR>\n"; @@ -1130,7 +1130,7 @@ function sentence_annotation($count,$filter) { $biconcor = get_biconcor_version($dir,$set,$id); //print "<div id=\"debug\">$sort / $offset</div>"; for($i=$offset;$i<$count+$offset && $i<count($bleu);$i++) { - $line = $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(); @@ -1279,7 +1279,7 @@ function input_annotation($sentence,$input,$segmentation,$filter) { print "<tr><td colspan=".($sep_end-$sep_start)."><div style=\"position:relative; z-index:1;\">"; for($j=$sep_start;$j<$sep_end;$j++) { if ($segmentation && array_key_exists($j,$segmentation["input_start"])) { - $id = $segmentation["input_start"][$j]; + $id = $segmentation["input_start"][$j]; print "<span id=\"input-$sentence-$id\" style=\"border-color:#000000; border-style:solid; border-width:1px;\" onmouseover=\"highlight_phrase($sentence,$id);\" onmouseout=\"lowlight_phrase($sentence,$id);\">"; } if (array_key_exists($j,$coverage)) { @@ -1413,7 +1413,7 @@ function annotation_hierarchical($sentence,$segmentation,$segmentation_out,$node print "<span style=\"opacity:0\">|</span>"; } - $span_word = array(); + $span_word = array(); if ($words != "") { $span_word = split(" ",$words); } for($w=0;$w<count($span_word);$w++) { if ($w > 0) { print " "; } diff --git a/scripts/ems/web/analysis_diff.php b/scripts/ems/web/analysis_diff.php index 2f0947e13..214ae1592 100644 --- a/scripts/ems/web/analysis_diff.php +++ b/scripts/ems/web/analysis_diff.php @@ -1,4 +1,4 @@ -<?php +<?php function diff_analysis() { global $task,$user,$setup,$id,$id2,$set; @@ -15,7 +15,7 @@ function diff_analysis() { print "Run $id2 ($c2) vs $id ($c)"; } print "</h4>"; - + ?><script language="javascript" src="javascripts/prototype.js"></script> <script language="javascript" src="javascripts/scriptaculous.js"></script> <script> @@ -96,9 +96,9 @@ function precision_by_coverage_diff() { $log_info[$log_count]["precision"] += $item[1]; $log_info[$log_count]["delete"] += $item[2]; $log_info[$log_count]["length"] += $item[3]; - $log_info[$log_count]["total"] += $item[4]; + $log_info[$log_count]["total"] += $item[4]; } - $log_info_new = $log_info; + $log_info_new = $log_info; // load base data $data = file(get_current_analysis_filename("precision","precision-by-corpus-coverage")); @@ -154,7 +154,7 @@ function precision_by_coverage_diff_factored($img_width,$total,$file,$factor_id) $log_info_factored[$factor][$log_count]["precision"] += $item[2]; $log_info_factored[$factor][$log_count]["delete"] += $item[3]; $log_info_factored[$factor][$log_count]["length"] += $item[4]; - $log_info_factored[$factor][$log_count]["total"] += $item[5]; + $log_info_factored[$factor][$log_count]["total"] += $item[5]; } $info_factored_new = $info_factored; $info_factored_sum_new = $info_factored_sum; @@ -225,7 +225,7 @@ function precision_by_word_diff($type) { if ($byCoverage != -2 && $byCoverage != $log_count) { continue; } - + //# filter for factor $word = $item[5]; if ($byFactor != "false" && $byFactor != $item[6]) { @@ -258,7 +258,7 @@ function precision_by_word_diff($type) { if ($byCoverage != -2 && $byCoverage != $log_count) { continue; } - + //# filter for factor $word = $item[5]; if ($byFactor != "false" && $byFactor != $item[6]) { @@ -319,7 +319,7 @@ ctx.fillRect (0, 0, $size, $size); $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]["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; } @@ -369,7 +369,7 @@ ctx.fillRect (0, 0, $size, $size); $matrix[$base][$alt]["coverage2"] = 0; } # ignore mismatches in source words due to tokenization / casing - if (array_key_exists($surface,$word)) { + 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"]; @@ -413,14 +413,14 @@ ctx.fillRect (0, 0, $size, $size); $prec_imp = (int)(sqrt($prec1-$prec2)); $prec_color = "255,100,100"; } - else { + 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) { @@ -428,7 +428,7 @@ ctx.fillRect (0, 0, $size, $size); $del_imp = $del1-$del2; $del_color = "150,100,255"; } - else { + else { $del_base = $del2; $del_imp = $del2-$del1; $del_color = "100,200,200"; @@ -470,7 +470,7 @@ ctx.fillRect (0, ".($total+$del_base_height).", $total, $del_imp_height); 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(); @@ -483,7 +483,7 @@ function precision_by_coverage_diff_matrix_details() { $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]["delete"] = $item[1]; # number of deleted $word[$surface]["total"] = $item[2]; # number of all translations $word[$surface]["coverage"] = $item[4]; # count in training corpus } @@ -502,7 +502,7 @@ function precision_by_coverage_diff_matrix_details() { $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 + $delete = $item[1]; # number of deleted $total = $item[3]; # number of all translations + deletions $coverage = $item[4]; # count in training corpus $surface = $item[5]; @@ -527,17 +527,17 @@ function precision_by_coverage_diff_matrix_details() { } } sort($all_out); - foreach($all_out as $out) { $o = explode("\t",$out); print $o[1]; } + 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); sort($keys,$sort_type); - + print "<div id=\"Toggle$name\" onClick=\"document.getElementById('Table$name').style.display = 'none'; this.style.display = 'none';\" style=\"display:none;\"><font size=-2>(hide table)</font></div>\n"; print "<div id=\"Table$name\" style=\"display:none;\">\n"; - 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><td align=center>Length</td></tr>\n"; + 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><td align=center>Length</td></tr>\n"; foreach ($keys as $i) { if (array_key_exists($i,$log_info)) { print "<tr><td align=center>$i</td>"; @@ -595,7 +595,7 @@ ctx.font = '9px serif'; print "ctx.fillRect ($x, 250, $width, $height);"; $total_so_far += $log_info[$i]["total"]; - + if ($width>3) { print "ctx.fillStyle = \"rgb(0,0,0)\";"; // print "ctx.rotate(-1.5707);"; @@ -763,9 +763,9 @@ function bleu_diff_annotation() { $data = file(get_analysis_filename($dir,$set,$idx?$id2:$id,"basic","bleu-annotation")); for($i=0;$i<count($data);$i++) { $item = split("\t",$data[$i]); - $annotation[$item[1]]["bleu$idx"] = $item[0]; - $annotation[$item[1]]["system$idx"] = $item[2]; - $annotation[$item[1]]["reference"] = $item[3]; + $annotation[$item[1]]["bleu$idx"] = $item[0]; + $annotation[$item[1]]["system$idx"] = $item[2]; + $annotation[$item[1]]["reference"] = $item[3]; $annotation[$item[1]]["id"] = $item[1]; } } @@ -825,7 +825,7 @@ function bleu_diff_annotation() { // display for($i=0;$i<$count && $i<count($annotation);$i++) { - $line = $annotation[$i]; + $line = $annotation[$i]; print "<font size=-2>[src]</font> ".$input[$line["id"]]."<br>"; $word_with_score1 = split(" ",$line["system1"]); @@ -840,7 +840,7 @@ function bleu_diff_annotation() { $matched_with_score1 = preg_replace('/D/',"",$matched_with_score); bleu_line_diff( $word_with_score1, $matched1, $matched_with_score1 ); - print "<font size=-2>[".$id."-".$line["id"].":".$line["bleu0"]."]</font> "; + print "<font size=-2>[".$id."-".$line["id"].":".$line["bleu0"]."]</font> "; $matched0 = preg_replace('/I/',"",$matched); $matched_with_score0 = preg_replace('/I/',"",$matched_with_score); bleu_line_diff( $word_with_score0, $matched0, $matched_with_score0 ); @@ -875,14 +875,14 @@ function ngram_diff($type) { // load data $order = $_GET['order']; - + for($idx=0;$idx<2;$idx++) { $data = file(get_analysis_filename($dir,$set,$idx?$id2:$id,"basic","n-gram-$type.$order")); for($i=0;$i<count($data);$i++) { $item = split("\t",$data[$i]); - $ngram_hash[$item[2]]["total$idx"] = $item[0]; + $ngram_hash[$item[2]]["total$idx"] = $item[0]; $ngram_hash[$item[2]]["correct$idx"] = $item[1]; - } + } unset($data); } @@ -893,7 +893,7 @@ function ngram_diff($type) { $sort = 'ratio_worse'; $smooth = 1; } - + error_reporting(E_ERROR); // otherwise undefined counts trigger notices // sort index @@ -914,12 +914,12 @@ function ngram_diff($type) { + (2*$item["correct0"] - $item["total0"]); } else if ($sort == "ratio_worse") { - $item["index"] = + $item["index"] = ($item["correct1"] + $smooth) / ($item["total1"] + $smooth) - ($item["correct0"] + $smooth) / ($item["total0"] + $smooth); } else if ($sort == "ratio_better") { - $item["index"] = + $item["index"] = - ($item["correct1"] + $smooth) / ($item["total1"] + $smooth) + ($item["correct0"] + $smooth) / ($item["total0"] + $smooth); } @@ -1010,7 +1010,7 @@ function ngram_diff($type) { } else { printf("<td align=right>%+d</td><td>(%d)</td><td align=right>%+d</td><td>(%d)</td></tr>", $ok_diff,$ok,$wrong_diff,$wrong); - } + } } print "</table>\n"; } diff --git a/scripts/ems/web/bilingual-concordance.css b/scripts/ems/web/bilingual-concordance.css index 4648a21dd..f9941175e 100644 --- a/scripts/ems/web/bilingual-concordance.css +++ b/scripts/ems/web/bilingual-concordance.css @@ -17,57 +17,57 @@ text-align: center; } -table.biconcor { - table-layout: fixed; - padding: 0px; - margin: 0px; +table.biconcor { + table-layout: fixed; + padding: 0px; + margin: 0px; } -tr.biconcor { - padding: 0px; - margin: 0px; +tr.biconcor { + padding: 0px; + margin: 0px; } -td.biconcor { - white-space: nowrap; - overflow: hidden; - padding: 0px; - margin: 0px; +td.biconcor { + white-space: nowrap; + overflow: hidden; + padding: 0px; + margin: 0px; } -td.pp_source_left { +td.pp_source_left { font-size: 70%; - text-align: right; + text-align: right; } -td.pp_target_left { +td.pp_target_left { font-size: 70%; - text-align: right; + text-align: right; } -td.pp_source { +td.pp_source { font-size: 70%; - font-weight: bold; + font-weight: bold; } -td.pp_target { +td.pp_target { font-size: 70%; - font-weight: bold; + font-weight: bold; } -td.mismatch_target { +td.mismatch_target { font-size: 70%; text-align: center; } -td.pp_source_right { +td.pp_source_right { font-size: 70%; - border-style:solid; - border-width:0px 2px 0px 0px ; - border-color: black; + border-style:solid; + border-width:0px 2px 0px 0px ; + border-color: black; } -td.pp_target_right { +td.pp_target_right { font-size: 70%; } @@ -88,11 +88,11 @@ span.mismatch_misaligned { } span.mismatch_aligned { - font-weight: bold; + font-weight: bold; } td.pp_more { font-size: 70%; color: navy; - text-align: center; + text-align: center; } diff --git a/scripts/ems/web/comment.php b/scripts/ems/web/comment.php index 04628ea4f..dcd51ab00 100644 --- a/scripts/ems/web/comment.php +++ b/scripts/ems/web/comment.php @@ -1,4 +1,4 @@ -<?php +<?php $fp = fopen("comment","a"); fwrite($fp,$_GET{'run'} . ";" . $_GET{'text'} . "\n"); fclose($fp); diff --git a/scripts/ems/web/diff.php b/scripts/ems/web/diff.php index 71e732af1..f440d3240 100644 --- a/scripts/ems/web/diff.php +++ b/scripts/ems/web/diff.php @@ -37,7 +37,7 @@ function compute_diff($base,$change) { foreach ($all_parameters as $parameter) { if (!array_key_exists($parameter,$parameter_base)) { $parameter_base[$parameter] = ""; - } + } if (!array_key_exists($parameter,$parameter_change)) { $parameter_change[$parameter] = ""; } diff --git a/scripts/ems/web/hierarchical-segmentation.css b/scripts/ems/web/hierarchical-segmentation.css index 47f2c2693..e66555070 100644 --- a/scripts/ems/web/hierarchical-segmentation.css +++ b/scripts/ems/web/hierarchical-segmentation.css @@ -10,7 +10,7 @@ div.leaf { border:1px solid black; margin:2px; padding:0px; - font-weight: normal; + font-weight: normal; background-color: white; } div.empty { @@ -34,7 +34,7 @@ div.continued { margin-right: 0px; padding: 0px; padding-top: 0px; - font-weight: normal; + font-weight: normal; background-color: white; } div.opening { @@ -44,7 +44,7 @@ div.opening { margin:2px; margin-right: 0px; padding: 0px; - font-weight: normal; + font-weight: normal; background-color: white; } div.closing { @@ -54,6 +54,6 @@ div.closing { margin:2px; margin-left: 0px; padding: 0px; - font-weight: normal; + font-weight: normal; background-color: white; } diff --git a/scripts/ems/web/hierarchical-segmentation.js b/scripts/ems/web/hierarchical-segmentation.js index b4eb206ce..819ed121e 100644 --- a/scripts/ems/web/hierarchical-segmentation.js +++ b/scripts/ems/web/hierarchical-segmentation.js @@ -1,6 +1,6 @@ -var nodeIn = []; +var nodeIn = []; var nodeOut = []; -var nodeChildren = []; +var nodeChildren = []; var max_depth = []; var span_count_in = []; var span_count_out = []; diff --git a/scripts/ems/web/index.php b/scripts/ems/web/index.php index d216b114a..9c918a96a 100644 --- a/scripts/ems/web/index.php +++ b/scripts/ems/web/index.php @@ -29,7 +29,7 @@ else if (array_key_exists("setup",$_POST) || array_key_exists("setup",$_GET)) { if (array_key_exists("show",$_GET)) { show(); } else if (array_key_exists("diff",$_GET)) { diff(); } - else if (array_key_exists("analysis",$_GET)) { + else if (array_key_exists("analysis",$_GET)) { $action = $_GET["analysis"]; $set = $_GET["set"]; $id = $_GET["id"]; @@ -60,7 +60,7 @@ else if (array_key_exists("setup",$_POST) || array_key_exists("setup",$_GET)) { if ($match[2] == $set) { $id_array[] = $match[1]; } - } + } } if (count($id_array) != 2) { print "ERROR: comp 2!"; diff --git a/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js b/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js index 33a0c7157..cd3d19b39 100644 --- a/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js +++ b/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js @@ -19,10 +19,10 @@ Event.simulateMouse = function(element, eventName) { metaKey: false }, arguments[2] || {}); var oEvent = document.createEvent("MouseEvents"); - oEvent.initMouseEvent(eventName, true, true, document.defaultView, - options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, + oEvent.initMouseEvent(eventName, true, true, document.defaultView, + options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element)); - + if(this.mark) Element.remove(this.mark); this.mark = document.createElement('div'); this.mark.appendChild(document.createTextNode(" ")); @@ -34,10 +34,10 @@ Event.simulateMouse = function(element, eventName) { this.mark.style.height = "5px;"; this.mark.style.borderTop = "1px solid red;"; this.mark.style.borderLeft = "1px solid red;"; - + if(this.step) alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options)); - + $(element).dispatchEvent(oEvent); }; @@ -55,7 +55,7 @@ Event.simulateKey = function(element, eventName) { }, arguments[2] || {}); var oEvent = document.createEvent("KeyEvents"); - oEvent.initKeyEvent(eventName, true, true, window, + oEvent.initKeyEvent(eventName, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode ); $(element).dispatchEvent(oEvent); @@ -123,7 +123,7 @@ Test.Unit.Logger.prototype = { _toHTML: function(txt) { return txt.escapeHTML().replace(/\n/g,"<br/>"); }, - addLinksToResults: function(){ + addLinksToResults: function(){ $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log td.title = "Run only this test"; Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;}); @@ -162,7 +162,7 @@ Test.Unit.Runner.prototype = { if(/^test/.test(testcase)) { this.tests.push( new Test.Unit.Testcase( - this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, + this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, testcases[testcase], testcases["setup"], testcases["teardown"] )); } @@ -203,7 +203,7 @@ Test.Unit.Runner.prototype = { }, postResults: function() { if (this.options.resultsURL) { - new Ajax.Request(this.options.resultsURL, + new Ajax.Request(this.options.resultsURL, { method: 'get', parameters: 'result=' + this.getResult(), asynchronous: false }); } }, @@ -240,9 +240,9 @@ Test.Unit.Runner.prototype = { errors += this.tests[i].errors; } return ( - (this.options.context ? this.options.context + ': ': '') + - this.tests.length + " tests, " + - assertions + " assertions, " + + (this.options.context ? this.options.context + ': ': '') + + this.tests.length + " tests, " + + assertions + " assertions, " + failures + " failures, " + errors + " errors"); } @@ -258,7 +258,7 @@ Test.Unit.Assertions.prototype = { }, summary: function() { return ( - this.assertions + " assertions, " + + this.assertions + " assertions, " + this.failures + " failures, " + this.errors + " errors" + "\n" + this.messages.join("\n")); @@ -284,55 +284,55 @@ Test.Unit.Assertions.prototype = { }, assert: function(expression) { var message = arguments[1] || 'assert: got "' + Test.Unit.inspect(expression) + '"'; - try { expression ? this.pass() : + try { expression ? this.pass() : this.fail(message); } catch(e) { this.error(e); } }, assertEqual: function(expected, actual) { var message = arguments[2] || "assertEqual"; try { (expected == actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, assertInspect: function(expected, actual) { var message = arguments[2] || "assertInspect"; try { (expected == actual.inspect()) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, assertEnumEqual: function(expected, actual) { var message = arguments[2] || "assertEnumEqual"; - try { $A(expected).length == $A(actual).length && + try { $A(expected).length == $A(actual).length && expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ? - this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) + + this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) + ', actual ' + Test.Unit.inspect(actual)); } catch(e) { this.error(e); } }, assertNotEqual: function(expected, actual) { var message = arguments[2] || "assertNotEqual"; - try { (expected != actual) ? this.pass() : + try { (expected != actual) ? this.pass() : this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, - assertIdentical: function(expected, actual) { - var message = arguments[2] || "assertIdentical"; - try { (expected === actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + - '", actual "' + Test.Unit.inspect(actual) + '"'); } - catch(e) { this.error(e); } + assertIdentical: function(expected, actual) { + var message = arguments[2] || "assertIdentical"; + try { (expected === actual) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + '", actual "' + Test.Unit.inspect(actual) + '"'); } + catch(e) { this.error(e); } }, - assertNotIdentical: function(expected, actual) { - var message = arguments[2] || "assertNotIdentical"; - try { !(expected === actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + - '", actual "' + Test.Unit.inspect(actual) + '"'); } - catch(e) { this.error(e); } + assertNotIdentical: function(expected, actual) { + var message = arguments[2] || "assertNotIdentical"; + try { !(expected === actual) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + '", actual "' + Test.Unit.inspect(actual) + '"'); } + catch(e) { this.error(e); } }, assertNull: function(obj) { var message = arguments[1] || 'assertNull'; - try { (obj==null) ? this.pass() : + try { (obj==null) ? this.pass() : this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); } catch(e) { this.error(e); } }, @@ -353,38 +353,38 @@ Test.Unit.Assertions.prototype = { }, assertType: function(expected, actual) { var message = arguments[2] || 'assertType'; - try { - (actual.constructor == expected) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + try { + (actual.constructor == expected) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + (actual.constructor) + '"'); } catch(e) { this.error(e); } }, assertNotOfType: function(expected, actual) { var message = arguments[2] || 'assertNotOfType'; - try { - (actual.constructor != expected) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + try { + (actual.constructor != expected) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + (actual.constructor) + '"'); } catch(e) { this.error(e); } }, assertInstanceOf: function(expected, actual) { var message = arguments[2] || 'assertInstanceOf'; - try { - (actual instanceof expected) ? this.pass() : + try { + (actual instanceof expected) ? this.pass() : this.fail(message + ": object was not an instance of the expected type"); } - catch(e) { this.error(e); } + catch(e) { this.error(e); } }, assertNotInstanceOf: function(expected, actual) { var message = arguments[2] || 'assertNotInstanceOf'; - try { - !(actual instanceof expected) ? this.pass() : + try { + !(actual instanceof expected) ? this.pass() : this.fail(message + ": object was an instance of the not expected type"); } - catch(e) { this.error(e); } + catch(e) { this.error(e); } }, assertRespondsTo: function(method, obj) { var message = arguments[2] || 'assertRespondsTo'; try { - (obj[method] && typeof obj[method] == 'function') ? this.pass() : + (obj[method] && typeof obj[method] == 'function') ? this.pass() : this.fail(message + ": object doesn't respond to [" + method + "]"); } catch(e) { this.error(e); } }, @@ -393,7 +393,7 @@ Test.Unit.Assertions.prototype = { try { var m = obj[method]; if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; - m() ? this.pass() : + m() ? this.pass() : this.fail(message + ": method returned false"); } catch(e) { this.error(e); } }, @@ -402,17 +402,17 @@ Test.Unit.Assertions.prototype = { try { var m = obj[method]; if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; - !m() ? this.pass() : + !m() ? this.pass() : this.fail(message + ": method returned true"); } catch(e) { this.error(e); } }, assertRaise: function(exceptionName, method) { var message = arguments[2] || 'assertRaise'; - try { + try { method(); this.fail(message + ": exception expected but none was raised"); } catch(e) { - ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); + ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); } }, assertElementsMatch: function() { @@ -434,7 +434,7 @@ Test.Unit.Assertions.prototype = { var startAt = new Date(); (iterations || 1).times(operation); var timeTaken = ((new Date())-startAt); - this.info((arguments[2] || 'Operation') + ' finished ' + + this.info((arguments[2] || 'Operation') + ' finished ' + iterations + ' iterations in ' + (timeTaken/1000)+'s' ); return timeTaken; }, @@ -444,7 +444,7 @@ Test.Unit.Assertions.prototype = { this.assertNotNull(element); if(element.style && Element.getStyle(element, 'display') == 'none') return false; - + return this._isVisible(element.parentNode); }, assertNotVisible: function(element) { @@ -457,7 +457,7 @@ Test.Unit.Assertions.prototype = { var startAt = new Date(); (iterations || 1).times(operation); var timeTaken = ((new Date())-startAt); - this.info((arguments[2] || 'Operation') + ' finished ' + + this.info((arguments[2] || 'Operation') + ' finished ' + iterations + ' iterations in ' + (timeTaken/1000)+'s' ); return timeTaken; } @@ -468,7 +468,7 @@ Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.p initialize: function(name, test, setup, teardown) { Test.Unit.Assertions.prototype.initialize.bind(this)(); this.name = name; - + if(typeof test == 'string') { test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,'); test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)'); @@ -478,7 +478,7 @@ Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.p } else { this.test = test || function() {}; } - + this.setup = setup || function() {}; this.teardown = teardown || function() {}; this.isWaiting = false; @@ -519,23 +519,23 @@ Test.setupBDDExtensionMethods = function(){ shouldNotBeAn: 'assertNotOfType', shouldBeNull: 'assertNull', shouldNotBeNull: 'assertNotNull', - + shouldBe: 'assertReturnsTrue', shouldNotBe: 'assertReturnsFalse', shouldRespondTo: 'assertRespondsTo' }; - var makeAssertion = function(assertion, args, object) { + var makeAssertion = function(assertion, args, object) { this[assertion].apply(this,(args || []).concat([object])); }; - - Test.BDDMethods = {}; - $H(METHODMAP).each(function(pair) { - Test.BDDMethods[pair.key] = function() { - var args = $A(arguments); - var scope = args.shift(); - makeAssertion.apply(scope, [pair.value, args, this]); }; + + Test.BDDMethods = {}; + $H(METHODMAP).each(function(pair) { + Test.BDDMethods[pair.key] = function() { + var args = $A(arguments); + var scope = args.shift(); + makeAssertion.apply(scope, [pair.value, args, this]); }; }); - + [Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each( function(p){ Object.extend(p, Test.BDDMethods) } ); @@ -543,7 +543,7 @@ Test.setupBDDExtensionMethods = function(){ Test.context = function(name, spec, log){ Test.setupBDDExtensionMethods(); - + var compiledSpec = {}; var titles = {}; for(specName in spec) { @@ -557,7 +557,7 @@ Test.context = function(name, spec, log){ var body = spec[specName].toString().split('\n').slice(1); if(/^\{/.test(body[0])) body = body.slice(1); body.pop(); - body = body.map(function(statement){ + body = body.map(function(statement){ return statement.strip() }); compiledSpec[testName] = body.join('\n'); diff --git a/scripts/ems/web/javascripts/sound.js b/scripts/ems/web/javascripts/sound.js index a286eb98e..0a63379fb 100644 --- a/scripts/ems/web/javascripts/sound.js +++ b/scripts/ems/web/javascripts/sound.js @@ -56,4 +56,4 @@ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){ Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'); else Sound.play = function(){}; -}
\ No newline at end of file +}
\ No newline at end of file diff --git a/scripts/ems/web/javascripts/unittest.js b/scripts/ems/web/javascripts/unittest.js index 33a0c7157..cd3d19b39 100644 --- a/scripts/ems/web/javascripts/unittest.js +++ b/scripts/ems/web/javascripts/unittest.js @@ -19,10 +19,10 @@ Event.simulateMouse = function(element, eventName) { metaKey: false }, arguments[2] || {}); var oEvent = document.createEvent("MouseEvents"); - oEvent.initMouseEvent(eventName, true, true, document.defaultView, - options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, + oEvent.initMouseEvent(eventName, true, true, document.defaultView, + options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element)); - + if(this.mark) Element.remove(this.mark); this.mark = document.createElement('div'); this.mark.appendChild(document.createTextNode(" ")); @@ -34,10 +34,10 @@ Event.simulateMouse = function(element, eventName) { this.mark.style.height = "5px;"; this.mark.style.borderTop = "1px solid red;"; this.mark.style.borderLeft = "1px solid red;"; - + if(this.step) alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options)); - + $(element).dispatchEvent(oEvent); }; @@ -55,7 +55,7 @@ Event.simulateKey = function(element, eventName) { }, arguments[2] || {}); var oEvent = document.createEvent("KeyEvents"); - oEvent.initKeyEvent(eventName, true, true, window, + oEvent.initKeyEvent(eventName, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode ); $(element).dispatchEvent(oEvent); @@ -123,7 +123,7 @@ Test.Unit.Logger.prototype = { _toHTML: function(txt) { return txt.escapeHTML().replace(/\n/g,"<br/>"); }, - addLinksToResults: function(){ + addLinksToResults: function(){ $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log td.title = "Run only this test"; Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;}); @@ -162,7 +162,7 @@ Test.Unit.Runner.prototype = { if(/^test/.test(testcase)) { this.tests.push( new Test.Unit.Testcase( - this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, + this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, testcases[testcase], testcases["setup"], testcases["teardown"] )); } @@ -203,7 +203,7 @@ Test.Unit.Runner.prototype = { }, postResults: function() { if (this.options.resultsURL) { - new Ajax.Request(this.options.resultsURL, + new Ajax.Request(this.options.resultsURL, { method: 'get', parameters: 'result=' + this.getResult(), asynchronous: false }); } }, @@ -240,9 +240,9 @@ Test.Unit.Runner.prototype = { errors += this.tests[i].errors; } return ( - (this.options.context ? this.options.context + ': ': '') + - this.tests.length + " tests, " + - assertions + " assertions, " + + (this.options.context ? this.options.context + ': ': '') + + this.tests.length + " tests, " + + assertions + " assertions, " + failures + " failures, " + errors + " errors"); } @@ -258,7 +258,7 @@ Test.Unit.Assertions.prototype = { }, summary: function() { return ( - this.assertions + " assertions, " + + this.assertions + " assertions, " + this.failures + " failures, " + this.errors + " errors" + "\n" + this.messages.join("\n")); @@ -284,55 +284,55 @@ Test.Unit.Assertions.prototype = { }, assert: function(expression) { var message = arguments[1] || 'assert: got "' + Test.Unit.inspect(expression) + '"'; - try { expression ? this.pass() : + try { expression ? this.pass() : this.fail(message); } catch(e) { this.error(e); } }, assertEqual: function(expected, actual) { var message = arguments[2] || "assertEqual"; try { (expected == actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, assertInspect: function(expected, actual) { var message = arguments[2] || "assertInspect"; try { (expected == actual.inspect()) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, assertEnumEqual: function(expected, actual) { var message = arguments[2] || "assertEnumEqual"; - try { $A(expected).length == $A(actual).length && + try { $A(expected).length == $A(actual).length && expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ? - this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) + + this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) + ', actual ' + Test.Unit.inspect(actual)); } catch(e) { this.error(e); } }, assertNotEqual: function(expected, actual) { var message = arguments[2] || "assertNotEqual"; - try { (expected != actual) ? this.pass() : + try { (expected != actual) ? this.pass() : this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); } catch(e) { this.error(e); } }, - assertIdentical: function(expected, actual) { - var message = arguments[2] || "assertIdentical"; - try { (expected === actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + - '", actual "' + Test.Unit.inspect(actual) + '"'); } - catch(e) { this.error(e); } + assertIdentical: function(expected, actual) { + var message = arguments[2] || "assertIdentical"; + try { (expected === actual) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + '", actual "' + Test.Unit.inspect(actual) + '"'); } + catch(e) { this.error(e); } }, - assertNotIdentical: function(expected, actual) { - var message = arguments[2] || "assertNotIdentical"; - try { !(expected === actual) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + - '", actual "' + Test.Unit.inspect(actual) + '"'); } - catch(e) { this.error(e); } + assertNotIdentical: function(expected, actual) { + var message = arguments[2] || "assertNotIdentical"; + try { !(expected === actual) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + '", actual "' + Test.Unit.inspect(actual) + '"'); } + catch(e) { this.error(e); } }, assertNull: function(obj) { var message = arguments[1] || 'assertNull'; - try { (obj==null) ? this.pass() : + try { (obj==null) ? this.pass() : this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); } catch(e) { this.error(e); } }, @@ -353,38 +353,38 @@ Test.Unit.Assertions.prototype = { }, assertType: function(expected, actual) { var message = arguments[2] || 'assertType'; - try { - (actual.constructor == expected) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + try { + (actual.constructor == expected) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + (actual.constructor) + '"'); } catch(e) { this.error(e); } }, assertNotOfType: function(expected, actual) { var message = arguments[2] || 'assertNotOfType'; - try { - (actual.constructor != expected) ? this.pass() : - this.fail(message + ': expected "' + Test.Unit.inspect(expected) + + try { + (actual.constructor != expected) ? this.pass() : + this.fail(message + ': expected "' + Test.Unit.inspect(expected) + '", actual "' + (actual.constructor) + '"'); } catch(e) { this.error(e); } }, assertInstanceOf: function(expected, actual) { var message = arguments[2] || 'assertInstanceOf'; - try { - (actual instanceof expected) ? this.pass() : + try { + (actual instanceof expected) ? this.pass() : this.fail(message + ": object was not an instance of the expected type"); } - catch(e) { this.error(e); } + catch(e) { this.error(e); } }, assertNotInstanceOf: function(expected, actual) { var message = arguments[2] || 'assertNotInstanceOf'; - try { - !(actual instanceof expected) ? this.pass() : + try { + !(actual instanceof expected) ? this.pass() : this.fail(message + ": object was an instance of the not expected type"); } - catch(e) { this.error(e); } + catch(e) { this.error(e); } }, assertRespondsTo: function(method, obj) { var message = arguments[2] || 'assertRespondsTo'; try { - (obj[method] && typeof obj[method] == 'function') ? this.pass() : + (obj[method] && typeof obj[method] == 'function') ? this.pass() : this.fail(message + ": object doesn't respond to [" + method + "]"); } catch(e) { this.error(e); } }, @@ -393,7 +393,7 @@ Test.Unit.Assertions.prototype = { try { var m = obj[method]; if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; - m() ? this.pass() : + m() ? this.pass() : this.fail(message + ": method returned false"); } catch(e) { this.error(e); } }, @@ -402,17 +402,17 @@ Test.Unit.Assertions.prototype = { try { var m = obj[method]; if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; - !m() ? this.pass() : + !m() ? this.pass() : this.fail(message + ": method returned true"); } catch(e) { this.error(e); } }, assertRaise: function(exceptionName, method) { var message = arguments[2] || 'assertRaise'; - try { + try { method(); this.fail(message + ": exception expected but none was raised"); } catch(e) { - ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); + ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); } }, assertElementsMatch: function() { @@ -434,7 +434,7 @@ Test.Unit.Assertions.prototype = { var startAt = new Date(); (iterations || 1).times(operation); var timeTaken = ((new Date())-startAt); - this.info((arguments[2] || 'Operation') + ' finished ' + + this.info((arguments[2] || 'Operation') + ' finished ' + iterations + ' iterations in ' + (timeTaken/1000)+'s' ); return timeTaken; }, @@ -444,7 +444,7 @@ Test.Unit.Assertions.prototype = { this.assertNotNull(element); if(element.style && Element.getStyle(element, 'display') == 'none') return false; - + return this._isVisible(element.parentNode); }, assertNotVisible: function(element) { @@ -457,7 +457,7 @@ Test.Unit.Assertions.prototype = { var startAt = new Date(); (iterations || 1).times(operation); var timeTaken = ((new Date())-startAt); - this.info((arguments[2] || 'Operation') + ' finished ' + + this.info((arguments[2] || 'Operation') + ' finished ' + iterations + ' iterations in ' + (timeTaken/1000)+'s' ); return timeTaken; } @@ -468,7 +468,7 @@ Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.p initialize: function(name, test, setup, teardown) { Test.Unit.Assertions.prototype.initialize.bind(this)(); this.name = name; - + if(typeof test == 'string') { test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,'); test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)'); @@ -478,7 +478,7 @@ Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.p } else { this.test = test || function() {}; } - + this.setup = setup || function() {}; this.teardown = teardown || function() {}; this.isWaiting = false; @@ -519,23 +519,23 @@ Test.setupBDDExtensionMethods = function(){ shouldNotBeAn: 'assertNotOfType', shouldBeNull: 'assertNull', shouldNotBeNull: 'assertNotNull', - + shouldBe: 'assertReturnsTrue', shouldNotBe: 'assertReturnsFalse', shouldRespondTo: 'assertRespondsTo' }; - var makeAssertion = function(assertion, args, object) { + var makeAssertion = function(assertion, args, object) { this[assertion].apply(this,(args || []).concat([object])); }; - - Test.BDDMethods = {}; - $H(METHODMAP).each(function(pair) { - Test.BDDMethods[pair.key] = function() { - var args = $A(arguments); - var scope = args.shift(); - makeAssertion.apply(scope, [pair.value, args, this]); }; + + Test.BDDMethods = {}; + $H(METHODMAP).each(function(pair) { + Test.BDDMethods[pair.key] = function() { + var args = $A(arguments); + var scope = args.shift(); + makeAssertion.apply(scope, [pair.value, args, this]); }; }); - + [Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each( function(p){ Object.extend(p, Test.BDDMethods) } ); @@ -543,7 +543,7 @@ Test.setupBDDExtensionMethods = function(){ Test.context = function(name, spec, log){ Test.setupBDDExtensionMethods(); - + var compiledSpec = {}; var titles = {}; for(specName in spec) { @@ -557,7 +557,7 @@ Test.context = function(name, spec, log){ var body = spec[specName].toString().split('\n').slice(1); if(/^\{/.test(body[0])) body = body.slice(1); body.pop(); - body = body.map(function(statement){ + body = body.map(function(statement){ return statement.strip() }); compiledSpec[testName] = body.join('\n'); diff --git a/scripts/ems/web/lib.php b/scripts/ems/web/lib.php index 6d936ddf4..68c58860b 100644 --- a/scripts/ems/web/lib.php +++ b/scripts/ems/web/lib.php @@ -21,7 +21,7 @@ function load_experiment_info() { file_exists($dir."/steps/1")) { $topd = dir($dir."/steps"); while (false !== ($run = $topd->read())) { - if (preg_match('/^([0-9]+)$/',$run,$match) + if (preg_match('/^([0-9]+)$/',$run,$match) && $run>0 && !file_exists("$dir/steps/$run/deleted.$run")) { $d = dir($dir."/steps/$run"); @@ -49,7 +49,7 @@ function load_experiment_info() { } $experiment[$id]->start = $stat[9]; } - + reset($experiment); while (list($id,$info) = each($experiment)) { if (file_exists("$dir/evaluation/report.$id")) { @@ -57,15 +57,15 @@ function load_experiment_info() { foreach ($f as $line_num => $line) { if (preg_match('/^(.+): (.+)/',$line,$match)) { $experiment[$id]->result[$match[1]] = $match[2]; - if (!$evalset || !array_key_exists($match[1],$evalset)) { - $evalset[$match[1]] = 0; + if (!$evalset || !array_key_exists($match[1],$evalset)) { + $evalset[$match[1]] = 0; } $evalset[$match[1]]++; } } } } - + krsort($experiment); uksort($evalset,"evalsetsort"); } @@ -81,7 +81,7 @@ function load_parameter($run) { if (file_exists($dir."/steps/new") || file_exists($dir."/steps/$run")) { $file = file("$dir/steps/$run/parameter.$run"); - } + } else { $file = file("$dir/steps/parameter.$run"); } @@ -121,7 +121,7 @@ function process_file_entry($dir,$entry) { if (file_exists($file.".STDOUT")) { $stat2 = stat($file.".STDOUT"); } if ($stat2[9] > $stat[9]) { $stat = $stat2; } $time = $stat[9]; - + if (!$experiment || !array_key_exists($run,$experiment) || !property_exists($experiment[$run],"last_step_time") || $time > $experiment[$run]->last_step_time) { @@ -142,7 +142,7 @@ function get_analysis_version($dir,$set,$id) { #while(list($type,$i) = each($analysis_version[$id][$set])) { # print "$type=$i "; #} - #print ") FROM CACHE<br>"; + #print ") FROM CACHE<br>"; return $analysis_version[$id][$set]; } $analysis_version[$id][$set]["basic"] = 0; @@ -188,7 +188,7 @@ function get_analysis_version($dir,$set,$id) { file_exists("$dir/model/biconcor.$match[1]")) { $analysis_version[$id][$set]["biconcor"] = $match[1]; } - } + } } # legacy stuff below... @@ -225,7 +225,7 @@ function get_analysis_version($dir,$set,$id) { #while(list($type,$i) = each($analysis_version[$id][$set])) { # print "$type=$i "; #} - #print ") ZZ<br>"; + #print ") ZZ<br>"; return $analysis_version[$id][$set]; } diff --git a/scripts/ems/web/overview.php b/scripts/ems/web/overview.php index ce0434bb8..534c7d8c0 100644 --- a/scripts/ems/web/overview.php +++ b/scripts/ems/web/overview.php @@ -39,7 +39,7 @@ function overview() { $report_info = "$dir/steps/$id/REPORTING_report.$id.INFO"; // does the analysis file exist? if (file_exists($analysis)) { - if (!array_key_exists($set,$has_analysis)) { + if (!array_key_exists($set,$has_analysis)) { $has_analysis[$set] = 0; } $has_analysis[$set]++; @@ -138,7 +138,7 @@ new Ajax.Updater("<?php print "$module_step[0]-$module_step[1]-$id"; ?>", '?setS } } } - else { $score = ""; } + else { $score = ""; } } } print "var best_score = [];\n"; @@ -158,9 +158,9 @@ function getHTTPObject(){ alert("Your browser does not support AJAX."); return null; } -} +} function createCommentBox( runID ) { - document.getElementById("run-" + runID).innerHTML = "<form onsubmit=\"return false;\"><input id=\"comment-" + runID + "\" name=\"comment-" + runID + "\" size=30><br><input type=submit onClick=\"addComment('" + runID + "');\" value=\"Add Comment\"></form>"; + document.getElementById("run-" + runID).innerHTML = "<form onsubmit=\"return false;\"><input id=\"comment-" + runID + "\" name=\"comment-" + runID + "\" size=30><br><input type=submit onClick=\"addComment('" + runID + "');\" value=\"Add Comment\"></form>"; if (currentComment[runID]) { document.getElementById("comment-" + runID).value = currentComment[runID]; } @@ -196,7 +196,7 @@ function highlightBest() { for (run in score) { var column = "score-"+run+"-"+set; if ($(column)) { - if (score[run][set] == best_score[set]) { + if (score[run][set] == best_score[set]) { $(column).setStyle({ backgroundColor: '#a0ffa0'}); } else if (score[run][set]+1 >= best_score[set]) { @@ -219,7 +219,7 @@ function highlightLine( id ) { $(column).setStyle({ backgroundColor: '#ffffff'}); } else { - if (score[run][set] < score[id][set]-1) { + if (score[run][set] < score[id][set]-1) { $(column).setStyle({ backgroundColor: '#ffa0a0'}); } else if (score[run][set] < score[id][set]) { @@ -234,7 +234,7 @@ function highlightLine( id ) { } } } - } + } } function lowlightAll() { for (run in score) { @@ -298,13 +298,13 @@ function output_score($id,$info) { preg_match('/([\d\(\)\.\s]+) (METEOR[\-c]*)/',$each_score[$i],$match)) { if ($i>0) { print "<BR>"; } $opened_a_tag = 0; - if ($set != "avg") { + if ($set != "avg") { if (file_exists("$dir/evaluation/$set.cleaned.$id")) { - print "<a href=\"?$state&show=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\">"; + print "<a href=\"?$state&show=evaluation/$set.output.$id\">"; $opened_a_tag = 1; } } @@ -336,7 +336,7 @@ function tune_status($id) { if (! file_exists($dir."/tuning/tmp.".$id)) { return ""; } $d = dir($dir."/tuning/tmp.".$id); while (false !== ($entry = $d->read())) { - if (preg_match('/run(\d+).moses.ini/',$entry,$match) + if (preg_match('/run(\d+).moses.ini/',$entry,$match) && $match[1] > $max_iteration) { $max_iteration = $match[1]; } @@ -383,7 +383,7 @@ function show() { } $fullname = $dir."/steps/".$extra.$_GET["show"]; - if (preg_match("/\//",$_GET["show"])) { + if (preg_match("/\//",$_GET["show"])) { $fullname = $dir."/".$_GET["show"]; } if (preg_match("/graph/",$fullname)) { diff --git a/scripts/ems/web/progress.perl b/scripts/ems/web/progress.perl index fd742e410..fa2ce9e8f 100755 --- a/scripts/ems/web/progress.perl +++ b/scripts/ems/web/progress.perl @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/env perl use warnings; use strict; diff --git a/scripts/ems/web/sgviz.js b/scripts/ems/web/sgviz.js index 03ad4741a..3e63260ee 100644 --- a/scripts/ems/web/sgviz.js +++ b/scripts/ems/web/sgviz.js @@ -54,7 +54,7 @@ function process_hypotheses() { // // INITIALIZATION -// +// function index_hypotheses_by_cell() { // init edge_lists @@ -93,7 +93,7 @@ function find_reachable_hypotheses_recursive( id ) { find_reachable_hypotheses_recursive( children[c] ); } } - + function compute_best_derivation_scores() { for(var from=0; from<length; from++ ) { cell_derivation_score[from] = Array(); @@ -147,7 +147,7 @@ function click_menu( id, force_flag ) { return; } menu_processing = 1; - + if (current_menu_selection == 1) { best_derivation(0); } if (current_menu_selection == 2) { unannotate_cells(); } if (current_menu_selection == 3) { unannotate_cells(); } @@ -155,7 +155,7 @@ function click_menu( id, force_flag ) { if (current_menu_selection == 5) { remove_non_terminal_treemap(0); } if (current_menu_selection == 6 && SORT_OPTION != 3) { remove_hypothesis_overview(); } if (current_menu_selection == 6 && SORT_OPTION == 3) { remove_hypothesis_overview(); remove_non_terminal_treemap(); } - if (current_menu_selection > 0) { + if (current_menu_selection > 0) { highlight_menu_button( current_menu_selection, 0 ); } @@ -196,8 +196,8 @@ function draw_menu_button( id, label ) { var content = document.createTextNode( label ); button_label.appendChild( content ); button_label.setAttribute("onclick","click_menu(" + id + ",0);") - - chart.appendChild( button_label ); + + chart.appendChild( button_label ); } function highlight_menu_button( id, on_off ) { @@ -251,8 +251,8 @@ function draw_option_button( rule_option, id, label ) { button_label.setAttribute("pointer-events", "none"); var content = document.createTextNode( label ); button_label.appendChild( content ); - - chart.appendChild( button_label ); + + chart.appendChild( button_label ); } function draw_sort_button( id, label ) { @@ -294,8 +294,8 @@ function draw_sort_button( id, label ) { button_label.setAttribute("pointer-events", "none"); var content = document.createTextNode( label ); button_label.appendChild( content ); - - chart.appendChild( button_label ); + + chart.appendChild( button_label ); } function click_sort( id ) { @@ -319,17 +319,17 @@ var show_scores = 0; var show_id = 0; var show_derivation = 0; function click_option( id ) { - if (id == 1) { - show_scores = !show_scores; + if (id == 1) { + show_scores = !show_scores; highlight_option_button( 0, 1, show_scores ); } - if (id == 2) { - show_derivation = !show_derivation; + if (id == 2) { + show_derivation = !show_derivation; color_cells(); highlight_option_button( 0, 2, show_derivation ); } - if (id == 3) { - show_id = !show_id; + if (id == 3) { + show_id = !show_id; highlight_option_button( 0, 3, show_id ); } if (current_menu_selection > 0) { @@ -340,15 +340,15 @@ function click_option( id ) { var show_hyp_score = 0; var show_derivation_score = 0; function click_rule_option( id ) { - if (id == 1) { - show_hyp_score = !show_hyp_score; + if (id == 1) { + show_hyp_score = !show_hyp_score; highlight_option_button( 1, 1, show_hyp_score ); } - if (id == 2) { - show_derivation_score = !show_derivation_score; + if (id == 2) { + show_derivation_score = !show_derivation_score; highlight_option_button( 1, 2, show_derivation_score ); } - if (id == 3) { + if (id == 3) { if (ZOOM > 0) { ZOOM = 0; } @@ -377,7 +377,7 @@ function draw_chart() { for (var from=0;from<length;from++) { for(var width=1; width<=length-from; width++) { var to = from + width - 1; - + // logical container var container = document.createElementNS(xmlns,"svg"); container.setAttribute("id", "cell-container-" + from + "-" + to); @@ -385,7 +385,7 @@ function draw_chart() { var transform = document.createElementNS(xmlns,"g"); transform.setAttribute("id", "cell-" + from + "-" + to); container.appendChild( transform ); - + // yellow box for the cell var cell = document.createElementNS(xmlns,"rect"); cell.setAttribute("id", "cellbox-" + from + "-" + to); @@ -403,7 +403,7 @@ function draw_chart() { cell.setAttribute("onclick","click_cell(" + from + "," + to + ");") transform.appendChild( cell ); } - + // box for the input word var input_box = document.createElementNS(xmlns,"rect"); input_box.setAttribute("id", "inputbox-" + from); @@ -415,8 +415,8 @@ function draw_chart() { input_box.setAttribute("height", CELL_HEIGHT/2); //cell.setAttribute("opacity", .75); input_box.setAttribute("fill", INPUT_REGULAR_COLOR); - chart.appendChild( input_box ); - + chart.appendChild( input_box ); + // input word input_word = document.createElementNS(xmlns,"text"); input_word.setAttribute("id", "input-" + from); @@ -426,7 +426,7 @@ function draw_chart() { input_word.setAttribute("text-anchor", "middle"); var content = document.createTextNode( input[from] ); input_word.appendChild( content ); - chart.appendChild( input_word ); + chart.appendChild( input_word ); } assign_chart_coordinates(); } @@ -435,7 +435,7 @@ function assign_chart_coordinates() { for (var from=0;from<length;from++) { for(var width=1; width<=length-from; width++) { var to = from + width - 1; - + var x = from*CELL_WIDTH + (width-1)*CELL_WIDTH/2; var y = (length-width)*CELL_HEIGHT*(1-ZOOM); //alert("(x,y) = (" + length + "," + width + "), width = " + ZOOM + ", height = " + (1-ZOOM)); @@ -505,7 +505,7 @@ var current_from = -1; var current_to; function hover_cell( from, to ) { if (current_from >= 0) { - highlight_input( current_from, current_to, 0) + highlight_input( current_from, current_to, 0) } highlight_input( from, to, 1) current_from = from; @@ -534,7 +534,7 @@ function highlight_input( from, to, on_off ) { } } -// +// // VISUALIZATION OF CHART CELLS // @@ -570,7 +570,7 @@ function annotate_cells_with_rulecount() { function annotate_cells_with_derivation_score() { for (var from=0;from<length;from++) { for(var width=1; width<=length-from; width++) { - var to = from + width - 1; + var to = from + width - 1; var score = cell_derivation_score[from][to]; if (score < -9e9) { score = "dead end"; } annotate_cell( from, to, score, 15 ) @@ -596,12 +596,12 @@ function annotate_cell( from, to, label, font_size ) { cell_label.setAttribute("pointer-events", "none"); cell_label.setAttribute("text-anchor", "middle"); var content = document.createTextNode(line[i]); - cell_label.appendChild( content ); + cell_label.appendChild( content ); cell_label_group.appendChild( cell_label ); } var cell = document.getElementById("cell-" + from + "-" + to); - cell.appendChild( cell_label_group ); + cell.appendChild( cell_label_group ); } function unannotate_cells() { @@ -624,7 +624,7 @@ function unannotate_cell( from, to ) { function non_terminal_treemap( with_hyps ) { for (var from=0;from<length;from++) { for(var width=1; width<=length-from; width++) { - var to = from + width - 1; + var to = from + width - 1; // get nt counts var lhs = new Array(); var lhs_list = new Array(); @@ -639,7 +639,7 @@ function non_terminal_treemap( with_hyps ) { lhs[nt]++; } } - // sort + // sort function sortByCount(a,b) { return lhs[b] - lhs[a]; } @@ -652,7 +652,7 @@ function non_terminal_treemap( with_hyps ) { function remove_non_terminal_treemap() { for (var from=0;from<length;from++) { for(var width=1; width<=length-from; width++) { - var to = from + width - 1; + var to = from + width - 1; var cell = document.getElementById("cell-" + from + "-" + to); var done = false; var j=0; @@ -693,7 +693,7 @@ function treemap_cell( from, to, label, count, total, with_hyps ) { rect.setAttribute("stroke", "black"); rect.setAttribute("stroke-width", "0.5"); rect.setAttribute("onclick","click_menu(" + id + ",0);") - cell.appendChild( rect ); + cell.appendChild( rect ); x += width * count[label[i]] / total; } } @@ -749,7 +749,7 @@ function treemap_squarify( from, to, label, count, total, with_hyps ) { rect.setAttribute("pointer-events", "none"); rect.setAttribute("stroke", "black"); rect.setAttribute("stroke-width", "0.5"); - cell.appendChild( rect ); + cell.appendChild( rect ); // hypotheses if (with_hyps) { var hyp_list = Array(); @@ -760,15 +760,15 @@ function treemap_squarify( from, to, label, count, total, with_hyps ) { hyp_list.push( id ); } } - hypothesis_in_rect( this_width * scale_factor - 2, - this_height * scale_factor - 2, - CELL_MARGIN + (offset_x + cum_x) * scale_factor + 1, - CELL_MARGIN + (offset_y + cum_y) * scale_factor + 1, + hypothesis_in_rect( this_width * scale_factor - 2, + this_height * scale_factor - 2, + CELL_MARGIN + (offset_x + cum_x) * scale_factor + 1, + CELL_MARGIN + (offset_y + cum_y) * scale_factor + 1, cell, hyp_list ); } // label var font_size = Math.min( Math.round(this_width * scale_factor / label[j].length * 1.3), - Math.round(this_height * scale_factor )); + Math.round(this_height * scale_factor )); if (font_size > 20) { font_size = 20; } if (font_size >= 3) { var rect_label = document.createElementNS(xmlns,"text"); @@ -782,7 +782,7 @@ function treemap_squarify( from, to, label, count, total, with_hyps ) { rect_label.setAttribute("pointer-events", "none"); var content = document.createTextNode( label[j] ); rect_label.appendChild( content ); - cell.appendChild( rect_label ); + cell.appendChild( rect_label ); } if (adding_on_left) { cum_y += this_height; } else { cum_x += this_width; } @@ -829,7 +829,7 @@ function best_derivation( on_off ) { best_derivation_recurse( best_id, on_off, -1, -1, 0 ); } -function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos ) { +function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos ) { var from = edge[id][FROM]; var to = edge[id][TO]; @@ -846,10 +846,10 @@ function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos else { unannotate_cell( from, to ); } - + // highlight hyp highlight_hyp( id, on_off ); - + // arrow to parent if (parent_from >= 0) { if (on_off) { @@ -860,7 +860,7 @@ function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos chart.removeChild(arrow); } } - + var child_order = Array(); if (edge[id][ALIGNMENT] != "") { var alignment = edge[id][ALIGNMENT].split(" "); @@ -880,7 +880,7 @@ function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos child_order[target_source[1]] = i; } } - + // recurse var covered = new Array; var children = get_children( id ); @@ -888,7 +888,7 @@ function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos var child = children[c]; for( var i=edge[child][FROM]; i<=edge[child][TO]; i++ ) { covered[i] = 1; - } + } best_derivation_recurse( child, on_off, from, to, children.length == 1 ? 0.5 : child_order[c]/(children.length-1.0) ); } @@ -900,10 +900,10 @@ function best_derivation_recurse( id, on_off, parent_from, parent_to, child_pos } else { var arrow = document.getElementById("arrow-word-" + i); - chart.removeChild(arrow); + chart.removeChild(arrow); } } - } + } } function make_arrow( id, parent_from, parent_to, from, to, word_flag, position ) { @@ -1034,7 +1034,7 @@ function hypothesis_in_rect( width, height, offset_x, offset_y, parent_element, for (var i=0; i<hyp_list.length;i++) { id = hyp_list[i]; - + //alert("adding circle (" + (x + diameter/2) + "," + (y + diameter/2) + ") - " + (diameter/2) ); var hyp = document.createElementNS(xmlns,"circle"); hyp.setAttribute("id", "hyp-" + id); @@ -1045,7 +1045,7 @@ function hypothesis_in_rect( width, height, offset_x, offset_y, parent_element, hyp.setAttribute("onmouseover","hover_hyp(" + id + ");") hyp.setAttribute("onmouseout","unhover_hyp(" + id + ");") parent_element.appendChild( hyp ); - + x += diameter; if (++column >= row_size) { column = 0; @@ -1114,7 +1114,7 @@ function hyp_color( id, on_off ) { if (on_off) { var color = "#ff0000"; if (edge[id][RECOMBINED]>0) { color = "#808080"; } - else if (id in reachable) { color = "#00c000"; } + else if (id in reachable) { color = "#00c000"; } return color; } var color = "#ffc0c0"; @@ -1136,26 +1136,26 @@ function get_rule( id ) { var source_target = alignment[i].split("-"); nt_label.push(output[source_target[1]]); } - + var rule = edge[id][LHS]+"\u2192"; var children = get_children(id); var pos = edge[id][FROM]; for (var i=0; i<children.length; i++) { if (pos != edge[id][FROM]) { rule += " "; } var child = children[i]; - for(;pos<edge[child][FROM];pos++) { - rule += (input[pos].length <= 10) ? input[pos] : input[pos].substr(0,8) + "."; + for(;pos<edge[child][FROM];pos++) { + rule += (input[pos].length <= 10) ? input[pos] : input[pos].substr(0,8) + "."; rule += " "; } rule += nt_label[i]; - rule += (edge[child][FROM] == edge[child][TO]) ? + rule += (edge[child][FROM] == edge[child][TO]) ? "[" + edge[child][FROM] + "]" : "[" + edge[child][FROM] + "-" + edge[child][TO] + "]"; pos = edge[child][TO]+1; } - for(;pos<=edge[id][TO];pos++) { + for(;pos<=edge[id][TO];pos++) { if (pos != edge[id][FROM]) { rule += " "; } - rule += (input[pos].length <= 10) ? input[pos] : input[pos].substr(0,8) + "."; + rule += (input[pos].length <= 10) ? input[pos] : input[pos].substr(0,8) + "."; } return rule; @@ -1176,10 +1176,10 @@ function show_rules( from, to ) { cell.setAttribute("stroke-width", "3"); current_rule_from = from; current_rule_to = to; - + best_hyp_score = -9e9; best_derivation_score = cell_derivation_score[from][to]; - + var rule_hash = Array(); var rule_count = Array(); rule_list = Array(); @@ -1196,16 +1196,16 @@ function show_rules( from, to ) { rule_count[rule_hash[rule]]++; } edge2rule[id] = rule_hash[rule]; - - if (edge[id][HYP_SCORE] > best_hyp_score) { - best_hyp_score = edge[id][HYP_SCORE]; + + if (edge[id][HYP_SCORE] > best_hyp_score) { + best_hyp_score = edge[id][HYP_SCORE]; } } function sortByRuleCount( a, b ) { return rule_count[rule_hash[b]] - rule_count[rule_hash[a]]; } rule_list = rule_list.sort(sortByRuleCount); - + RULE_HEIGHT = 15; RULE_FONT_SIZE = 11; // squeeze if too many rules @@ -1214,7 +1214,7 @@ function show_rules( from, to ) { RULE_HEIGHT = Math.floor( RULE_HEIGHT * factor ); RULE_FONT_SIZE = Math.ceil( RULE_FONT_SIZE * factor ); } - + draw_rule_options(); for(var i=-1; i<rule_list.length; i++) { draw_rule(from, to, i); @@ -1243,7 +1243,7 @@ function unshow_rules() { finished = 0; for(var i=1; !finished; i++) { var old = document.getElementById("rule-option-" + i); - if (old != null) { + if (old != null) { chart.removeChild( old ); var old = document.getElementById("rule-option-label-" + i); chart.removeChild( old ); @@ -1306,12 +1306,12 @@ function click_rule( from, to, rule_id ) { // highlight current rule if (current_rule_id>=0) { var rule_label = document.getElementById("rule-"+current_rule_id); - rule_label.setAttribute("style", "font-size: "+RULE_FONT_SIZE+"; font-family: Verdana, Arial;"); + rule_label.setAttribute("style", "font-size: "+RULE_FONT_SIZE+"; font-family: Verdana, Arial;"); } var rule_label = document.getElementById("rule-"+rule_id); rule_label.setAttribute("style", "font-size: "+RULE_FONT_SIZE+"; font-family: Verdana, Arial; font-weight: bold;"); current_rule_id = rule_id; - + // first get all the data output_list = Array(); var output_hash = Array(); @@ -1332,7 +1332,7 @@ function click_rule( from, to, rule_id ) { // create index for children var children = get_children( id ); for(var j=0;j<children.length;j++) { - // init children indices if needed + // init children indices if needed if (j > children_list.length-1) { children_hash.push([]); children_list.push([]); @@ -1346,7 +1346,7 @@ function click_rule( from, to, rule_id ) { } } } - + // sort function sortBySecond(a,b) { asplit = a.split("|"); @@ -1361,7 +1361,7 @@ function click_rule( from, to, rule_id ) { for(var i=0;i<children.length;i++) { children_list[i].sort(sortHypByScore); } - + // select dimensions of rule cube axis = Array(); axis.push(output_list); @@ -1394,7 +1394,7 @@ function draw_rule_cube(z_pos_string) { if (z_pos_string != "") { z_pos = z_pos_string.split(","); } - + // draw rube cube var old = document.getElementById("rule-cube"); if (old != null) { chart.removeChild( old ); } @@ -1439,7 +1439,7 @@ function draw_rule_cube(z_pos_string) { } else if (max_length+8 > CHART_HEIGHT/9) { RULE_CUBE_HYP_SIZE = 9; - RULE_CUBE_FONT_SIZE = 7; + RULE_CUBE_FONT_SIZE = 7; } else { RULE_CUBE_HYP_SIZE = CHART_HEIGHT/(max_length+8); @@ -1455,7 +1455,7 @@ function draw_rule_cube(z_pos_string) { rule_cube.setAttribute("x", CHART_WIDTH - 30); rule_cube.setAttribute("y", 0); chart.appendChild( rule_cube ); - + // draw y axis var label = get_rule_axis_name(dimension_order[0]); draw_rule_row(-1,label); @@ -1470,7 +1470,7 @@ function draw_rule_cube(z_pos_string) { // draw x axis if (axis.length > 1) { var label = get_rule_axis_name(dimension_order[1]); - draw_rule_column(-1,label); + draw_rule_column(-1,label); for(var x=0; x<axis[dimension_order[1]].length && x<CHART_HEIGHT/9-10; x++) { var label = get_rule_axis_label(dimension_order[1], x); draw_rule_column(x,label); @@ -1478,7 +1478,7 @@ function draw_rule_cube(z_pos_string) { if (axis[dimension_order[1]].length > CHART_HEIGHT/9-10) { draw_rule_column(Math.ceil(CHART_HEIGHT/9-10),"(more, "+axis[dimension_order[1]].length+" total)"); } - } + } // draw hyps for(var y=0; y<axis[dimension_order[0]].length && y<(CHART_HEIGHT-Z_HEIGHT)/9-10; y++) { @@ -1493,8 +1493,8 @@ function draw_rule_cube(z_pos_string) { } } } - - + + // draw z-axes var pos_offset = axis[dimension_order[0]].length+2; for(var z=2;z<dimension_order.length;z++) { @@ -1506,7 +1506,7 @@ function draw_rule_cube(z_pos_string) { } pos_offset += axis[dimension_order[z]].length+2; } - + // report summary statistics var message = output_list.length + " output phrases"; message += "<br>DEBUG: " + axis.length; @@ -1514,7 +1514,7 @@ function draw_rule_cube(z_pos_string) { for(var i=0;i<children_list.length;i++) { message += "<br>" + children_list[i].length + " hyps for NT" + (i+1); } - //draw_rule_message(message); + //draw_rule_message(message); } function find_hyp_by_rule(position, dimension_order) { @@ -1524,14 +1524,14 @@ function find_hyp_by_rule(position, dimension_order) { var match = 1; for(var p=0; p<position.length; p++) { if (dimension_order[p] == 0) { - if (output_list[position[p]] != edge[id][OUTPUT]+"|"+edge[id][HEURISTIC_RULE_SCORE]) { + if (output_list[position[p]] != edge[id][OUTPUT]+"|"+edge[id][HEURISTIC_RULE_SCORE]) { match = 0; } } else { var nt_number = dimension_order[p]-1; - if (children_list[nt_number][position[p]] != children[nt_number]) { - match = 0; + if (children_list[nt_number][position[p]] != children[nt_number]) { + match = 0; } } } @@ -1580,7 +1580,7 @@ function get_full_output( id ) { var source_target = alignment[i].split("-"); nonterminal[source_target[1]] = children[i]; } - + var full_output = ""; for(var i=0;i<output.length;i++) { if (nonterminal[i] === undefined) { @@ -1647,7 +1647,7 @@ function draw_rule_z( z,total_z, z_pos, pos,pos_offset, label ) { else { rule_label.setAttribute("style", "font-size: "+(RULE_CUBE_FONT_SIZE-2)+"; font-family: Verdana, Arial; font-weight: bold;"); } - + var content = document.createTextNode( label ); rule_label.appendChild( content ); var rule_cube = document.getElementById("rule-cube"); @@ -1686,7 +1686,7 @@ function rule_hyp_color( id, on_off ) { } else { derivation_score_color = get_score_from_color(best_derivation_score-edge[id][DERIVATION_SCORE]); - } + } } return "#" + inactive_color + derivation_score_color + hyp_score_color; } diff --git a/scripts/ems/web/sgviz.php b/scripts/ems/web/sgviz.php index bac9289ba..9fccadf60 100644 --- a/scripts/ems/web/sgviz.php +++ b/scripts/ems/web/sgviz.php @@ -39,7 +39,7 @@ new Ajax.Request('?analysis=sgviz_data' method: "post" }); </script></body></html> -<?php +<?php // read graph //$file = get_current_analysis_filename("basic","search-graph")."/graph.$sentence"; //$handle = fopen($file,"r"); @@ -55,7 +55,7 @@ function sgviz_data($sentence) { $file = get_current_analysis_filename("basic","search-graph")."/graph.$sentence"; $handle = fopen($file,"r"); - while (($line = fgets($handle)) !== false) { + 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]); } |