regression test for score

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4112 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2011-08-04 09:15:43 +00:00
parent e988361d62
commit fc176801d6
2 changed files with 28 additions and 7 deletions

View File

@ -13,19 +13,28 @@ my $data_dir;
my $test_dir;
my $results_dir;
GetOptions("decoder=s" => \$scoreExe,
GetOptions("scorer=s" => \$scoreExe,
"test=s" => \$test_name,
"data-dir=s"=> \$data_dir,
"test-dir=s"=> \$test_dir,
"results-dir=s"=> \$results_dir,
) or exit 1;
my $outPath = "$test_dir/phrase-table.4.half.f2e";
my $cmdMain = "$scoreExe $test_dir/extract.sorted $test_dir/lex.f2e $outPath --GoodTuring \n";
# output dir
unless (defined $results_dir)
{
my $ts = get_timestamp($scoreExe);
$results_dir = "$data_dir/results/$test_name/$ts";
}
`mkdir -p $results_dir`;
my $outPath = "$results_dir/phrase-table.4.half.f2e";
my $cmdMain = "$scoreExe $test_dir/$test_name/extract.sorted $test_dir/$test_name/lex.f2e $outPath --GoodTuring \n";
`$cmdMain`;
my $truthPath = "$test_dir/truth/results.txt";
my $truthPath = "$test_dir/$test_name/truth/results.txt";
my $cmd = "diff $outPath $truthPath | wc -l";
my $numDiff = 554;
@ -41,3 +50,16 @@ else
print STDERR "FAILURE. Ran $cmdMain\n";
exit 1;
}
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";
}

View File

@ -86,22 +86,21 @@ foreach my $test (@tests)
if ($model_type eq 'phrase')
{
$cmd .= "$BIN_TEST/run-single-test.perl $test_run --decoder=$decoderPhrase";
$cmd .= " --test=$test";
}
elsif ($model_type eq 'chart.')
{
$cmd .= "$BIN_TEST/run-single-test.perl $test_run --decoder=$decoderChart";
$cmd .= " --test=$test";
}
elsif ($model_type eq 'score.')
{
$cmd = "$Bin/run-test-scorer.perl $scoreExe $Bin/tests/$test";
$cmd .= "$Bin/run-test-scorer.perl $test_run --scorer=$scoreExe";
}
else
{
print "FAIL";
}
$cmd .= " --test=$test";
print STDERR "cmd = $cmd\n";