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 <fishandfrolick@gmail.com>2013-02-16 15:01:23 +0400
committerHieu Hoang <fishandfrolick@gmail.com>2013-02-16 15:01:23 +0400
commit30850bf45f8d103854ebd2e94eea04900ab842db (patch)
tree39d59eb1bb3846726e5244edea526a065f96b4f1 /scripts/ems
parenta9e2be28968fa3a0ea57682be79629adeb507d16 (diff)
new substitute-filtered-tables.perl
Diffstat (limited to 'scripts/ems')
-rwxr-xr-xscripts/ems/support/substitute-filtered-tables.perl54
1 files changed, 23 insertions, 31 deletions
diff --git a/scripts/ems/support/substitute-filtered-tables.perl b/scripts/ems/support/substitute-filtered-tables.perl
index 723c140b0..530130aa8 100755
--- a/scripts/ems/support/substitute-filtered-tables.perl
+++ b/scripts/ems/support/substitute-filtered-tables.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -w
# experiment.perl support script
# get filtered rule and reordering tables and place them into a configuration file
@@ -8,42 +8,34 @@ if (scalar @ARGV < 1 || ! -e $ARGV[0]) {
}
# read config sections about filtered tables
-my %CONFIG;
-my $status = 0;
-my $section;
+my @arr;
open(FILTERED, $ARGV[0]) or die "Cannot open: $!";
-while(<FILTERED>) {
- if (/^\[(.+)\]\s*$/) {
- if ($1 eq "ttable-file" || $1 eq "distortion-file") {
- $section = $1;
- $status = 1;
- print STDERR "found $section\n";
- }
- else {
- $status = 0;
- }
- }
- elsif ($status) {
- $CONFIG{$section} .= $_;
+while(my $line = <FILTERED>) {
+ chomp($line);
+ if ($line =~ /PhraseModel /) {
+ print STDERR "pt:$line \n";
+ push(@arr, $line);
}
+ elsif ($line =~ /LexicalReordering /) {
+ print STDERR "ro:$line \n";
+ push(@arr, $line);
+ }
}
close(FILTERED);
# pass through master config file and replace table sections
-($status,$section) = (0);
-while(<STDIN>) {
- if (/^\[(.+)\]\s*$/) {
- print $_;
- if ($1 eq "ttable-file" || $1 eq "distortion-file") {
- print STDERR "replacing $1\n";
- print $CONFIG{$1};
- $status = 1;
- }
- else {
- $status = 0;
- }
+my $ind = 0;
+while(my $line = <STDIN>) {
+ chomp($line);
+ if ($line =~ /PhraseModel /) {
+ print $arr[$ind]."\n";
+ ++$ind;
}
- elsif (!$status) {
- print $_;
+ elsif ($line =~ /LexicalReordering /) {
+ print $arr[$ind]."\n";
+ ++$ind;
+ }
+ else {
+ print "$line\n";
}
}