Two more patches attached (I'm still operating under the assumption
that this is the best place to send them).

These patches add an absolute file name check.  This bit me when I tried
to learn how to use tuning.  The train-factored-model script was
perfectly happy to let me use relative filenames for the language model.
But when I want to do tuning via mert-moses, I got a complaint about the
same filename in my autogenerated moses.ini file being non absolute.

Note that the mert-moses patch is only (presumably) for portability.

Will push to my git repo as well

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
diff --git a/scripts/training/mert-moses.pl b/scripts/training/mert-moses.pl
index e85638c..a4c9925 100755
--- a/scripts/training/mert-moses.pl
+++ b/scripts/training/mert-moses.pl
@@ -38,6 +38,7 @@
 
 use FindBin qw($Bin);
 use File::Basename;
+use File::Spec::Functions;
 my $SCRIPTS_ROOTDIR = $Bin;
 if ($SCRIPTS_ROOTDIR eq '') {
   $SCRIPTS_ROOTDIR = dirname(__FILE__);
@@ -1114,7 +1115,7 @@ sub scan_config {
       if (defined $fn && $fn !~ /^\s+$/) {
 	  print "checking weight-count for $section\n";
         # this is a filename! check it
-	if ($fn !~ /^\//) {
+	if (not file_name_is_absolute $fn) {
 	  $error = 1;
 	  print STDERR "$inishortname:$nr:Filename not absolute: $fn\n";
 	}
diff --git a/scripts/training/train-factored-phrase-model.perl b/scripts/training/train-factored-phrase-model.perl
index e36c2df..b491ff5 100755
--- a/scripts/training/train-factored-phrase-model.perl
+++ b/scripts/training/train-factored-phrase-model.perl
@@ -3,6 +3,7 @@
 use strict;
 use Getopt::Long "GetOptions";
 use FindBin qw($Bin);
+use File::Spec::Functions;
 use File::Basename;
 
 # Train Factored Phrase Model
@@ -215,6 +216,8 @@ if ($___LAST_STEP == 9) {
     ($f, $order, $filename, $type) = split /:/, $lm, 4;
     die "ERROR: Wrong format of --lm. Expected: --lm factor:order:filename"
       if $f !~ /^[0-9]+$/ || $order !~ /^[0-9]+$/ || !defined $filename;
+    die "ERROR: Filename is not absolute: $filename"
+      unless file_name_is_absolute $filename;
     die "ERROR: Language model file not found or empty: $filename"
       if ! -s $filename;
     push @___LM, [ $f, $order, $filename, $type ];

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to