From 26235c2770f10fc6975a06fd3a8167cbd23029a9 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 25 Nov 2013 00:14:16 -0500 Subject: remove dead code, add adagrad crf learner --- tests/run-system-tests.pl | 4 +++- tests/tools/flex-diff.pl | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 tests/tools/flex-diff.pl (limited to 'tests') diff --git a/tests/run-system-tests.pl b/tests/run-system-tests.pl index 8555ef78..324763ae 100755 --- a/tests/run-system-tests.pl +++ b/tests/run-system-tests.pl @@ -11,6 +11,7 @@ my $TEMP_DIR = tempdir( CLEANUP => 1 ); my $DECODER = "$script_dir/../decoder/cdec"; my $FILTER = "$script_dir/tools/filter-stderr.pl"; my $COMPARE_STATS = "$script_dir/tools/compare-statistics.pl"; +my $XDIFF = "$script_dir/tools/flex-diff.pl"; die "Can't find $DECODER" unless -f $DECODER; die "Can't execute $DECODER" unless -x $DECODER; @@ -18,6 +19,7 @@ die "Can't find $FILTER" unless -f $FILTER; die "Can't execute $FILTER" unless -x $FILTER; die "Can't find $COMPARE_STATS" unless -f $COMPARE_STATS; die "Can't execute $COMPARE_STATS" unless -x $COMPARE_STATS; +die "Can't execute $XDIFF" unless -x $XDIFF; my $TEST_DIR = "$script_dir/system_tests"; opendir DIR, $TEST_DIR or die "Can't open $TEST_DIR: $!"; @@ -62,7 +64,7 @@ for my $test (@tests) { } else { die unless -f "$TEMP_DIR/stdout"; my $failed = 0; - run3 "diff gold.stdout $TEMP_DIR/stdout"; + run3 "$XDIFF gold.stdout $TEMP_DIR/stdout"; if ($? != 0) { print STDERR " FAILED differences in output!\n"; $failed = 1; diff --git a/tests/tools/flex-diff.pl b/tests/tools/flex-diff.pl new file mode 100755 index 00000000..245e9a1b --- /dev/null +++ b/tests/tools/flex-diff.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl -w +use strict; +use IPC::Run3; + +# this file abstracts away from differences due to different hash +# functions that lead to different orders of features, n-best entries, +# etc. + +die "Usage: $0 file1.txt file2.txt\n" unless scalar @ARGV == 2; +my $tmpa = "tmp.$$.a"; +my $tmpb = "tmp.$$.b"; +create_sorted($ARGV[0], $tmpa); +create_sorted($ARGV[1], $tmpb); + +my $failed = 0; +run3 "diff $tmpa $tmpb"; +if ($? != 0) { + run3 "diff $ARGV[0] $ARGV[1]"; + $failed = 1; +} + +unlink $tmpa; +unlink $tmpb; + +exit $failed; + +sub create_sorted { + my ($in, $out) = @_; + open A, "sort $in|" or die "Can't read $in: $!"; + open AA, ">$out" or die "Can't write $out: $!"; + while() { + chomp; + s/^\s*//; + s/\s*$//; + my @cs = split //; + @cs = sort @cs; + my $o = join('', @cs); + print AA "$o\n"; + } + close AA; + close A; +} + -- cgit v1.2.3 From 73aea215412a8a2837292d9eac1617df7c45ef01 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 25 Nov 2013 00:28:48 -0500 Subject: fix for ubuntu systems --- tests/tools/flex-diff.pl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/tools/flex-diff.pl b/tests/tools/flex-diff.pl index 245e9a1b..30f73c4d 100755 --- a/tests/tools/flex-diff.pl +++ b/tests/tools/flex-diff.pl @@ -1,5 +1,8 @@ #!/usr/bin/perl -w use strict; + +my $script_dir; BEGIN { use Cwd qw/ abs_path cwd /; use File::Basename; $script_dir = dirname(abs_path($0)); push @INC, "$script_dir/.."; } + use IPC::Run3; # this file abstracts away from differences due to different hash -- cgit v1.2.3