2011-08-04 12:11:40 +04:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use strict;
|
2011-08-22 11:56:46 +04:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use Cwd qw/ abs_path /;
|
|
|
|
use File::Basename;
|
|
|
|
my $script_dir = dirname(abs_path($0));
|
|
|
|
print STDERR "script_dir=$script_dir\n";
|
|
|
|
push @INC, $script_dir;
|
|
|
|
}
|
|
|
|
|
2011-08-04 12:11:40 +04:00
|
|
|
use FindBin qw($Bin);
|
|
|
|
use MosesRegressionTesting;
|
|
|
|
use Getopt::Long;
|
|
|
|
use File::Temp qw ( tempfile );
|
|
|
|
use POSIX qw ( strftime );
|
|
|
|
|
|
|
|
my $scoreExe;
|
|
|
|
my $test_name;
|
|
|
|
my $data_dir;
|
|
|
|
my $test_dir;
|
|
|
|
my $results_dir;
|
|
|
|
|
2011-08-04 13:15:43 +04:00
|
|
|
GetOptions("scorer=s" => \$scoreExe,
|
2011-08-04 12:11:40 +04:00
|
|
|
"test=s" => \$test_name,
|
|
|
|
"data-dir=s"=> \$data_dir,
|
|
|
|
"test-dir=s"=> \$test_dir,
|
|
|
|
"results-dir=s"=> \$results_dir,
|
|
|
|
) or exit 1;
|
|
|
|
|
2011-08-04 13:15:43 +04:00
|
|
|
# output dir
|
|
|
|
unless (defined $results_dir)
|
|
|
|
{
|
|
|
|
my $ts = get_timestamp($scoreExe);
|
|
|
|
$results_dir = "$data_dir/results/$test_name/$ts";
|
|
|
|
}
|
|
|
|
|
|
|
|
`mkdir -p $results_dir`;
|
|
|
|
|
2011-08-05 13:23:48 +04:00
|
|
|
my $outPath = "$results_dir/pt.half";
|
2011-08-05 06:48:30 +04:00
|
|
|
|
2011-08-05 13:23:48 +04:00
|
|
|
my $scorerArgs = `cat $test_dir/$test_name/args.txt`;
|
|
|
|
$_ = $scorerArgs;
|
|
|
|
s/(\$\w+)/$1/eeg;
|
|
|
|
$scorerArgs = $_;
|
2011-08-04 12:11:40 +04:00
|
|
|
|
2011-08-05 13:23:48 +04:00
|
|
|
my $cmdMain = "$scoreExe $scorerArgs \n";
|
2011-08-04 12:11:40 +04:00
|
|
|
`$cmdMain`;
|
|
|
|
|
2011-08-04 13:15:43 +04:00
|
|
|
my $truthPath = "$test_dir/$test_name/truth/results.txt";
|
2011-08-04 12:11:40 +04:00
|
|
|
|
|
|
|
|
2011-08-05 13:23:48 +04:00
|
|
|
if (-e $outPath)
|
2011-08-04 12:11:40 +04:00
|
|
|
{
|
2011-08-05 13:23:48 +04:00
|
|
|
my $cmd = "diff $outPath $truthPath | wc -l";
|
|
|
|
|
|
|
|
my $numDiff = `$cmd`;
|
|
|
|
|
|
|
|
if ($numDiff == 0)
|
|
|
|
{
|
|
|
|
# print STDERR "FAILURE. Ran $cmdMain\n";
|
|
|
|
print STDERR "SUCCESS\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print STDERR "FAILURE. Ran $cmdMain\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
2011-08-04 12:11:40 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-05 13:23:48 +04:00
|
|
|
print STDERR "FAILURE. Output does not exists. Ran $cmdMain\n";
|
2011-08-04 12:11:40 +04:00
|
|
|
exit 1;
|
|
|
|
}
|
2011-08-04 13:15:43 +04:00
|
|
|
|
2011-08-05 13:23:48 +04:00
|
|
|
###################################
|
2011-08-04 13:15:43 +04:00
|
|
|
sub get_timestamp {
|
|
|
|
my ($file) = @_;
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks)
|
|
|
|
= stat($file);
|
|
|
|
my $timestamp = strftime("%Y%m%d-%H%M%S", gmtime $mtime);
|
|
|
|
my $timestamp2 = strftime("%Y%m%d-%H%M%S", gmtime);
|
|
|
|
my $username = `whoami`; chomp $username;
|
|
|
|
return "moses.v$timestamp-$username-at-$timestamp2";
|
|
|
|
}
|
|
|
|
|
|
|
|
|