Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-05-17 16:04:04 +0300
committerJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-05-17 16:04:04 +0300
commita25193cc5da6a271c4676e843db80ee19221822a (patch)
treedb764696f2e663016a9ab87a95846501c585b4aa /scripts/ems
parent108da163745699e724f581c3d33b1e8a5e26a9e9 (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')
-rwxr-xr-xscripts/ems/experiment.perl310
-rwxr-xr-xscripts/ems/fix-info.perl6
-rwxr-xr-xscripts/ems/support/analysis.perl108
-rwxr-xr-xscripts/ems/support/berkeley-process.sh8
-rwxr-xr-xscripts/ems/support/berkeley-train.sh4
-rwxr-xr-xscripts/ems/support/build-domain-file-from-subcorpora.perl4
-rwxr-xr-xscripts/ems/support/build-sparse-features.perl6
-rwxr-xr-xscripts/ems/support/consolidate-training-data.perl2
-rwxr-xr-xscripts/ems/support/fast-align-in-parts.perl2
-rwxr-xr-xscripts/ems/support/generic-multicore-parallelizer.perl6
-rwxr-xr-xscripts/ems/support/generic-parallelizer.perl6
-rwxr-xr-xscripts/ems/support/input-from-sgm.perl6
-rwxr-xr-xscripts/ems/support/interpolate-lm.perl10
-rwxr-xr-xscripts/ems/support/lmplz-wrapper.perl2
-rwxr-xr-xscripts/ems/support/mml-filter.perl2
-rwxr-xr-xscripts/ems/support/mml-score.perl2
-rwxr-xr-xscripts/ems/support/mml-train.perl2
-rwxr-xr-xscripts/ems/support/prepare-fast-align.perl2
-rwxr-xr-xscripts/ems/support/reference-from-sgm.perl4
-rwxr-xr-xscripts/ems/support/remove-segmentation-markup.perl6
-rwxr-xr-xscripts/ems/support/report-experiment-scores.perl2
-rwxr-xr-xscripts/ems/support/run-command-on-multiple-refsets.perl4
-rwxr-xr-xscripts/ems/support/run-wade.perl2
-rwxr-xr-xscripts/ems/support/split-sentences.perl28
-rwxr-xr-xscripts/ems/support/submit-grid.perl2
-rwxr-xr-xscripts/ems/support/substitute-filtered-tables-and-weights.perl2
-rwxr-xr-xscripts/ems/support/substitute-filtered-tables.perl4
-rwxr-xr-xscripts/ems/support/substitute-weights.perl6
-rwxr-xr-xscripts/ems/support/symmetrize-fast-align.perl2
-rwxr-xr-xscripts/ems/support/thot-lm-wrapper.perl2
-rwxr-xr-xscripts/ems/support/tree-converter-wrapper.perl2
-rwxr-xr-xscripts/ems/support/wrap-xml.perl2
-rw-r--r--scripts/ems/web/analysis.php80
-rw-r--r--scripts/ems/web/analysis_diff.php62
-rw-r--r--scripts/ems/web/bilingual-concordance.css56
-rw-r--r--scripts/ems/web/comment.php2
-rw-r--r--scripts/ems/web/diff.php2
-rw-r--r--scripts/ems/web/hierarchical-segmentation.css8
-rw-r--r--scripts/ems/web/hierarchical-segmentation.js4
-rw-r--r--scripts/ems/web/index.php4
-rw-r--r--scripts/ems/web/javascripts/scriptaculous-js-1.8.3/src/unittest.js132
-rw-r--r--scripts/ems/web/javascripts/sound.js2
-rw-r--r--scripts/ems/web/javascripts/unittest.js132
-rw-r--r--scripts/ems/web/lib.php20
-rw-r--r--scripts/ems/web/overview.php24
-rwxr-xr-xscripts/ems/web/progress.perl2
-rw-r--r--scripts/ems/web/sgviz.js178
-rw-r--r--scripts/ems/web/sgviz.php4
48 files changed, 634 insertions, 634 deletions
diff --git a/scripts/ems/experiment.perl b/scripts/ems/experiment.perl
index 5d68e409c..62b039124 100755
--- a/scripts/ems/experiment.perl
+++ b/scripts/ems/experiment.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
# Experiment Management System
# Documentation at http://www.statmt.org/moses/?n=FactoredTraining.EMS
@@ -30,7 +30,7 @@ my ($CONFIG_FILE,
$DELETE_CRASHED,
$DELETE_VERSION
);
-
+
my $SLEEP = 2;
my $META = "$RealBin/experiment.meta";
@@ -63,7 +63,7 @@ die("experiment.perl -config config-file [-exec] [-no-graph]")
'no-graph' => \$NO_GRAPH);
if (! -e "steps") { `mkdir -p steps`; }
-die("error: could not find config file")
+die("error: could not find config file")
unless ($CONFIG_FILE && -e $CONFIG_FILE) ||
($CONTINUE && -e &steps_file("config.$CONTINUE",$CONTINUE)) ||
($DELETE_CRASHED && -e &steps_file("config.$DELETE_CRASHED",$DELETE_CRASHED)) ||
@@ -159,7 +159,7 @@ exit();
# graph that depicts steps of the experiment, with depedencies
sub init_agenda_graph() {
- my $dir = &check_and_get("GENERAL:working-dir");
+ my $dir = &check_and_get("GENERAL:working-dir");
my $graph_file = &steps_file("graph.$VERSION",$VERSION);
open(PS,">".$graph_file.".ps") or die "Cannot open: $!";
@@ -208,7 +208,7 @@ sub detect_if_cluster {
$CLUSTER = 1;
print "running on a cluster\n" if $CLUSTER;
}
- }
+ }
}
sub detect_if_multicore {
@@ -230,7 +230,7 @@ sub read_meta {
my ($module,$step);
while(<META>) {
s/\#.*$//; # strip comments
- next if /^\s*$/;
+ next if /^\s*$/;
while (/\\\s*$/) {
$_ .= <META>;
s/\s*\\\s*[\n\r]*\s+/ /;
@@ -369,7 +369,7 @@ sub read_config {
else {
print STDERR "BUGGY CONFIG LINE ($line_count): $_";
$error++;
- }
+ }
}
}
die("$error ERROR".(($error>1)?"s":"")." IN CONFIG FILE") if $error;
@@ -406,9 +406,9 @@ sub read_config {
s/\$\{$pattern\}/$o/ if $escaped;
s/\$$pattern/$o/ unless $escaped;
print "$_\n" if $VERBOSE;
- if (/\$/) {
+ if (/\$/) {
print "more resolving needed\n" if $VERBOSE;
- $resolve = 1;
+ $resolve = 1;
}
}
}
@@ -419,12 +419,12 @@ sub read_config {
# check if specified files exist
$error = 0;
foreach my $parameter (keys %CONFIG) {
- foreach (@{$CONFIG{$parameter}}) {
+ foreach (@{$CONFIG{$parameter}}) {
next if $parameter =~ /temp-dir/;
next if (!/^\// || -e); # ok if not file, or exists
- my $file = $_;
+ my $file = $_;
$file =~ s/ .+$//; # remove switches
- my $gz = $file; $gz =~ s/\.gz$//;
+ my $gz = $file; $gz =~ s/\.gz$//;
next if -e $gz; # ok if non gzipped exists
next if `find $file* -maxdepth 0 -follow`; # ok if stem
print STDERR "$parameter: file $_ does not exist!\n";
@@ -515,15 +515,15 @@ sub find_steps_for_module {
print "\t\tproduces $out\n" if $VERBOSE;
next unless defined($NEEDED{$out}) || (defined($FINAL_STEP) && $FINAL_STEP eq $step);
print "\t\tneeded\n" if $VERBOSE;
-
- # if output of a step is specified, you do not have
+
+ # if output of a step is specified, you do not have
# to execute that step
if(defined($CONFIG{$out})) {
$GIVEN{$out} = $step;
next;
}
print "\t\toutput not specified in config\n" if $VERBOSE;
-
+
# not needed, if optional and not specified
if (defined($STEP_IGNORE{$defined_step})) {
my $next = 0;
@@ -560,16 +560,16 @@ sub find_steps_for_module {
# OK, add step to the list
- push @DO_STEP,$step;
+ push @DO_STEP,$step;
$STEP_LOOKUP{$step} = $#DO_STEP;
print "\tdo-step: $step\n" if $VERBOSE;
-
- # mark as pass step (where no action is taken), if step is
+
+ # mark as pass step (where no action is taken), if step is
# optional and nothing needs to be do done
if (defined($STEP_PASS{$defined_step})) {
my $flag = 1;
foreach my $pass (@{$STEP_PASS{$defined_step}}) {
- $flag = 0
+ $flag = 0
if &backoff_and_get(&extend_local_name($module,$set,$pass));
}
$PASS{$#DO_STEP}++ if $flag;
@@ -578,12 +578,12 @@ sub find_steps_for_module {
if (defined($STEP_PASS_IF{$defined_step})) {
my $flag = 0;
foreach my $pass (@{$STEP_PASS_IF{$defined_step}}) {
- $flag = 1
+ $flag = 1
if &backoff_and_get(&extend_local_name($module,$set,$pass));
}
$PASS{$#DO_STEP}++ if $flag;
}
-
+
# special case for passing: steps that only affect factor 0
if (defined($ONLY_FACTOR_0{$defined_step})) {
my $FACTOR = &backoff_and_get_array("LM:$set:factors");
@@ -625,7 +625,7 @@ sub find_steps_for_module {
print "\n\t\tcross-directed to $in\n" if $VERBOSE;
}
elsif(defined($CONFIG{$in})) {
- print "\n\t\t... but that is specified\n" if $VERBOSE;
+ print "\n\t\t... but that is specified\n" if $VERBOSE;
}
else {
push @{$NEEDED{$in}}, $#DO_STEP;
@@ -639,11 +639,11 @@ sub find_steps_for_module {
sub check_producability {
my ($module,$set,$output) = @_;
-
+
# find $output requested as input by step in $module/$set
my @OUT = &construct_input($module,$set,$output);
-
- # if multiple outputs (due to multiple sets merged into one),
+
+ # if multiple outputs (due to multiple sets merged into one),
# only one needs to exist
foreach my $out (@OUT) {
print "producable? $out\n" if $VERBOSE;
@@ -687,12 +687,12 @@ sub construct_input {
# potentially multiple input files
my @IN;
-
+
# input from same module
if ($in !~ /([^:]+):(\S+)/) {
push @IN, &construct_name($module,$set,$in);
}
-
+
# input from previous model, multiple
elsif ($MODULE_TYPE{$1} eq "multiple") {
my @SETS = &get_sets($1);
@@ -711,7 +711,7 @@ sub construct_input {
else {
push @IN,$in;
}
-
+
return @IN;
}
@@ -750,7 +750,7 @@ sub delete_version {
# check which versions are already deleted
my %ALREADY_DELETED;
- my $dir = &check_and_get("GENERAL:working-dir");
+ my $dir = &check_and_get("GENERAL:working-dir");
open(VERSION,"ls $dir/steps/*/deleted.* 2>/dev/null|");
while(<VERSION>) {
/deleted\.(\d+)/;
@@ -787,7 +787,7 @@ sub delete_version {
chomp($step_file);
my $step = &get_step_from_step_file($step_file);
next if $USED_BY_OTHERS{$step};
- &delete_step($step,$DELETE_VERSION);
+ &delete_step($step,$DELETE_VERSION);
}
# orphan killing: delete steps in deleted versions, if they were only preserved because this version needed them
@@ -808,12 +808,12 @@ sub get_step_from_step_file {
$step =~ s/_/:/g;
return $step;
}
-
+
sub delete_step {
my ($step_name,$version) = @_;
my ($module,$set,$step) = &deconstruct_name($step_name);
- my $step_file = &versionize(&step_file2($module,$set,$step),$version);
+ my $step_file = &versionize(&step_file2($module,$set,$step),$version);
print "delete step $step_file\n";
`rm $step_file $step_file.*` if $EXECUTE;
@@ -839,7 +839,7 @@ sub delete_output {
if (-e $file) {
print "\tdelete file $file\n";
`rm $file` if $EXECUTE;
- }
+ }
# delete files that have additional extension
$file =~ /^(.+)\/([^\/]+)$/;
my ($dir,$f) = ($1,$2);
@@ -861,7 +861,7 @@ sub delete_output {
# RE-USE
# look for completed step jobs from previous experiments
sub find_re_use {
- my $dir = &check_and_get("GENERAL:working-dir");
+ my $dir = &check_and_get("GENERAL:working-dir");
return unless -e "$dir/steps";
for(my $i=0;$i<=$#DO_STEP;$i++) {
@@ -953,13 +953,13 @@ sub find_re_use {
$change = 1;
print "\tpassed step $DO_STEP[$_] used in re-use run $run -> fail\n" if $VERBOSE;
}
- }
+ }
}
# re-use step has to exist for this run
if (! defined($RE_USE[$parent]{$reuse_run})) {
print "\tno previous step -> fail\n" if $VERBOSE;
delete($RE_USE[$i]{$run});
- $change = 1;
+ $change = 1;
}
}
}
@@ -967,7 +967,7 @@ sub find_re_use {
}
}
- # summarize and convert hashes into integers for to be re-used
+ # summarize and convert hashes into integers for to be re-used
print "\nSTEP SUMMARY:\n";
open(RE_USE,">".&steps_file("re-use.$VERSION",$VERSION)) or die "Cannot open: $!";
for(my $i=$#DO_STEP;$i>=0;$i--) {
@@ -998,7 +998,7 @@ sub find_dependencies {
}
for(my $i=0;$i<=$#DO_STEP;$i++) {
my $step = $DO_STEP[$i];
- $step =~ /^(.+:)[^:]+$/;
+ $step =~ /^(.+:)[^:]+$/;
my $module_set = $1;
foreach my $needed_by (@{$NEEDED{$module_set.$STEP_OUT{&defined_step($step)}}}) {
print "$needed_by needed by $i\n" if $VERBOSE;
@@ -1020,9 +1020,9 @@ sub draw_agenda_graph {
print DOT " ranksep=0;\n";
for(my $i=0;$i<=$#DO_STEP;$i++) {
my $step = $DO_STEP[$i];
- $step =~ /^(.+):[^:]+$/;
+ $step =~ /^(.+):[^:]+$/;
my $module_set = $1;
- push @{$M{$module_set}},$i;
+ push @{$M{$module_set}},$i;
}
my $i = 0;
my (@G,%GIVEN_NUMBER);
@@ -1049,7 +1049,7 @@ sub draw_agenda_graph {
}
else {
my $step = $DO_STEP[$i];
- $step =~ s/^.+:([^:]+)$/$1/;
+ $step =~ s/^.+:([^:]+)$/$1/;
$step .= " (".$RE_USE[$i].")" if $RE_USE[$i];
my $color = "green";
@@ -1058,7 +1058,7 @@ sub draw_agenda_graph {
$color = "lightblue" if $RE_USE[$i] && $RE_USE[$i] != $VERSION;
$color = "red" if defined($CRASHED{$i});
$color = "lightyellow" if defined($PASS{$i});
-
+
print DOT " $i [label=\"$step\",shape=box,fontsize=10,height=0,style=filled,fillcolor=\"$color\"];\n";
}
}
@@ -1087,7 +1087,7 @@ sub draw_agenda_graph {
sub define_step {
my ($step) = @_;
- my $dir = &check_and_get("GENERAL:working-dir");
+ my $dir = &check_and_get("GENERAL:working-dir");
`mkdir -p $dir` if ! -e $dir;
my @STEP;
if ($step eq "all") {
@@ -1104,14 +1104,14 @@ sub define_step {
next if &define_template($i);
if ($DO_STEP[$i] =~ /^CORPUS:(.+):factorize$/) {
&define_corpus_factorize($i);
- }
+ }
elsif ($DO_STEP[$i] eq 'SPLITTER:train') {
&define_splitter_train($i);
- }
+ }
elsif ($DO_STEP[$i] =~ /^LM:(.+):factorize$/) {
&define_lm_factorize($i,$1);
}
- elsif ($DO_STEP[$i] =~ /^LM:(.+):randomize$/ ||
+ elsif ($DO_STEP[$i] =~ /^LM:(.+):randomize$/ ||
$DO_STEP[$i] eq 'INTERPOLATED-LM:randomize') {
&define_lm_randomize($i,$1);
}
@@ -1178,7 +1178,7 @@ sub define_step {
}
elsif ($DO_STEP[$i] eq 'TUNING:factorize-input') {
&define_tuningevaluation_factorize($i);
- }
+ }
elsif ($DO_STEP[$i] eq 'TUNING:factorize-input-devtest') {
&define_tuningevaluation_factorize($i);
}
@@ -1193,7 +1193,7 @@ sub define_step {
}
elsif ($DO_STEP[$i] =~ /^EVALUATION:(.+):factorize-input$/) {
&define_tuningevaluation_factorize($i);
- }
+ }
elsif ($DO_STEP[$i] =~ /^EVALUATION:(.+):filter$/) {
&define_tuningevaluation_filter($1,$i);
}
@@ -1225,7 +1225,7 @@ sub define_step {
}
}
-# LOOP that executes the steps
+# LOOP that executes the steps
# including checks, if needed to be executed, waiting for completion, and error detection
sub execute_steps {
@@ -1266,7 +1266,7 @@ sub execute_steps {
print "number of steps doable or running: ".(scalar keys %DO)." at ".`date`;
foreach my $step (keys %DO) { print "\t".($DO{$step}==2?"running: ":"doable: ").$DO_STEP[$step]."\n"; }
return unless scalar keys %DO;
-
+
# execute new step
my $done = 0;
foreach my $i (keys %DO) {
@@ -1284,7 +1284,7 @@ sub execute_steps {
# cluster job submission
if ($CLUSTER && (!&is_qsub_script($i) || (&backoff_and_get($DO_STEP[$i].":jobs") && (&backoff_and_get($DO_STEP[$i].":jobs")==1)))) {
$DO{$i}++;
- my $qsub_args = &get_qsub_args($DO_STEP[$i]);
+ my $qsub_args = &get_qsub_args($DO_STEP[$i]);
print "\texecuting $step via qsub $qsub_args ($active active)\n";
my $qsub_command="qsub $qsub_args -S /bin/bash -e $step.STDERR -o $step.STDOUT $step";
print "\t$qsub_command\n" if $VERBOSE;
@@ -1306,8 +1306,8 @@ sub execute_steps {
}
# update state
- &draw_agenda_graph() unless $done;
-
+ &draw_agenda_graph() unless $done;
+
# sleep until one more step is done
while(! $done) {
sleep($SLEEP);
@@ -1328,7 +1328,7 @@ sub execute_steps {
}
}
`touch $running_file`;
- }
+ }
}
}
@@ -1356,17 +1356,17 @@ sub get_qsub_args {
# instead of submited as jobs. here we check for that.
sub is_qsub_script {
my ($i) = @_;
- return (defined($QSUB_STEP{$i}) ||
+ return (defined($QSUB_STEP{$i}) ||
defined($QSUB_SCRIPT{&defined_step($DO_STEP[$i])}));
}
-# write the info file that is consulted to check if
+# write the info file that is consulted to check if
# a steps has to be redone, even if it was run before
sub write_info {
my ($i) = @_;
my $step = $DO_STEP[$i];
my $module_set = $step; $module_set =~ s/:[^:]+$//;
-
+
open(INFO,">".&versionize(&step_file($i)).".INFO") or die "Cannot open: $!";
my %VALUE = &get_parameters_relevant_for_re_use($i);
foreach my $parameter (keys %VALUE) {
@@ -1426,19 +1426,19 @@ sub check_info {
if (defined($ONLY_EXISTENCE_MATTERS{"$module:$step"}{$parameter})) {
print "existence ok\n" if $VERBOSE;
}
- elsif (&match_info_strings($VALUE{$parameter},$INFO{$parameter})) {
- print "ok\n" if $VERBOSE;
+ elsif (&match_info_strings($VALUE{$parameter},$INFO{$parameter})) {
+ print "ok\n" if $VERBOSE;
}
- else {
+ else {
print "mismatch\n" if $VERBOSE;
- return 0;
+ return 0;
}
}
print "\tall parameters match\n" if $VERBOSE;
return 1;
}
-sub match_info_strings {
+sub match_info_strings {
my ($current,$old) = @_;
$current =~ s/ $//;
$old =~ s/ $//;
@@ -1479,7 +1479,7 @@ sub get_parameters_relevant_for_re_use {
my ($out,@INPUT) = &get_output_and_input($i);
my $actually_used = "USED";
foreach my $in_file (@INPUT) {
- $actually_used .= " ".$in_file;
+ $actually_used .= " ".$in_file;
}
$VALUE{"INPUT"} = $actually_used;
@@ -1591,7 +1591,7 @@ sub step_file2 {
my ($module,$set,$step) = @_;
my $dir = &check_and_get("GENERAL:working-dir");
`mkdir -p $dir/steps` if ! -e "$dir/steps";
- my $file = "$dir/steps/$module" . ($set ? ("_".$set) : "") . "_$step";
+ my $file = "$dir/steps/$module" . ($set ? ("_".$set) : "") . "_$step";
return $file;
}
@@ -1609,7 +1609,7 @@ sub defined_step_id {
sub defined_step {
my ($step) = @_;
- my $defined_step = $step;
+ my $defined_step = $step;
$defined_step =~ s/:.+:/:/;
return $defined_step;
}
@@ -1659,7 +1659,7 @@ sub define_corpus_factorize {
my ($output,$input) = &get_output_and_input($step_id);
my $input_extension = &check_backoff_and_get("TRAINING:input-extension");
my $output_extension = &check_backoff_and_get("TRAINING:output-extension");
-
+
my $dir = &check_and_get("GENERAL:working-dir");
my $temp_dir = &check_and_get("INPUT-FACTOR:temp-dir") . ".$VERSION";
my $cmd = "mkdir -p $temp_dir\n"
@@ -1673,7 +1673,7 @@ sub define_corpus_factorize {
"$output.$output_extension",
&check_backoff_and_get_array("TRAINING:output-factors"),
$step_id);
-
+
&create_step($step_id,$cmd);
}
@@ -1689,7 +1689,7 @@ sub define_tuningevaluation_factorize {
. &factorize_one_language("INPUT-FACTOR",$input,$output,
&check_backoff_and_get_array("TRAINING:input-factors"),
$step_id);
-
+
&create_step($step_id,$cmd);
}
@@ -1700,12 +1700,12 @@ sub define_lm_factorize {
my ($output,$input) = &get_output_and_input($step_id);
print "LM:$set:factors\n" if $VERBOSE;
my $factor = &check_backoff_and_get_array("LM:$set:factors");
-
+
my $dir = &check_and_get("GENERAL:working-dir");
my $temp_dir = &check_and_get("INPUT-FACTOR:temp-dir") . ".$VERSION";
my $cmd = "mkdir -p $temp_dir\n"
. &factorize_one_language("OUTPUT-FACTOR",$input,$output,$factor,$step_id);
-
+
&create_step($step_id,$cmd);
}
@@ -1715,12 +1715,12 @@ sub define_interpolated_lm_factorize_tuning {
my ($output,$input) = &get_output_and_input($step_id);
my $factor = &check_backoff_and_get_array("TRAINING:output-factors");
-
+
my $dir = &check_and_get("GENERAL:working-dir");
my $temp_dir = &check_and_get("INPUT-FACTOR:temp-dir") . ".$VERSION";
my $cmd = "mkdir -p $temp_dir\n"
. &factorize_one_language("OUTPUT-FACTOR",$input,$output,$factor,$step_id);
-
+
&create_step($step_id,$cmd);
}
@@ -1732,7 +1732,7 @@ sub define_splitter_train {
my $output_splitter = &get("GENERAL:output-splitter");
my $input_extension = &check_backoff_and_get("SPLITTER:input-extension");
my $output_extension = &check_backoff_and_get("SPLITTER:output-extension");
-
+
my $cmd = "";
if ($input_splitter) {
$cmd .= "$input_splitter -train -model $output.$input_extension -corpus $input.$input_extension\n";
@@ -1747,7 +1747,7 @@ sub define_splitter_train {
sub define_lm_train_randomized {
my ($step_id,$set) = @_;
my $training = &check_backoff_and_get("LM:$set:rlm-training");
- my $order = &check_backoff_and_get("LM:$set:order");
+ my $order = &check_backoff_and_get("LM:$set:order");
my ($output,$input) = &get_output_and_input($step_id);
$output =~ /^(.+)\/([^\/]+)$/;
@@ -1765,7 +1765,7 @@ sub define_lm_randomize {
my ($module,$set,$stepname) = &deconstruct_name($DO_STEP[$step_id]);
my $randomizer = &check_backoff_and_get("$module:$set:lm-randomizer");
- my $order = &check_backoff_and_get("$module:$set:order");
+ my $order = &check_backoff_and_get("$module:$set:order");
my ($output,$input) = &get_output_and_input($step_id);
$output =~ /^(.+)\/([^\/]+)$/;
@@ -1782,7 +1782,7 @@ sub factorize_one_language {
my $temp_dir = &check_and_get("INPUT-FACTOR:temp-dir") . ".$VERSION";
my $parallelizer = &get("GENERAL:generic-parallelizer");
my ($module,$set,$stepname) = &deconstruct_name($DO_STEP[$step_id]);
-
+
my ($cmd,$list) = ("");
foreach my $factor (@{$FACTOR}) {
if ($factor eq "word") {
@@ -1791,7 +1791,7 @@ sub factorize_one_language {
else {
my $script = &check_and_get("$type:$factor:factor-script");
my $out = "$outfile.$factor";
- if ($parallelizer && defined($PARALLELIZE{&defined_step($DO_STEP[$step_id])})
+ if ($parallelizer && defined($PARALLELIZE{&defined_step($DO_STEP[$step_id])})
&& ( (&get("$module:jobs") && $CLUSTER)
|| (&get("$module:cores") && $MULTICORE))) {
my $subdir = $module;
@@ -1803,7 +1803,7 @@ sub factorize_one_language {
$qflags="--queue-flags \"$qsub_args\"" if ($CLUSTER && $qsub_args);
$cmd .= "$parallelizer $qflags -in $infile -out $out -cmd '$script %s %s $temp_dir/$subdir' -jobs ".&get("$module:jobs")." -tmpdir $temp_dir/$subdir\n";
$QSUB_STEP{$step_id}++;
- }
+ }
elsif ($MULTICORE) {
$cmd .= "$parallelizer -in $infile -out $out -cmd '$script %s %s $temp_dir/$subdir' -cores ".&get("$module:cores")." -tmpdir $temp_dir/$subdir\n";
}
@@ -1825,9 +1825,9 @@ sub define_tuning_tune {
my $use_mira = &backoff_and_get("TUNING:use-mira", 0);
my $word_alignment = &backoff_and_get("TRAINING:include-word-alignment-in-rules");
my $tmp_dir = &get_tmp_file("TUNING","","tune");
-
- # the last 3 variables are only used for mira tuning
- my ($tuned_config,$config,$input,$reference,$config_devtest,$input_devtest,$reference_devtest, $filtered_config) = &get_output_and_input($step_id);
+
+ # the last 3 variables are only used for mira tuning
+ my ($tuned_config,$config,$input,$reference,$config_devtest,$input_devtest,$reference_devtest, $filtered_config) = &get_output_and_input($step_id);
$config = $filtered_config if $filtered_config;
@@ -1853,13 +1853,13 @@ sub define_tuning_tune {
my $mira_config = "$tmp_dir/mira-config.$VERSION.";
my $mira_config_log = $mira_config."log";
$mira_config .= "cfg";
-
+
write_mira_config($mira_config,$tmp_dir,$config,$input,$reference,$config_devtest,$input_devtest,$reference_devtest);
#$cmd = "$tuning_script -config $mira_config -exec >& $mira_config_log";
# we want error messages in top-level log file
$cmd = "$tuning_script -config $mira_config -exec ";
- # write script to select the best set of weights after training for the specified number of epochs -->
+ # write script to select the best set of weights after training for the specified number of epochs -->
# cp to tuning/tmp.?/moses.ini
my $script_filename = "$tmp_dir/selectBestWeights.";
my $script_filename_log = $script_filename."log";
@@ -1881,7 +1881,7 @@ sub define_tuning_tune {
my $decoder_settings = &backoff_and_get("TUNING:decoder-settings");
$decoder_settings = "" unless $decoder_settings;
$decoder_settings .= " -v 0 " unless $CLUSTER && $jobs && $jobs>1;
-
+
my $tuning_settings = &backoff_and_get("TUNING:tuning-settings");
$tuning_settings = "" unless $tuning_settings;
@@ -1890,7 +1890,7 @@ sub define_tuning_tune {
$cmd .= " --continue" if $tune_continue;
$cmd .= " --skip-decoder" if $skip_decoder;
$cmd .= " --inputtype $tune_inputtype" if defined($tune_inputtype);
-
+
my $qsub_args = &get_qsub_args($DO_STEP[$step_id]);
$cmd .= " --queue-flags=\"$qsub_args\"" if ($CLUSTER && $qsub_args);
$cmd .= " --jobs $jobs" if $CLUSTER && $jobs && $jobs>1;
@@ -1898,14 +1898,14 @@ sub define_tuning_tune {
$tuning_dir =~ s/\/[^\/]+$//;
$cmd .= "\nmkdir -p $tuning_dir";
}
-
+
$cmd .= "\ncp $tmp_dir/moses.ini $tuned_config";
&create_step($step_id,$cmd);
}
sub write_mira_config {
- my ($config_filename,$expt_dir,$tune_filtered_ini,$input,$reference,$devtest_filtered_ini,$input_devtest,$reference_devtest) = @_;
+ my ($config_filename,$expt_dir,$tune_filtered_ini,$input,$reference,$devtest_filtered_ini,$input_devtest,$reference_devtest) = @_;
my $moses_src_dir = &check_and_get("GENERAL:moses-src-dir");
my $mira_src_dir = &backoff_and_get("GENERAL:mira-src-dir");
my $tuning_decoder_settings = &check_and_get("TUNING:decoder-settings");
@@ -1916,7 +1916,7 @@ sub write_mira_config {
my $use_jackknife = &backoff_and_get("TUNING:use-jackknife");
# are we tuning a meta feature?
- my $tune_meta_feature = &backoff_and_get("TUNING:tune-meta-feature");
+ my $tune_meta_feature = &backoff_and_get("TUNING:tune-meta-feature");
my $tune_filtered_ini_start;
if (!$use_jackknife) {
@@ -1927,13 +1927,13 @@ sub write_mira_config {
# apply start weights to filtered ini file, and pass the new ini to mira
print "DEBUG: $RealBin/support/substitute-weights.perl $start_weights $tune_filtered_ini $tune_filtered_ini_start \n";
system("$RealBin/support/substitute-weights.perl $start_weights $tune_filtered_ini $tune_filtered_ini_start");
- }
+ }
}
# do we want to continue an interrupted experiment?
my $continue_expt = &backoff_and_get("TUNING:continue-expt");
my $continue_epoch = &backoff_and_get("TUNING:continue-epoch");
- my $continue_weights = &backoff_and_get("TUNING:continue-weights");
+ my $continue_weights = &backoff_and_get("TUNING:continue-weights");
# mira config file
open(CFG, ">$config_filename");
@@ -1956,7 +1956,7 @@ sub write_mira_config {
print CFG "tune-meta-feature=1 \n" if ($tune_meta_feature);
print CFG "jackknife=1 \n" if ($use_jackknife);
print CFG "wait-for-bleu=1 \n\n";
- #print CFG "decoder-settings=".$tuning_decoder_settings."\n\n";
+ #print CFG "decoder-settings=".$tuning_decoder_settings."\n\n";
print CFG "[train] \n";
print CFG "trainer=\${moses-home}/bin/mira \n";
if ($use_jackknife) {
@@ -1972,7 +1972,7 @@ sub write_mira_config {
}
else {
print CFG $input.".only$i, " if $i<9;
- print CFG $input.".only$i" if $i==9;
+ print CFG $input.".only$i" if $i==9;
}
}
print CFG "\n";
@@ -1999,14 +1999,14 @@ sub write_mira_config {
print CFG "moses-ini-file=".$tune_filtered_ini."\n";
}
}
- print CFG "decoder-settings=".$tuning_decoder_settings." -text-type \"dev\"\n";
- print CFG "hours=48 \n";
+ print CFG "decoder-settings=".$tuning_decoder_settings." -text-type \"dev\"\n";
+ print CFG "hours=48 \n";
if ($parallel_settings) {
foreach my $setting (split(" ", $parallel_settings)) {
print CFG $setting."\n";
}
}
- print CFG "extra-args=".$tuning_settings."\n\n";
+ print CFG "extra-args=".$tuning_settings."\n\n";
print CFG "[devtest] \n";
if (&get("TRAINING:hierarchical-rule-set")) {
print CFG "moses=\${moses-home}/bin/moses_chart \n";
@@ -2019,7 +2019,7 @@ sub write_mira_config {
print CFG "input-file=".$input_devtest."\n";
print CFG "reference-file=".$reference_devtest."\n";
print CFG "moses-ini-file=".$devtest_filtered_ini."\n";
- print CFG "decoder-settings=".$tuning_decoder_settings." -text-type \"devtest\"\n";
+ print CFG "decoder-settings=".$tuning_decoder_settings." -text-type \"devtest\"\n";
print CFG "hours=12 \nextra-args= \nskip-dev=1 \nskip-devtest=0 \nskip-submit=0 \n";
close(CFG);
}
@@ -2052,7 +2052,7 @@ sub write_selectBestMiraWeights {
print SCR "} \n\n";
print SCR "print STDERR \"Best weights according to BLEU on devtest set: \$best_weights \\n\"; \n";
print SCR "system(\"cp \$best_weights $weight_out_file\"); \n\n";
-
+
close(SCR);
system("chmod u+x $script_filename");
}
@@ -2118,7 +2118,7 @@ sub define_training_symmetrize_giza {
my $method = &check_and_get("TRAINING:alignment-symmetrization-method");
my $cmd = &get_training_setting(3);
my $alignment_stem = &versionize(&long_file_name("aligned","model",""));
-
+
$cmd .= "-giza-e2f $giza -giza-f2e $giza_inv ";
$cmd .= "-alignment-file $aligned ";
$cmd .= "-alignment-stem $alignment_stem ";
@@ -2129,17 +2129,17 @@ sub define_training_symmetrize_giza {
sub define_training_build_suffix_array {
my ($step_id) = @_;
-
+
my $scripts = &check_and_get("GENERAL:moses-script-dir");
-
+
my ($model, $aligned,$corpus) = &get_output_and_input($step_id);
my $sa_exec_dir = &check_and_get("TRAINING:suffix-array");
my $input_extension = &check_backoff_and_get("TRAINING:input-extension");
my $output_extension = &check_backoff_and_get("TRAINING:output-extension");
my $method = &check_and_get("TRAINING:alignment-symmetrization-method");
-
+
my $glue_grammar_file = &versionize(&long_file_name("glue-grammar","model",""));
-
+
my $cmd = "$scripts/training/wrappers/adam-suffix-array/suffix-array-create.sh $sa_exec_dir $corpus.$input_extension $corpus.$output_extension $aligned.$method $model $glue_grammar_file";
&create_step($step_id,$cmd);
@@ -2222,7 +2222,7 @@ sub define_training_extract_phrases {
$cmd .= "-alignment-stem $alignment_stem ";
$cmd .= "-extract-file $extract ";
$cmd .= "-corpus $corpus ";
-
+
if (&get("TRAINING:hierarchical-rule-set")) {
my $no_glue_grammar = &get("TRAINING:no-glue-grammar");
if (!defined($no_glue_grammar) || $no_glue_grammar eq "false") {
@@ -2327,7 +2327,7 @@ sub define_training_build_ttable {
$cmd .= "-ghkm-parts-of-speech-file $parts_of_speech_labels_file ";
}
}
-
+
&create_step($step_id,$cmd);
}
@@ -2346,7 +2346,7 @@ sub define_domain_feature_score_option {
else {
return "-score-options '--Domain$method $domains' ";
}
-}
+}
sub define_training_build_reordering {
my ($step_id) = @_;
@@ -2406,8 +2406,8 @@ sub define_training_sigtest_filter {
chop($filtered_table);
}
$raw_table =~ s/\s*\-\S+\s*//; # remove switch
- $filtered_table =~ s/\s*\-\S+\s*//;
-
+ $filtered_table =~ s/\s*\-\S+\s*//;
+
my $cmd = "zcat $raw_table.gz | $moses_src_dir/contrib/sigtest-filter/filter-pt -e $suffix_array.$output_extension -f $suffix_array.$input_extension $sigtest_filter $hierarchical_flag | gzip - > $filtered_table.gz\n";
&create_step($step_id,$cmd);
}
@@ -2461,7 +2461,7 @@ sub get_config_tables {
# additional settings for hierarchical models
my $extract_version = $VERSION;
if (&get("TRAINING:hierarchical-rule-set")) {
- $extract_version = $RE_USE[$STEP_LOOKUP{"TRAINING:extract-phrases"}]
+ $extract_version = $RE_USE[$STEP_LOOKUP{"TRAINING:extract-phrases"}]
if defined($STEP_LOOKUP{"TRAINING:extract-phrases"});
my $no_glue_grammar = &get("TRAINING:no-glue-grammar");
if (!defined($no_glue_grammar) || $no_glue_grammar eq "false") {
@@ -2506,10 +2506,10 @@ sub define_training_create_config {
if($transliteration_pt){
$cmd .= "-transliteration-phrase-table $transliteration_pt ";
- }
+ }
if ($osm) {
- my $osm_settings = &get("TRAINING:operation-sequence-model-settings");
+ my $osm_settings = &get("TRAINING:operation-sequence-model-settings");
if ($osm_settings =~ /-factor *(\S+)/){
$cmd .= "-osm-model $osm/ -osm-setting $1 ";
}
@@ -2547,7 +2547,7 @@ sub define_training_create_config {
$type = 5 if (&get("INTERPOLATED-LM:rlm") ||
&backoff_and_get("INTERPOLATED-LM:lm-randomizer"));
- # manually set type
+ # manually set type
$type = &get("INTERPOLATED-LM:type") if &get("INTERPOLATED-LM:type");
# go through each interpolated language model
@@ -2588,7 +2588,7 @@ sub define_training_create_config {
&backoff_and_get("LM:$set:rlm-training") ||
&backoff_and_get("LM:$set:lm-randomizer"));
- # manually set type
+ # manually set type
$type = &backoff_and_get("LM:$set:type") if (&backoff_and_get("LM:$set:type"));
# binarized by INTERPOLATED-LM
@@ -2596,7 +2596,7 @@ sub define_training_create_config {
$lm_file =~ s/\.lm/\.binlm/;
$type = 1;
$type = &get("INTERPOLATED-LM:type") if &get("INTERPOLATED-LM:type");
- }
+ }
# which factor is the model trained on?
my $factor = 0;
@@ -2631,7 +2631,7 @@ sub define_interpolated_lm_interpolate {
}
}
- # go through language models by factor and order
+ # go through language models by factor and order
my ($icount,$ILM_SETS) = &get_interpolated_lm_sets();
foreach my $factor (keys %{$ILM_SETS}) {
foreach my $order (keys %{$$ILM_SETS{$factor}}) {
@@ -2643,8 +2643,8 @@ sub define_interpolated_lm_interpolate {
foreach my $id_set (@{$$ILM_SETS{$factor}{$order}}) {
my ($id,$set) = split(/ /,$id_set,2);
$lm_list .= $LM[$id].",";
- if (defined($weights)) {
- die("ERROR: no interpolation weight set for $factor:$order:$set (factor:order:set)")
+ if (defined($weights)) {
+ die("ERROR: no interpolation weight set for $factor:$order:$set (factor:order:set)")
unless defined($WEIGHT{"$factor:$order:$set"});
$weight_list .= $WEIGHT{"$factor:$order:$set"}.",";
}
@@ -2708,7 +2708,7 @@ sub define_interpolated_lm_process {
my $tool = &check_backoff_and_get("INTERPOLATED-LM:lm-${stepname}r");
my $FACTOR = &backoff_and_get_array("TRAINING:output-factors");
- # go through language models by factor and order
+ # go through language models by factor and order
my ($icount,$ILM_SETS) = &get_interpolated_lm_sets();
my $cmd = "";
foreach my $factor (keys %{$ILM_SETS}) {
@@ -2729,7 +2729,7 @@ sub define_interpolated_lm_process {
$name = "$interpolated_lm$suffix";
$name_processed = "$processed_lm$suffix";
}
- $cmd .= "$tool $name $name_processed\n";
+ $cmd .= "$tool $name $name_processed\n";
}
}
@@ -2768,7 +2768,7 @@ sub get_interpolated_lm_sets {
my $icount=0;
foreach my $set (@LM_SETS) {
my $order = &check_backoff_and_get("LM:$set:order");
-
+
my $factor = 0;
if (&backoff_and_get("TRAINING:output-factors") &&
&backoff_and_get("LM:$set:factors")) {
@@ -2873,7 +2873,7 @@ sub get_table_name_settings {
push @NAME,"$default.$f";
# push @NAME,"$dir/model/$table.$VERSION.$f";
}
-
+
# get specified names, if any
if (&get("TRAINING:$table")) {
my @SPECIFIED_NAME = @{$CONFIG{"TRAINING:$table"}};
@@ -2890,7 +2890,7 @@ sub get_table_name_settings {
$cmd .= "-$table $name ";
}
return $cmd;
-}
+}
sub get_factor_id {
my ($type) = @_;
@@ -2908,7 +2908,7 @@ sub encode_factor_definition {
my $encoded;
foreach my $mapping (split(/,\s*/,$definition)) {
my ($in,$out) = split(/\s*->\s*/,$mapping);
- $encoded .=
+ $encoded .=
&encode_factor_list($IN,$in)."-".
&encode_factor_list($OUT,$out)."+";
}
@@ -2941,22 +2941,22 @@ sub define_tuningevaluation_filter {
$binarizer = &backoff_and_get("EVALUATION:$set:ttable-binarizer") unless $tuning_flag;
$binarizer = &backoff_and_get("TUNING:ttable-binarizer") if $tuning_flag;
my $report_precision_by_coverage = !$tuning_flag && &backoff_and_get("EVALUATION:$set:report-precision-by-coverage");
-
- # occasionally, lattices and conf nets need to be able
- # to filter phrase tables, we can provide sentences/ngrams
+
+ # occasionally, lattices and conf nets need to be able
+ # to filter phrase tables, we can provide sentences/ngrams
# in a separate file
my $input_filter;
$input_filter = &get("EVALUATION:$set:input-filter") unless $tuning_flag;
$input_filter = &get("TUNING:input-filter") if $tuning_flag;
#print "filter: $input_filter \n";
$input_filter = $input unless $input_filter;
-
+
my $settings = &backoff_and_get("EVALUATION:$set:filter-settings") unless $tuning_flag;
$settings = &backoff_and_get("TUNING:filter-settings") if $tuning_flag;
$settings = "" unless $settings;
$binarizer .= " -no-alignment-info" if defined ($binarizer) && !$hierarchical && defined $word_alignment && $word_alignment eq "no";
-
+
$settings .= " -Binarizer \"$binarizer\"" if $binarizer;
$settings .= " --Hierarchical" if $hierarchical;
@@ -2992,13 +2992,13 @@ sub define_tuningevaluation_filter {
$config = $tuning_flag ? "$dir/tuning/moses.table.ini.$VERSION" : "$dir/evaluation/$set.moses.table.ini.$VERSION";
$cmd = "touch $config\n";
$delete_config = 1;
-
+
$cmd .= &get_config_tables($config,$reordering_table,$phrase_translation_table,undef,$domains);
if (&get("TRAINING:in-decoding-transliteration")) {
$cmd .= "-transliteration-phrase-table $dir/model/transliteration-phrase-table.$VERSION ";
- }
+ }
$cmd .= "-lm 0:3:$config:8\n"; # dummy kenlm 3-gram model on factor 0
@@ -3009,12 +3009,12 @@ sub define_tuningevaluation_filter {
if ($sa_exec_dir) {
# suffix array
$cmd .= "$scripts/training/wrappers/adam-suffix-array/suffix-array-extract.sh $sa_exec_dir $phrase_translation_table $input_filter $filter_dir $sa_extractors \n";
-
+
my $escaped_filter_dir = $filter_dir;
$escaped_filter_dir =~ s/\//\\\\\//g;
$cmd .= "cat $config | sed s/10\\ 0\\ 0\\ 7.*/10\\ 0\\ 0\\ 7\\ $escaped_filter_dir/g > $filter_dir/moses.ini \n";
- # kind of a hack -- the correct thing would be to make the generation of the config file ($filter_dir/moses.ini)
- # set the PhraseDictionaryALSuffixArray's path to the filtered directory rather than to the suffix array itself
+ # kind of a hack -- the correct thing would be to make the generation of the config file ($filter_dir/moses.ini)
+ # set the PhraseDictionaryALSuffixArray's path to the filtered directory rather than to the suffix array itself
$cmd .= "sed -i 's%path=$phrase_translation_table%path=$filter_dir%' $filter_dir/moses.ini\n";
}
else {
@@ -3022,7 +3022,7 @@ sub define_tuningevaluation_filter {
$cmd .= "$scripts/training/filter-model-given-input.pl";
$cmd .= " $filter_dir $config $input_filter $settings\n";
}
-
+
# clean-up
$cmd .= "rm $config" if $delete_config;
@@ -3033,7 +3033,7 @@ sub define_evaluation_decode {
my ($set,$step_id) = @_;
my $scripts = &check_and_get("GENERAL:moses-script-dir");
my $dir = &check_and_get("GENERAL:working-dir");
-
+
my ($system_output,
$config,$input,$filtered_config) = &get_output_and_input($step_id);
$config = $filtered_config if $filtered_config;
@@ -3051,12 +3051,12 @@ sub define_evaluation_decode {
my $hierarchical = &get("TRAINING:hierarchical-rule-set");
my $word_alignment = &backoff_and_get("TRAINING:include-word-alignment-in-rules");
my $post_decoding_transliteration = &get("TRAINING:post-decoding-transliteration");
-
- # If Transliteration Module is to be used as post-decoding step ...
+
+ # If Transliteration Module is to be used as post-decoding step ...
if (defined($post_decoding_transliteration) && $post_decoding_transliteration eq "yes"){
$settings .= " -output-unknowns $system_output.oov";
}
-
+
# specify additional output for analysis
if (defined($report_precision_by_coverage) && $report_precision_by_coverage eq "yes") {
@@ -3095,7 +3095,7 @@ sub define_evaluation_decode {
$cmd .= "mkdir -p $dir/evaluation/tmp.$set.$VERSION\n";
$cmd .= "cd $dir/evaluation/tmp.$set.$VERSION\n";
if (defined $moses_parallel) {
- $cmd .= $moses_parallel;
+ $cmd .= $moses_parallel;
} else {
$cmd .= "$scripts/generic/moses-parallel.pl";
}
@@ -3105,7 +3105,7 @@ sub define_evaluation_decode {
$cmd .= " -config $config";
$cmd .= " -input-file $input";
$cmd .= " --jobs $jobs";
- $cmd .= " -decoder-parameters \"$settings\" > $system_output";
+ $cmd .= " -decoder-parameters \"$settings\" > $system_output";
$cmd .= " -n-best-file $system_output.best$nbest_size -n-best-size $nbest" if $nbest;
}
else {
@@ -3252,12 +3252,12 @@ sub define_reporting_report {
my $scripts = &check_and_get("GENERAL:moses-script-dir");
my $cmd = "$scripts/ems/support/report-experiment-scores.perl";
-
+
# get scores that were produced
foreach my $parent (@{$DEPENDENCY[$step_id]}) {
- my ($parent_module,$parent_set,$parent_step)
+ my ($parent_module,$parent_set,$parent_step)
= &deconstruct_name($DO_STEP[$parent]);
-
+
my $file = &get_default_file($parent_module,$parent_set,$parent_step);
$cmd .= " set=$parent_set,type=$parent_step,file=$file";
}
@@ -3282,7 +3282,7 @@ sub get_output_and_input {
my $output = &get_default_file(&deconstruct_name($step));
my @INPUT;
- if (defined($USES_INPUT{$step_id})) {
+ if (defined($USES_INPUT{$step_id})) {
for(my $i=0; $i<scalar @{$USES_INPUT{$step_id}}; $i++) {
# get name of input file needed
my $in_file = $USES_INPUT{$step_id}[$i];
@@ -3293,9 +3293,9 @@ sub get_output_and_input {
my $prev_step = "";
# print "\tlooking up in_file $in_file\n";
foreach my $parent (@{$DEPENDENCY[$step_id]}) {
- my ($parent_module,$parent_set,$parent_step)
+ my ($parent_module,$parent_set,$parent_step)
= &deconstruct_name($DO_STEP[$parent]);
- my $parent_file
+ my $parent_file
= &construct_name($parent_module,$parent_set,
$STEP_OUT{&defined_step($DO_STEP[$parent])});
if ($in_file eq $parent_file) {
@@ -3367,12 +3367,12 @@ sub define_template {
if ($single_cmd =~ /^ln /) {
$new_cmd .= $single_cmd."\n";
}
- elsif ($single_cmd =~ /^.+$/) {
+ elsif ($single_cmd =~ /^.+$/) {
# find IN and OUT files
$single_cmd =~ /(EMS_IN_EMS\S*)/
|| die("ERROR: could not find EMS_IN_EMS in $single_cmd");
my $in = $1;
- $single_cmd =~ /(EMS_OUT_EMS\S*)/
+ $single_cmd =~ /(EMS_OUT_EMS\S*)/
|| die("ERROR: could not find OUT in $single_cmd");
my $out = $1;
# replace IN and OUT with %s
@@ -3388,13 +3388,13 @@ sub define_template {
my $qsub_args = &get_qsub_args($DO_STEP[$step_id]);
$qflags="--queue-flags \"$qsub_args\"" if ($CLUSTER && $qsub_args);
$new_cmd .= "$parallelizer $qflags -in $in -out $out -cmd '$single_cmd' -jobs ".&get("$module:jobs")." -tmpdir $dir/$tmp_dir\n";
- }
+ }
if ($MULTICORE) {
$new_cmd .= "$parallelizer -in $in -out $out -cmd '$single_cmd' -cores ".&get("$module:cores")." -tmpdir $dir/$tmp_dir\n";
}
}
}
-
+
$cmd = $new_cmd;
$QSUB_STEP{$step_id}++;
}
@@ -3468,12 +3468,12 @@ sub create_step {
my $file = &versionize(&step_file2($module,$set,$step));
my $dir = &check_and_get("GENERAL:working-dir");
my $subdir = $module;
- $subdir =~ tr/A-Z/a-z/;
+ $subdir =~ tr/A-Z/a-z/;
$subdir = "evaluation" if $subdir eq "reporting";
$subdir = "lm" if $subdir eq "interpolated-lm";
open(STEP,">$file") or die "Cannot open: $!";
print STEP "#!/bin/bash\n\n";
- print STEP "PATH=\"".$ENV{"PATH"}."\"\n";
+ print STEP "PATH=\"".$ENV{"PATH"}."\"\n";
print STEP "cd $dir\n";
print STEP "echo 'starting at '`date`' on '`hostname`\n";
print STEP "mkdir -p $dir/$subdir\n\n";
@@ -3481,7 +3481,7 @@ sub create_step {
print STEP "echo 'finished at '`date`\n";
print STEP "touch $file.DONE\n";
close(STEP);
-}
+}
sub get {
return &check_and_get($_[0],"allow_undef");
@@ -3541,7 +3541,7 @@ sub check_backoff_and_get_array {
sub get_specified_or_default_file {
my ($specified_module,$specified_set,$specified_parameter,
$default_module, $default_set, $default_step) = @_;
- my $specified =
+ my $specified =
&construct_name($specified_module,$specified_set,$specified_parameter);
if (defined($CONFIG{$specified})) {
print "\t\texpanding $CONFIG{$specified}[0]\n" if $VERBOSE;
@@ -3624,7 +3624,7 @@ sub long_file_name {
$file = "$dir/$file";
}
- my $module_working_dir_parameter =
+ my $module_working_dir_parameter =
$module . ($set ne "" ? ":$set" : "") . ":working-dir";
if (defined($CONFIG{$module_working_dir_parameter})) {
@@ -3634,7 +3634,7 @@ sub long_file_name {
}
sub compute_version_number {
- my $dir = &check_and_get("GENERAL:working-dir");
+ my $dir = &check_and_get("GENERAL:working-dir");
$VERSION = 1;
return unless -e $dir;
open(LS,"find $dir/steps -maxdepth 1 -follow |");
diff --git a/scripts/ems/fix-info.perl b/scripts/ems/fix-info.perl
index 8f83d4ccf..abe58fe83 100755
--- a/scripts/ems/fix-info.perl
+++ b/scripts/ems/fix-info.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -8,7 +8,7 @@ $step = "*" unless defined($step);
die("fix-info.perl file [step]") unless defined($file);
die("file not found") unless -e $file;
-die("full path!") unless $file =~ /^\//;
+die("full path!") unless $file =~ /^\//;
my @filestat = stat($file);
my $newtime = $filestat[9];
@@ -21,7 +21,7 @@ while(my $info = <LS>) {
if (/$file .*\[/) {
$changed++;
s/($file) (.*\[)\d+/$1 $2$newtime/g;
- }
+ }
}
if ($changed) {
print "updating $info\n";
diff --git a/scripts/ems/support/analysis.perl b/scripts/ems/support/analysis.perl
index cea2657c9..f4d5a55b4 100755
--- a/scripts/ems/support/analysis.perl
+++ b/scripts/ems/support/analysis.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -29,7 +29,7 @@ if (!&GetOptions('system=s' => \$system, # raw output from decoder
'search-graph=s' => \$search_graph, # visualization of search graph
'hierarchical' => \$hierarchical) || # hierarchical model?
!defined($dir)) {
- die("ERROR: syntax: analysis.perl -system FILE -reference FILE -dir DIR [-input FILE] [-input-corpus FILE] [-ttable FILE] [-score-options SETTINGS] [-segmentation FILE] [-output-corpus FILE] [-alignment-file FILE] [-biconcor BIN]");
+ die("ERROR: syntax: analysis.perl -system FILE -reference FILE -dir DIR [-input FILE] [-input-corpus FILE] [-ttable FILE] [-score-options SETTINGS] [-segmentation FILE] [-output-corpus FILE] [-alignment-file FILE] [-biconcor BIN]");
}
`mkdir -p $dir`;
@@ -95,7 +95,7 @@ if (defined($segmentation)) {
# coverage analysis
my (%INPUT_PHRASE,%CORPUS_COVERED,%TTABLE_COVERED,%TTABLE_ENTROPY);
-if (!defined($coverage_dir) && (defined($ttable) || defined($corpus))) {
+if (!defined($coverage_dir) && (defined($ttable) || defined($corpus))) {
if (!defined($input)) {
die("ERROR: when specifying either ttable or input-corpus, please also specify input\n");
}
@@ -170,7 +170,7 @@ sub input_phrases {
$line = &get_factor_phrase($factor,$line);
&extract_n_grams($line,\%INPUT_PHRASE);
}
- close(INPUT);
+ close(INPUT);
}
# reduce a factorized phrase into the factors of interest
@@ -279,11 +279,11 @@ sub bleu_annotation {
}
if (ref($REFERENCE[$i]) eq 'ARRAY') {
foreach my $ref (@{$REFERENCE[$i]}) {
- print OUT "\t".$ref;
+ print OUT "\t".$ref;
}
}
else {
- print OUT "\t".$REFERENCE[$i]
+ print OUT "\t".$REFERENCE[$i]
}
print OUT "\n";
}
@@ -301,7 +301,7 @@ sub add_match {
my $ref_count = 0;
$ref_count = $REF_NGRAM{$length}{$ngram} if defined($REF_NGRAM{$length}{$ngram});
my $match_count = ($sys_count > $ref_count) ? $ref_count : $sys_count;
-
+
$$CORRECT{$length}{$ngram} += $match_count;
$$TOTAL{$length}{$ngram} += $sys_count;
#print "$length:$ngram $sys_count $ref_count\n";
@@ -345,7 +345,7 @@ sub ttable_coverage {
# handling hierarchical
$in =~ s/ \[[^ \]]+\]$//; # remove lhs nt
next if $in =~ /\[[^ \]]+\]\[[^ \]]+\]/; # only consider flat rules
- $in = &get_factor_phrase($factor,$in) if defined($factor) && $factor eq "0";
+ $in = &get_factor_phrase($factor,$in) if defined($factor) && $factor eq "0";
$scores = $COLUMN[4] if defined($hierarchical); #scalar @COLUMN == 5;
my @IN = split(/ /,$in);
$size = scalar @IN;
@@ -473,7 +473,7 @@ sub input_annotation {
#$ttable_entropy = 0 unless defined($ttable_entropy);
$ttable_covered = 0 unless defined($ttable_covered);
$corpus_covered = 0 unless defined($corpus_covered);
-
+
if (defined($TTABLE_COVERED{$length}{$phrase})) {
printf OUT "%d-%d:%d:%d:%.5f ",$start,$start+$length-1,$corpus_covered,$ttable_covered,$ttable_entropy;
}
@@ -481,7 +481,7 @@ sub input_annotation {
}
print OUT "\n";
}
- close(INPUT);
+ close(INPUT);
close(OUT);
}
@@ -532,7 +532,7 @@ sub extract_n_grams {
$sentence =~ s/\s+/ /g;
$sentence =~ s/^ //;
$sentence =~ s/ $//;
-
+
my @WORD = split(/ /,$sentence);
for(my $length=1;$length<=$MAX_LENGTH;$length++) {
for(my $i=0;$i<=scalar(@WORD)-$length;$i++) {
@@ -604,8 +604,8 @@ sub precision_by_coverage {
defined($REF_NGRAM{1}{$ngram})) {
my $ref_count = $REF_NGRAM{1}{$ngram};
my $sys_count = $SYS_NGRAM{1}{$ngram};
- $PREC_NGRAM{1}{$ngram} =
- ($ref_count >= $sys_count) ? 1 : $ref_count/$sys_count;
+ $PREC_NGRAM{1}{$ngram} =
+ ($ref_count >= $sys_count) ? 1 : $ref_count/$sys_count;
}
}
close(REPORT);
@@ -615,10 +615,10 @@ sub precision_by_coverage {
while($line =~ /([^|]+) \|(\d+)\-(\d+)\|\s*(.*)$/) {
my ($output,$from,$to) = ($1,$2,$3);
$line = $4;
-
+
# bug fix: 1-1 unknown word mappings get alignment point
if ($from == $to && # one
- scalar(split(/ /,$output)) == 1 && # to one
+ scalar(split(/ /,$output)) == 1 && # to one
!defined($ALIGNED{$from})) { # but not aligned
push @{$ALIGNED{$from}},$output_pos;
}
@@ -631,11 +631,11 @@ sub precision_by_coverage {
my ($precision,$deleted,$length) = (0,0,0);
- # unaligned? note as deleted
+ # unaligned? note as deleted
if (!defined($ALIGNED{$i})) {
$deleted = 1;
}
- # aligned
+ # aligned
else {
foreach my $o (@{$ALIGNED{$i}}) {
$precision += $PREC_NGRAM{1}{$OUTPUT[$o]};
@@ -649,12 +649,12 @@ sub precision_by_coverage {
$DELETED_BY_WORD{$word} += $deleted;
$PREC_BY_WORD{$word} += $precision;
$LENGTH_BY_WORD{$word} += $length;
- $TOTAL_BY_WORD{$word}++;
+ $TOTAL_BY_WORD{$word}++;
$DELETED_BY_COVERAGE{$coverage} += $deleted;
$PREC_BY_COVERAGE{$coverage} += $precision;
$LENGTH_BY_COVERAGE{$coverage} += $length;
- $TOTAL_BY_COVERAGE{$coverage}++;
+ $TOTAL_BY_COVERAGE{$coverage}++;
if ($precision_by_coverage_factor) {
$DELETED_BY_FACTOR{$FACTOR[$i]} += $deleted;
@@ -662,9 +662,9 @@ sub precision_by_coverage {
$PREC_BY_FACTOR{$FACTOR[$i]} += $precision;
$PREC_BY_FACTOR_COVERAGE{$FACTOR[$i]}{$coverage} += $precision;
$LENGTH_BY_FACTOR{$FACTOR[$i]} += $length;
- $LENGTH_BY_FACTOR_COVERAGE{$FACTOR[$i]}{$coverage} += $length;
- $TOTAL_BY_FACTOR{$FACTOR[$i]}++;
- $TOTAL_BY_FACTOR_COVERAGE{$FACTOR[$i]}{$coverage}++;
+ $LENGTH_BY_FACTOR_COVERAGE{$FACTOR[$i]}{$coverage} += $length;
+ $TOTAL_BY_FACTOR{$FACTOR[$i]}++;
+ $TOTAL_BY_FACTOR_COVERAGE{$FACTOR[$i]}{$coverage}++;
}
}
}
@@ -853,10 +853,10 @@ sub hs_scan_line {
# process a single sentence for hierarchical segmentation
sub hs_process {
my ($sentence,$DERIVATION,$STATS) = @_;
-
+
my $DROP_RULE = shift @{$DERIVATION}; # get rid of S -> S </s>
my $max = $$DERIVATION[0]{'end'};
-
+
# consolidate glue rules into one rule
my %GLUE_RULE;
$GLUE_RULE{'start'} = 1;
@@ -867,10 +867,10 @@ sub hs_process {
while(1) {
my $RULE = shift @{$DERIVATION};
if (scalar(@{$$RULE{'rule_rhs'}}) == 2 &&
- ($$RULE{'rule_lhs'} eq "S" &&
+ ($$RULE{'rule_lhs'} eq "S" &&
$$RULE{'rule_rhs'}[0] eq "S" &&
$$RULE{'rule_rhs'}[1] eq "X") ||
- ($$RULE{'rule_lhs'} eq "Q" &&
+ ($$RULE{'rule_lhs'} eq "Q" &&
$$RULE{'rule_rhs'}[0] eq "Q")) {
unshift @{$GLUE_RULE{'spans'}},$$RULE{'spans'}[1];
push @{$GLUE_RULE{'rule_rhs'}}, $$RULE{'rule_rhs'}[1];
@@ -883,17 +883,17 @@ sub hs_process {
last;
}
}
- unshift @{$DERIVATION}, \%GLUE_RULE;
+ unshift @{$DERIVATION}, \%GLUE_RULE;
$$STATS{'glue-rule'} += $x;
-
+
# create chart
my %CHART;
foreach my $RULE (@{$DERIVATION}) {
$CHART{$$RULE{'start'}}{$$RULE{'end'}} = $RULE;
}
-
+
# compute depth
- &hs_compute_depth(1,$max,0,\%CHART);
+ &hs_compute_depth(1,$max,0,\%CHART);
my $max_depth = 0;
foreach my $RULE (@{$DERIVATION}) {
next unless defined($$RULE{'depth'}); # better: delete offending rule S -> S <s>
@@ -901,17 +901,17 @@ sub hs_process {
}
&hs_recompute_depth(1,$max,\%CHART,$max_depth);
$$STATS{'depth'} += $max_depth;
-
+
# build matrix of divs
-
+
my @MATRIX;
&hs_create_out_span(1,$max,\%CHART,\@MATRIX);
print OUTPUT_TREE &hs_output_matrix($sentence,\@MATRIX,$max_depth);
-
+
my @MATRIX_IN;
&hs_create_in_span(1,$max,\%CHART,\@MATRIX_IN);
print INPUT_TREE &hs_output_matrix($sentence,\@MATRIX_IN,$max_depth);
-
+
# number rules and get their children
my $id = 0;
foreach my $RULE (@{$DERIVATION}) {
@@ -920,10 +920,10 @@ sub hs_process {
$$RULE{'id'} = $id++;
}
&hs_get_children(1,$max,\%CHART);
-
+
foreach my $RULE (@{$DERIVATION}) {
next unless defined($$RULE{'start_div'}); # better: delete offending rule S -> S <s>
-
+
print NODE $sentence." ";
print NODE $$RULE{'depth'}." ";
print NODE $$RULE{'start_div'}." ".$$RULE{'end_div'}." ";
@@ -963,11 +963,11 @@ sub hs_output_matrix {
$class = "]";
}
elsif ($OPEN[$d]) {
- $class = "-";
+ $class = "-";
}
$out .= $class;
}
- $out .= "\t";
+ $out .= "\t";
$out .= $$SPAN{'lhs'} if defined($$SPAN{'lhs'});
$out .= "\t";
$out .= $$SPAN{'rhs'} if defined($$SPAN{'rhs'});
@@ -984,9 +984,9 @@ sub hs_output_matrix {
sub hs_rule_type {
my ($RULE) = @_;
-
+
my $type = "";
-
+
# output side
my %NT;
my $total_word_count = 0;
@@ -998,7 +998,7 @@ sub hs_rule_type {
$word_count = 0;
my $nt = chr(97+$nt_count++);
$NT{$$RULE{'alignment'}{$i}} = $nt;
- $type .= $nt;
+ $type .= $nt;
}
else {
$word_count++;
@@ -1006,9 +1006,9 @@ sub hs_rule_type {
}
}
$type .= $word_count if $word_count > 0;
-
+
$type .= ":".$total_word_count.":".$nt_count.":";
-
+
# input side
$word_count = 0;
$total_word_count = 0;
@@ -1039,7 +1039,7 @@ sub hs_compute_depth {
my $RULE = $$CHART{$start}{$end};
$$RULE{'depth'} = $depth;
-
+
for(my $i=0;$i<scalar @{$$RULE{'rule_rhs'}};$i++) {
# non-terminals
if (defined($$RULE{'alignment'}{$i})) {
@@ -1057,7 +1057,7 @@ sub hs_recompute_depth {
return 0;
}
my $RULE = $$CHART{$start}{$end};
-
+
my $min_sub_depth = $max_depth+1;
for(my $i=0;$i<scalar @{$$RULE{'rule_rhs'}};$i++) {
# non-terminals
@@ -1079,10 +1079,10 @@ sub hs_get_children {
return -1;
}
my $RULE = $$CHART{$start}{$end};
-
+
my @CHILDREN = ();
$$RULE{'children'} = \@CHILDREN;
-
+
for(my $i=0;$i<scalar @{$$RULE{'rule_rhs'}};$i++) {
# non-terminals
if (defined($$RULE{'alignment'}{$i})) {
@@ -1091,7 +1091,7 @@ sub hs_get_children {
push @CHILDREN, $child unless $child == -1;
}
}
- return $$RULE{'id'};
+ return $$RULE{'id'};
}
# create the span annotation for an output sentence
@@ -1102,7 +1102,7 @@ sub hs_create_out_span {
return;
}
my $RULE = $$CHART{$start}{$end};
-
+
my %SPAN;
$SPAN{'start'} = $start;
$SPAN{'end'} = $end;
@@ -1130,7 +1130,7 @@ sub hs_create_out_span {
$SPAN{'end'} = $end;
$SPAN{'depth'} = $$RULE{'depth'};
push @{$MATRIX},\%SPAN;
- $THIS_SPAN = \%SPAN;
+ $THIS_SPAN = \%SPAN;
}
$$THIS_SPAN{'rhs'} .= " " if defined($$THIS_SPAN{'rhs'});
$$THIS_SPAN{'rhs'} .= $$RULE{"rule_rhs"}[$i];
@@ -1150,7 +1150,7 @@ sub hs_create_in_span {
return;
}
my $RULE = $$CHART{$start}{$end};
-
+
my %SPAN;
$SPAN{'start'} = $start;
$SPAN{'end'} = $end;
@@ -1160,7 +1160,7 @@ sub hs_create_in_span {
push @{$MATRIX},\%SPAN;
$$RULE{'start_div_in'} = $#{$MATRIX};
my $THIS_SPAN = \%SPAN;
-
+
my $terminal = 1;
# in input order ...
for(my $i=0;$i<scalar(@{$$RULE{'spans'}});$i++) {
@@ -1177,7 +1177,7 @@ sub hs_create_in_span {
$SPAN{'end'} = $end;
$SPAN{'depth'} = $$RULE{'depth'};
push @{$MATRIX},\%SPAN;
- $THIS_SPAN = \%SPAN;
+ $THIS_SPAN = \%SPAN;
}
$$THIS_SPAN{'rhs'} .= " " if defined($$THIS_SPAN{'rhs'});
$$THIS_SPAN{'rhs'} .= $$SUBSPAN{'word'};
@@ -1204,7 +1204,7 @@ sub process_search_graph {
$heuristic_rule_score = $rule_score; # hmmmm....
}
else {
- die("ERROR: buggy search graph line: $_");
+ die("ERROR: buggy search graph line: $_");
}
chop($alignment) if $alignment;
chop($children) if $children;
diff --git a/scripts/ems/support/berkeley-process.sh b/scripts/ems/support/berkeley-process.sh
index 42b8ba9c3..e68056c96 100755
--- a/scripts/ems/support/berkeley-process.sh
+++ b/scripts/ems/support/berkeley-process.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-if [ $# -lt 8 ]
+if [ $# -lt 8 ]
then
echo "Usage: $0 <\"java options\"> <berkeleyaligner jar file> <input file stem> <previous berkeley param dir> <output directory> <source lang> <target lang> <alignment name (i.e. 'berk' or 'low-posterior')> <posterior threshold> [aligner options...]"
exit 1
@@ -23,7 +23,7 @@ shift
shift
shift
shift
-shift
+shift
JAVA_CMD="/usr/local/share/java/bin/java $JAVA_OPTS -jar $JAR -Data.trainSources $INFILE.list -Main.loadParamsDir $PARAMDIR -exec.execDir $OUTNAME -Main.loadLexicalModelOnly false -Data.englishSuffix $SLANG -Data.foreignSuffix $TLANG -exec.create true -Main.saveParams false -Main.alignTraining true -Main.forwardModels HMM -Main.reverseModels HMM -Main.mode JOINT -Main.iters 0 -Data.testSources -EMWordAligner.posteriorDecodingThreshold $POSTERIOR $@"
echo "Running $JAVA_CMD"
@@ -37,8 +37,8 @@ gzip $OUTNAME/training.$TLANG-$SLANG.A3
#now shift the output
perl -e "
-use strict;
-while (<STDIN>) {
+use strict;
+while (<STDIN>) {
chomp();
my @pairs = split(\" \");
for (my \$i=0;\$i<scalar(@pairs);\$i++) {
diff --git a/scripts/ems/support/berkeley-train.sh b/scripts/ems/support/berkeley-train.sh
index 57d2963fc..96f6b648c 100755
--- a/scripts/ems/support/berkeley-train.sh
+++ b/scripts/ems/support/berkeley-train.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-if [ $# -lt 6 ]
+if [ $# -lt 6 ]
then
echo "Usage: $0 <\"java options\"> <berkeleyaligner jar file> <input file stem> <output directory> <source lang> <target lang> [aligner options...]"
exit 1
@@ -20,4 +20,4 @@ shift
shift
echo $INFILE > $INFILE.list
-/usr/local/share/java/bin/java $JAVA_OPTS -jar $JAR -Data.trainSources $INFILE.list -exec.execDir $OUTDIR -Data.englishSuffix $SLANG -Data.foreignSuffix $TLANG -exec.create true -Main.SaveParams true -Main.alignTraining false -Data.testSources $@
+/usr/local/share/java/bin/java $JAVA_OPTS -jar $JAR -Data.trainSources $INFILE.list -exec.execDir $OUTDIR -Data.englishSuffix $SLANG -Data.foreignSuffix $TLANG -exec.create true -Main.SaveParams true -Main.alignTraining false -Data.testSources $@
diff --git a/scripts/ems/support/build-domain-file-from-subcorpora.perl b/scripts/ems/support/build-domain-file-from-subcorpora.perl
index f166c8927..085fd2629 100755
--- a/scripts/ems/support/build-domain-file-from-subcorpora.perl
+++ b/scripts/ems/support/build-domain-file-from-subcorpora.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -7,7 +7,7 @@ use strict;
# (helper for domain adatpation)
# Creates a file with domain names and end line numbers for different domains
-# within the cleaned training corpus. This file is used by various domain
+# within the cleaned training corpus. This file is used by various domain
# adaptation methods.
my ($extension,@SUBCORPORA) = @ARGV;
diff --git a/scripts/ems/support/build-sparse-features.perl b/scripts/ems/support/build-sparse-features.perl
index 3f4b505d5..79fc1e394 100755
--- a/scripts/ems/support/build-sparse-features.perl
+++ b/scripts/ems/support/build-sparse-features.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -18,7 +18,7 @@ foreach my $feature_spec (split(/,\s*/,$specification)) {
my @SPEC = split(/\s+/,$feature_spec);
my $factor = ($SPEC[0] eq 'word-translation') ? "0-0" : "0";
- $factor = $1 if $feature_spec =~ / factor ([\d\-]+)/;
+ $factor = $1 if $feature_spec =~ / factor ([\d\-]+)/;
$feature_spec =~ s/ factor ([\d\-]+)//;
if ($SPEC[0] eq 'target-word-insertion') {
@@ -107,7 +107,7 @@ sub create_top_words {
open(TOP,">$file");
for(my $i=0; $i<$count && $i<scalar(@SORTED); $i++) {
$SORTED[$i] =~ /^\d+ (.+)$/;
- print TOP "$1\n";
+ print TOP "$1\n";
}
close(TOP);
diff --git a/scripts/ems/support/consolidate-training-data.perl b/scripts/ems/support/consolidate-training-data.perl
index 170ba999c..4ab7f82cf 100755
--- a/scripts/ems/support/consolidate-training-data.perl
+++ b/scripts/ems/support/consolidate-training-data.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
# $Id: consolidate-training-data.perl 928 2009-09-02 02:58:01Z philipp $
diff --git a/scripts/ems/support/fast-align-in-parts.perl b/scripts/ems/support/fast-align-in-parts.perl
index fa501b454..f777d7e52 100755
--- a/scripts/ems/support/fast-align-in-parts.perl
+++ b/scripts/ems/support/fast-align-in-parts.perl
@@ -24,7 +24,7 @@ die("ERROR - usage: fast-align-in-parts.perl -bin FAST_ALIGN_BIN -i PARALLEL_COR
&& $MAX_LINES > 0;
die("ERROR - input file does not exist: $IN") unless -e $IN;
die("ERROR - fast_align binary does not exist: $BIN") unless -e $BIN;
-
+
chomp(my $line_count = `cat $IN | wc -l`);
# not more than maximal number of lines -> just run it regulary
diff --git a/scripts/ems/support/generic-multicore-parallelizer.perl b/scripts/ems/support/generic-multicore-parallelizer.perl
index e5a12adce..0f7910603 100755
--- a/scripts/ems/support/generic-multicore-parallelizer.perl
+++ b/scripts/ems/support/generic-multicore-parallelizer.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -6,7 +6,7 @@ use strict;
my $cores = 8;
my $serial = 1;
my ($infile,$outfile,$cmd,$tmpdir);
-my $parent = $$;
+my $parent = $$;
use Getopt::Long qw(:config pass_through no_ignore_case);
GetOptions('cores=i' => \$cores,
@@ -27,7 +27,7 @@ die("ERROR: you need to specify a tempdir with -tmpdir") unless $tmpdir;
# create split input files
my $sentenceN = `cat $infile | wc -l`;
-my $splitN = int(($sentenceN+($cores*$serial)-0.5) / ($cores*$serial));
+my $splitN = int(($sentenceN+($cores*$serial)-0.5) / ($cores*$serial));
print STDERR "split -a 3 -l $splitN $infile $tmpdir/in-$parent-\n";
`split -a 4 -l $splitN $infile $tmpdir/in-$parent-`;
diff --git a/scripts/ems/support/generic-parallelizer.perl b/scripts/ems/support/generic-parallelizer.perl
index fd7fb2552..811a99bde 100755
--- a/scripts/ems/support/generic-parallelizer.perl
+++ b/scripts/ems/support/generic-parallelizer.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -25,7 +25,7 @@ $qflags = "" unless $qflags;
# create split input files
my $sentenceN = `cat $infile | wc -l`;
-my $splitN = int(($sentenceN+$jobs-0.5) / $jobs);
+my $splitN = int(($sentenceN+$jobs-0.5) / $jobs);
`split -a 2 -l $splitN $infile $tmpdir/in-$$-`;
# find out the names of the jobs
@@ -56,7 +56,7 @@ foreach my $job (@JOB){
# get qsub ID
my @QSUB_ID;
-foreach my $job (@JOB){
+foreach my $job (@JOB){
`cat $tmpdir/job-$$-$job.log` =~ /Your job (\d+) /
or die "ERROR: Can't read log of job $tmpdir/job-$$-$job.log";
push @QSUB_ID,$1;
diff --git a/scripts/ems/support/input-from-sgm.perl b/scripts/ems/support/input-from-sgm.perl
index 223996676..18000581a 100755
--- a/scripts/ems/support/input-from-sgm.perl
+++ b/scripts/ems/support/input-from-sgm.perl
@@ -1,9 +1,9 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
-die("ERROR syntax: input-from-sgm.perl < in.sgm > in.txt")
+die("ERROR syntax: input-from-sgm.perl < in.sgm > in.txt")
unless scalar @ARGV == 0;
while(my $line = <STDIN>) {
@@ -17,7 +17,7 @@ while(my $line = <STDIN>) {
$line !~ /<seg[^>]+>\s*(.*)\s*<\/seg>/i) {
my $next_line = <STDIN>;
$line .= $next_line;
- chop($line);
+ chop($line);
}
if ($line =~ /<seg[^>]+>\s*(.*)\s*<\/seg>/i) {
my $input = $1;
diff --git a/scripts/ems/support/interpolate-lm.perl b/scripts/ems/support/interpolate-lm.perl
index a2fe62b22..7d52fd877 100755
--- a/scripts/ems/support/interpolate-lm.perl
+++ b/scripts/ems/support/interpolate-lm.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -28,8 +28,8 @@ die("interpolate-lm.perl --tuning set --name out-lm --lm lm0,lm1,lm2,lm3 [--sril
# check and set default to unset parameters
die("ERROR: please specify output language model name --name") unless defined($NAME);
-die("ERROR: please specify tuning set with --tuning") unless defined($TUNING);
-die("ERROR: please specify language models with --lm") unless defined($LM);
+die("ERROR: please specify tuning set with --tuning") unless defined($TUNING);
+die("ERROR: please specify language models with --lm") unless defined($LM);
die("ERROR: can't read $TUNING") unless -e $TUNING;
die("ERROR: did not find srilm dir") unless -e $SRILM;
die("ERROR: cannot run ngram") unless -x $SRILM."/ngram";
@@ -152,7 +152,7 @@ sub interpolate {
$mix =~ /best lambda \(([\d\. e-]+)\)/ || die("ERROR: computing lambdas failed: $mix");
@LAMBDA = split(/ /,$1);
}
-
+
# create new language model
print STDERR "creating new language model...\n";
my $i = 0;
@@ -196,7 +196,7 @@ sub saferun3 {
print STDERR "Executing: @_\n";
my $wtr = gensym();
my $rdr = gensym();
- my $err = gensym();
+ my $err = gensym();
my $pid = open3($wtr, $rdr, $err, @_);
close($wtr);
my $gotout = "";
diff --git a/scripts/ems/support/lmplz-wrapper.perl b/scripts/ems/support/lmplz-wrapper.perl
index f36d2d9e0..df503754f 100755
--- a/scripts/ems/support/lmplz-wrapper.perl
+++ b/scripts/ems/support/lmplz-wrapper.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/mml-filter.perl b/scripts/ems/support/mml-filter.perl
index c50725aae..51bc4cda5 100755
--- a/scripts/ems/support/mml-filter.perl
+++ b/scripts/ems/support/mml-filter.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/mml-score.perl b/scripts/ems/support/mml-score.perl
index 449d6a05c..6f7b724ea 100755
--- a/scripts/ems/support/mml-score.perl
+++ b/scripts/ems/support/mml-score.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/mml-train.perl b/scripts/ems/support/mml-train.perl
index 1f0548082..dcc998711 100755
--- a/scripts/ems/support/mml-train.perl
+++ b/scripts/ems/support/mml-train.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/prepare-fast-align.perl b/scripts/ems/support/prepare-fast-align.perl
index 54c124af0..80fec36b2 100755
--- a/scripts/ems/support/prepare-fast-align.perl
+++ b/scripts/ems/support/prepare-fast-align.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/reference-from-sgm.perl b/scripts/ems/support/reference-from-sgm.perl
index 595226bf1..ebb9ae4ae 100755
--- a/scripts/ems/support/reference-from-sgm.perl
+++ b/scripts/ems/support/reference-from-sgm.perl
@@ -1,9 +1,9 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
-die("ERROR syntax: reference-from-sgm.perl ref src out")
+die("ERROR syntax: reference-from-sgm.perl ref src out")
unless scalar @ARGV == 3;
my ($ref,$src,$txt) = @ARGV;
diff --git a/scripts/ems/support/remove-segmentation-markup.perl b/scripts/ems/support/remove-segmentation-markup.perl
index d6333f813..a0bd61fff 100755
--- a/scripts/ems/support/remove-segmentation-markup.perl
+++ b/scripts/ems/support/remove-segmentation-markup.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -6,7 +6,7 @@ use strict;
$|++;
while(<STDIN>) {
- s/ \|\d+\-\d+\| / /g;
- s/ \|\d+\-\d+\|$//;
+ s/ \|\d+\-\d+\| / /g;
+ s/ \|\d+\-\d+\|$//;
print $_;
}
diff --git a/scripts/ems/support/report-experiment-scores.perl b/scripts/ems/support/report-experiment-scores.perl
index ef64d4c2d..b649951ce 100755
--- a/scripts/ems/support/report-experiment-scores.perl
+++ b/scripts/ems/support/report-experiment-scores.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
# $Id: report-experiment-scores.perl 407 2008-11-10 14:43:31Z philipp $
diff --git a/scripts/ems/support/run-command-on-multiple-refsets.perl b/scripts/ems/support/run-command-on-multiple-refsets.perl
index c3db3c4dc..1e914b44b 100755
--- a/scripts/ems/support/run-command-on-multiple-refsets.perl
+++ b/scripts/ems/support/run-command-on-multiple-refsets.perl
@@ -1,9 +1,9 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
-die("ERROR: syntax: run-command-on-multiple-refsets.perl cmd in out")
+die("ERROR: syntax: run-command-on-multiple-refsets.perl cmd in out")
unless scalar @ARGV == 3;
my ($cmd,$in,$out) = @ARGV;
diff --git a/scripts/ems/support/run-wade.perl b/scripts/ems/support/run-wade.perl
index 25cda3bb3..175948b98 100755
--- a/scripts/ems/support/run-wade.perl
+++ b/scripts/ems/support/run-wade.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/split-sentences.perl b/scripts/ems/support/split-sentences.perl
index f1af451b3..02a1e2315 100755
--- a/scripts/ems/support/split-sentences.perl
+++ b/scripts/ems/support/split-sentences.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
# Based on Preprocessor written by Philipp Koehn
@@ -97,21 +97,21 @@ sub preprocess {
$text =~ s/ \n/\n/g;
$text =~ s/^ //g;
$text =~ s/ $//g;
-
+
#####add sentence breaks as needed#####
-
+
#non-period end of sentence markers (?!) followed by sentence starters.
$text =~ s/([?!]) +([\'\"\(\[\¿\¡\p{IsPi}]*[\p{IsUpper}])/$1\n$2/g;
-
+
#multi-dots followed by sentence starters
$text =~ s/(\.[\.]+) +([\'\"\(\[\¿\¡\p{IsPi}]*[\p{IsUpper}])/$1\n$2/g;
-
+
# add breaks for sentences that end with some sort of punctuation inside a quote or parenthetical and are followed by a possible sentence starter punctuation and upper case
$text =~ s/([?!\.][\ ]*[\'\"\)\]\p{IsPf}]+) +([\'\"\(\[\¿\¡\p{IsPi}]*[\ ]*[\p{IsUpper}])/$1\n$2/g;
-
+
# add breaks for sentences that end with some sort of punctuation are followed by a sentence starter punctuation and upper case
$text =~ s/([?!\.]) +([\'\"\(\[\¿\¡\p{IsPi}]+[\ ]*[\p{IsUpper}])/$1\n$2/g;
-
+
# special punctuation cases are covered. Check all remaining periods.
my $word;
my $i;
@@ -125,32 +125,32 @@ sub preprocess {
if($prefix && $NONBREAKING_PREFIX{$prefix} && $NONBREAKING_PREFIX{$prefix} == 1 && !$starting_punct) {
#not breaking;
} elsif ($words[$i] =~ /(\.)[\p{IsUpper}\-]+(\.+)$/) {
- #not breaking - upper case acronym
+ #not breaking - upper case acronym
} elsif($words[$i+1] =~ /^([ ]*[\'\"\(\[\¿\¡\p{IsPi}]*[ ]*[\p{IsUpper}0-9])/) {
#the next word has a bunch of initial quotes, maybe a space, then either upper case or a number
$words[$i] = $words[$i]."\n" unless ($prefix && $NONBREAKING_PREFIX{$prefix} && $NONBREAKING_PREFIX{$prefix} == 2 && !$starting_punct && ($words[$i+1] =~ /^[0-9]+/));
#we always add a return for these unless we have a numeric non-breaker and a number start
}
-
+
}
$text = $text.$words[$i]." ";
}
-
+
#we stopped one token from the end to allow for easy look-ahead. Append it now.
$text = $text.$words[$i];
-
+
# clean up spaces at head and tail of each line as well as any double-spacing
$text =~ s/ +/ /g;
$text =~ s/\n /\n/g;
$text =~ s/ \n/\n/g;
$text =~ s/^ //g;
$text =~ s/ $//g;
-
+
#add trailing break
$text .= "\n" unless $text =~ /\n$/;
-
+
return $text;
-
+
}
diff --git a/scripts/ems/support/submit-grid.perl b/scripts/ems/support/submit-grid.perl
index 9997241e7..a0967f9a5 100755
--- a/scripts/ems/support/submit-grid.perl
+++ b/scripts/ems/support/submit-grid.perl
@@ -9,7 +9,7 @@ use File::Basename;
my $continue = 0;
-my $args = "";
+my $args = "";
my $config;
GetOptions("continue=i" => \$continue,
diff --git a/scripts/ems/support/substitute-filtered-tables-and-weights.perl b/scripts/ems/support/substitute-filtered-tables-and-weights.perl
index 681d251c7..13be52c6b 100755
--- a/scripts/ems/support/substitute-filtered-tables-and-weights.perl
+++ b/scripts/ems/support/substitute-filtered-tables-and-weights.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/substitute-filtered-tables.perl b/scripts/ems/support/substitute-filtered-tables.perl
index e7d9f55f8..c5ebabded 100755
--- a/scripts/ems/support/substitute-filtered-tables.perl
+++ b/scripts/ems/support/substitute-filtered-tables.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
@@ -45,7 +45,7 @@ while(my $line = <STDIN>) {
elsif ($feature_section && $line =~ /LexicalReordering/) {
print $arr[$ind]."\n";
++$ind;
- }
+ }
else {
print "$line\n";
}
diff --git a/scripts/ems/support/substitute-weights.perl b/scripts/ems/support/substitute-weights.perl
index 42357ed1e..b692f3f85 100755
--- a/scripts/ems/support/substitute-weights.perl
+++ b/scripts/ems/support/substitute-weights.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
@@ -18,7 +18,7 @@ while(my $line = <BASEINI>) {
}
elsif ($line =~ /\[[a-zA-Z0-9\-]*\]/) {
$inWeightSection = 0;
- }
+ }
if (!$inWeightSection) {
print OUT "$line\n" unless $line =~ /dense weights for feature functions/;
@@ -48,7 +48,7 @@ while(my $line = <WEIGHTINI>) {
elsif ($line =~ /\[[a-zA-Z0-9\-]*\]/) {
print OUT "\n" if $inWeightSection;
$inWeightSection = 0;
- }
+ }
if ($inWeightSection && $line !~ /^\s*$/) {
print OUT "$line\n";
diff --git a/scripts/ems/support/symmetrize-fast-align.perl b/scripts/ems/support/symmetrize-fast-align.perl
index 90621dea9..9f7fec248 100755
--- a/scripts/ems/support/symmetrize-fast-align.perl
+++ b/scripts/ems/support/symmetrize-fast-align.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/thot-lm-wrapper.perl b/scripts/ems/support/thot-lm-wrapper.perl
index 222623c5b..59d483e65 100755
--- a/scripts/ems/support/thot-lm-wrapper.perl
+++ b/scripts/ems/support/thot-lm-wrapper.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/tree-converter-wrapper.perl b/scripts/ems/support/tree-converter-wrapper.perl
index a37654cf1..aae55991a 100755
--- a/scripts/ems/support/tree-converter-wrapper.perl
+++ b/scripts/ems/support/tree-converter-wrapper.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
diff --git a/scripts/ems/support/wrap-xml.perl b/scripts/ems/support/wrap-xml.perl
index 28708a62a..52190309a 100755
--- a/scripts/ems/support/wrap-xml.perl
+++ b/scripts/ems/support/wrap-xml.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl
use warnings;
use strict;
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>&nbsp;</td><td>%.1f%s</td><td>%.1f%s</td><td>%.1f%s</td><td>%.1f%s</td></tr>\n",
$info["$type-1-correct"]/$info["$type-1-total"]*100,'%',
$info["$type-2-correct"]/$info["$type-2-total"]*100,'%',
@@ -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>&nbsp;</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>&nbsp;</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]);
}