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:
authorHieu Hoang <hieuhoang@gmail.com>2013-03-06 23:34:48 +0400
committerHieu Hoang <hieuhoang@gmail.com>2013-03-06 23:34:48 +0400
commit0f2b2acd7896fa4f41f91802644c28981d27847f (patch)
treef4a063bae985071d1c3129b951464d7faf32328d /scripts/ems
parentb18ebf2e090f4efb9e8705a1ea47c4bf1698cacc (diff)
added substitute-weights.perl
Diffstat (limited to 'scripts/ems')
-rw-r--r--scripts/ems/experiment.meta2
-rwxr-xr-xscripts/ems/support/substitute-weights.perl44
2 files changed, 45 insertions, 1 deletions
diff --git a/scripts/ems/experiment.meta b/scripts/ems/experiment.meta
index 2a32d4e2b..dcd429825 100644
--- a/scripts/ems/experiment.meta
+++ b/scripts/ems/experiment.meta
@@ -932,7 +932,7 @@ apply-filter
default-name: evaluation/filtered.ini
pass-if: TRAINING:binarize-all
ignore-if: use-hiero
- template: $moses-script-dir/ems/support/substitute-filtered-tables.perl IN1/moses.ini < IN > OUT
+ template: $moses-script-dir/ems/support/substitute-weights.perl IN1/moses.ini < IN > OUT
decode
in: filtered-config input
out: system-output
diff --git a/scripts/ems/support/substitute-weights.perl b/scripts/ems/support/substitute-weights.perl
new file mode 100755
index 000000000..8c52a73bf
--- /dev/null
+++ b/scripts/ems/support/substitute-weights.perl
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+
+# experiment.perl support script
+# get filtered rule and reordering tables and place them into a configuration file
+
+if (scalar @ARGV < 1 || ! -e $ARGV[0]) {
+ die("ERROR: could not find pseudo-config with filtered tables");
+}
+
+# read initial ini file
+my @arr;
+my $inWeightSection = 0;
+open(FILTERED, $ARGV[0]) or die "Cannot open: $!";
+while(my $line = <FILTERED>) {
+ chomp($line);
+ if ($line =~ /\[weight\]/) {
+ $inWeightSection = 1;
+ }
+ elsif ($line =~ /\[[a-zA-Z0-0]*\]/) {
+ $inWeightSection = 0;
+ }
+
+ if (!$inWeightSection) {
+ print "$line\n";
+ }
+}
+close(FILTERED);
+
+# read tuned ini file
+$inWeightSection = 0;
+my $ind = 0;
+while(my $line = <STDIN>) {
+ chomp($line);
+ if ($line =~ /\[weight\]/) {
+ $inWeightSection = 1;
+ }
+ elsif ($line =~ /\[[a-zA-Z0-0]*\]/) {
+ $inWeightSection = 0;
+ }
+
+ if ($inWeightSection) {
+ print "$line\n";
+ }
+}