avoid name collisions when filtering multiple reordering tables

This commit is contained in:
Jonathan Chen 2016-05-17 12:00:54 -05:00
parent 5b42fb9c05
commit e2c596415d

View File

@ -224,6 +224,7 @@ while(my $line = <INI>) {
elsif ($line =~ /LexicalReordering /) {
print STDERR "ro:$line\n";
my ($source_factor, $t, $w, $file); # = ($1,$2,$3,$4);
my $dest_factor;
for (my $i = 1; $i < scalar(@toks); ++$i) {
my @args = split(/=/, $toks[$i]);
@ -238,6 +239,7 @@ while(my $line = <INI>) {
}
elsif ($args[0] eq "output-factor") {
#$t = chomp($args[1]);
$dest_factor = $args[1];
}
elsif ($args[0] eq "type") {
$t = $args[1];
@ -255,6 +257,13 @@ while(my $line = <INI>) {
my $new_name = "$dir/$file";
$new_name =~ s/\.gz//;
# avoid name collisions for multiple reordering tables; using phrase-table numbering scheme (except for TABLE_NUMBER)
$new_name .= ".$source_factor-$dest_factor";
my $cnt = 1;
$cnt ++ while (defined $new_name_used{"$new_name.$cnt"});
$new_name .= ".$cnt";
$new_name_used{$new_name} = 1;
#print INI_OUT "$source_factor $t $w $new_name\n";
@toks = set_value(\@toks, "path", "$new_name");
print INI_OUT join_array(\@toks)."\n";