From 0f2b2acd7896fa4f41f91802644c28981d27847f Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Wed, 6 Mar 2013 19:34:48 +0000 Subject: [PATCH] added substitute-weights.perl --- scripts/ems/experiment.meta | 2 +- scripts/ems/support/substitute-weights.perl | 44 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 scripts/ems/support/substitute-weights.perl 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 = ) { + 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 = ) { + chomp($line); + if ($line =~ /\[weight\]/) { + $inWeightSection = 1; + } + elsif ($line =~ /\[[a-zA-Z0-0]*\]/) { + $inWeightSection = 0; + } + + if ($inWeightSection) { + print "$line\n"; + } +}