added substitute-weights.perl

This commit is contained in:
Hieu Hoang 2013-03-06 19:34:48 +00:00
parent b18ebf2e09
commit 0f2b2acd78
2 changed files with 45 additions and 1 deletions

View File

@ -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

View File

@ -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";
}
}