allowing to override default paths

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@547 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
bojar 2006-08-07 23:04:33 +00:00
parent d020dbae28
commit ab5bb31797
2 changed files with 34 additions and 3 deletions

View File

@ -4,12 +4,28 @@
# relies on wiseln, a wise variant of linking. You might just use ln -s instead.
use strict;
use Getopt::Long;
my @fixpath = ();
# specify search-replace pattern to fix paths.
# use a space to delimit source and target pathnames
GetOptions(
"fixpath=s" => \@fixpath,
);
my @fixrepls = map {
my ($fixsrc, $fixtgt) = split / /, $_;
print STDERR "Will replace >$fixsrc< with >$fixtgt<\n";
[ $fixsrc, $fixtgt ];
} @fixpath;
my $ini = shift;
die "usage!" if !defined $ini;
my %cnt; # count files per section
open INI, $ini or die "Can't read $ini";
open OUT, ">moses.ini" or die "Can't write ./moses.ini";
my $section = undef;
while (<INI>) {
if (/^\[([^\]]*)\]\s*$/) {
$section = $1;
@ -20,6 +36,7 @@ while (<INI>) {
my ($a, $b, $c, $fn) = split / /;
$cnt{$section}++;
my $suffix = ($fn =~ /\.gz$/ ? ".gz" : "");
$fn = fixpath($fn);
$fn = ensure_relative_to_origin($fn, $ini);
safesystem("wiseln $fn ./$section.$cnt{$section}$suffix") or die;
$_ = "$a $b $c ./$section.$cnt{$section}$suffix\n";
@ -29,7 +46,7 @@ while (<INI>) {
my ($a, $b, $c, $fn) = split / /;
$cnt{$section}++;
my $suffix = ($fn =~ /\.gz$/ ? ".gz" : "");
$fn = ensure_relative_to_origin($fn, $ini);
$fn = fixpath($fn);
safesystem("wiseln $fn ./$section.$cnt{$section}$suffix") or die;
$_ = "$a $b $c ./$section.$cnt{$section}$suffix\n";
}
@ -38,6 +55,7 @@ while (<INI>) {
my $fn = $_;
$cnt{$section}++;
my $suffix = ($fn =~ /\.gz$/ ? ".gz" : "");
$fn = fixpath($fn);
$fn = ensure_relative_to_origin($fn, $ini);
safesystem("wiseln $fn ./$section.$cnt{$section}$suffix") or die;
$_ = "./$section.$cnt{$section}$suffix\n";
@ -48,6 +66,15 @@ while (<INI>) {
close INI;
close OUT;
sub fixpath {
my $fn = shift;
foreach my $pair (@fixrepls) {
$fn =~ s/$pair->[0]/$pair->[1]/g;
}
return $fn;
}
sub safesystem {
print STDERR "Executing: @_\n";
system(@_);

View File

@ -102,6 +102,7 @@ my $pythonpath = undef; # path to python libraries needed by cmert
my $filtercmd = undef; # path to filter-model-given-input.pl
my $SCORENBESTCMD = undef;
my $qsubwrapper = undef;
my $moses_parallel_cmd = undef;
use strict;
@ -130,6 +131,7 @@ GetOptions(
"filtercmd=s" => \$filtercmd, # allow to override the default location
"scorenbestcmd=s" => \$SCORENBESTCMD, # path to score-nbest.py
"qsubwrapper=s" => \$qsubwrapper, # allow to override the default location
"mosesparallelcmd=s" => \$moses_parallel_cmd, # allow to override the default location
) or exit(1);
# the 4 required parameters can be supplied on the command line directly
@ -150,7 +152,8 @@ if ($usage || !defined $___DEV_F || !defined$___DEV_E || !defined$___DECODER ||
Options:
--working-dir=mert-dir ... where all the files are created
--nbest=100 ... how big nbestlist to generate
--jobs=N ... optional path to moses-parallel.perl
--jobs=N ... set this to anything to run moses in parallel
--mosesparallelcmd=STRING ... use a different script instead of moses-parallel
--queue-flags=STRING ... anything you with to pass to
qsub, eg. '-l ws06osssmt=true'
The default is to submit the jobs to the ws06ossmt queue, which
@ -196,7 +199,8 @@ $filtercmd="$SCRIPTS_ROOTDIR/training/filter-model-given-input.pl" if !defined $
$qsubwrapper="$SCRIPTS_ROOTDIR/generic/qsub-wrapper.pl" if !defined $qsubwrapper;
my $moses_parallel_cmd = "$SCRIPTS_ROOTDIR/generic/moses-parallel.pl";
$moses_parallel_cmd = "$SCRIPTS_ROOTDIR/generic/moses-parallel.pl"
if !defined $moses_parallel_cmd;
$cmertdir = "$SCRIPTS_ROOTDIR/training/cmert-0.5" if !defined $cmertdir;
my $cmertcmd="$cmertdir/mert";