mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
lmplz-wrapper.perl: use Getopt::Long's "pass_through" option
This avoids the need to duplicate all of lmplz's options in the wrapper and it prevents --prune 0 0 1 from being truncated to --prune 0 if the user forgets to quote the arguments.
This commit is contained in:
parent
c634f6ee5b
commit
6ce3060dd8
@ -3,25 +3,20 @@
|
||||
use strict;
|
||||
use Getopt::Long "GetOptions";
|
||||
|
||||
my ($TEXT,$ORDER,$PRUNE,$BIN,$LM,$MEMORY,$TMP,$DISCOUNT_FALLBACK);
|
||||
Getopt::Long::config("pass_through");
|
||||
|
||||
my ($TEXT,$ORDER,$BIN,$LM);
|
||||
|
||||
&GetOptions('text=s' => \$TEXT,
|
||||
'lm=s' => \$LM,
|
||||
'bin=s' => \$BIN,
|
||||
'prune=s' => \$PRUNE,
|
||||
'discount_fallback' => \$DISCOUNT_FALLBACK,
|
||||
'T=s' => \$TMP,
|
||||
'S=s' => \$MEMORY,
|
||||
'order=i' => \$ORDER);
|
||||
|
||||
die("ERROR: specify at least --text CORPUS --arpa LM and --order N!")
|
||||
unless defined($TEXT) && defined($LM) && defined($ORDER);
|
||||
die("ERROR: specify at least --bin BIN --text CORPUS --lm LM and --order N!")
|
||||
unless defined($BIN) && defined($TEXT) && defined($LM) && defined($ORDER);
|
||||
|
||||
my $cmd = "$BIN --text $TEXT --order $ORDER --arpa $LM";
|
||||
$cmd .= " --prune $PRUNE" if defined($PRUNE);
|
||||
$cmd .= " -S $MEMORY" if defined($MEMORY);
|
||||
$cmd .= " -T $TMP" if defined($TMP);
|
||||
$cmd .= " --discount_fallback" if defined($DISCOUNT_FALLBACK);
|
||||
$cmd .= " " . join(' ', @ARGV) if scalar(@ARGV); # Pass remaining args through.
|
||||
|
||||
print "exec: $cmd\n";
|
||||
`$cmd`;
|
||||
|
Loading…
Reference in New Issue
Block a user