mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 06:22:14 +03:00
added substitute-weights.perl
This commit is contained in:
parent
b18ebf2e09
commit
0f2b2acd78
@ -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
|
||||
|
44
scripts/ems/support/substitute-weights.perl
Executable file
44
scripts/ems/support/substitute-weights.perl
Executable 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";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user