Skip to content

Commit

Permalink
absolute file name check, provided by Eric Kow
Browse files Browse the repository at this point in the history
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1944 1f5c12ca-751b-0410-a591-d2e778427230
  • Loading branch information
hieuhoang1972 committed Nov 20, 2008
1 parent 254284e commit 2807bc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/training/mert-moses.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down Expand Up @@ -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";
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/training/train-factored-phrase-model.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -215,6 +216,8 @@
($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 ];
Expand Down

0 comments on commit 2807bc4

Please sign in to comment.