Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-08 19:54:30 +0400
committerredpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230>2006-08-08 19:54:30 +0400
commite9fd44ef132674335d88f627504431a5e98bac34 (patch)
tree5e665c350f1551c965a7003fb38eea28dd1f54bd /regression-testing/MosesRegressionTesting.pm
parent264f045a6bff3e7004e5860d997c36fc86d55662 (diff)
check in regression tests to CVS
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@557 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'regression-testing/MosesRegressionTesting.pm')
-rw-r--r--regression-testing/MosesRegressionTesting.pm75
1 files changed, 75 insertions, 0 deletions
diff --git a/regression-testing/MosesRegressionTesting.pm b/regression-testing/MosesRegressionTesting.pm
new file mode 100644
index 000000000..c332a3dcc
--- /dev/null
+++ b/regression-testing/MosesRegressionTesting.pm
@@ -0,0 +1,75 @@
+package MosesRegressionTesting;
+
+use strict;
+
+# if your tests need a new version of the test data, increment this
+# and make sure that a moses-regression-tests-vX.Y is available for
+# download from statmt.org (redpony AT umd dot edu for more info)
+use constant TESTING_DATA_VERSION => '0.1';
+
+# find the data directory in a few likely locations and make sure
+# that it is the correct version
+sub find_data_directory
+{
+ my ($test_script_root, $data_dir) = @_;
+ my $data_version = TESTING_DATA_VERSION;
+ my @ds = ();
+ my $mrtp = "moses-reg-test-data-$data_version";
+ push @ds, $data_dir if defined $data_dir;
+ push @ds, "$test_script_root/$mrtp";
+ push @ds, "/export/ws06osmt/regression-testing/$mrtp";
+ push @ds, "/tmp/$mrtp";
+ push @ds, "/var/tmp/$mrtp";
+ foreach my $d (@ds) {
+ next unless (-d $d);
+ if (!-d "$d/models") {
+ print STDERR "Found $d but it is malformed: missing subdir models/\n";
+ next;
+ }
+ if (!-d "$d/lm") {
+ print STDERR "Found $d but it is malformed: missing subdir lm/\n";
+ next;
+ }
+ return $d;
+ }
+ print STDERR<<EOT;
+
+You do not appear to have the regression testing data installed. You may
+either specify a non-standard location when running the test suite with
+the --data-dir option, or, you may install it in any one of the following
+standard locations: $test_script_root, /tmp, or /var/tmp with these
+commands:
+
+ cd <DESIRED_INSTALLATION_DIRECTORY>
+ wget http://www.statmt.org/moses/reg-testing/moses-regression-tests-v$data_version.tar
+ tar xf moses-regression-tests-v$data_version.tar
+ rm moses-regression-tests-v$data_version.tar
+
+EOT
+ exit 1;
+}
+
+
+sub get_localized_moses_ini
+{
+ use File::Temp;
+ my ($moses_ini, $data_dir) = @_;
+ my $LM_PATH = "$data_dir/lm";
+ my $MODEL_PATH = "$data_dir/models";
+ my $local_moses_ini = new File::Temp( UNLINK => 0, SUFFIX => '.ini' );
+
+ open MI, "<$moses_ini" or die "Couldn't read $moses_ini";
+ open MO, ">$local_moses_ini" or die "Couldn't open $local_moses_ini for writing";
+ while (my $l = <MI>) {
+ $l =~ s/\$\{LM_PATH\}/$LM_PATH/g;
+ $l =~ s/\$\{MODEL_PATH\}/$MODEL_PATH/g;
+ print $local_moses_ini $l;
+ }
+ close MO;
+ close MI;
+
+ return $local_moses_ini->filename;
+}
+
+1;
+