diff options
author | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-11-25 00:14:16 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@Chriss-MacBook-Air.local> | 2013-11-25 00:14:16 -0500 |
commit | cdb7f2b26e717bbfe84dbd73f949c6b06ca2b2d7 (patch) | |
tree | 9d845458299fd0f16de20a0f3dbe07cf7dc3e918 /tests/tools | |
parent | f2fb69b10a897e8beb4e6e6d6cbb4327096235ef (diff) |
remove dead code, add adagrad crf learner
Diffstat (limited to 'tests/tools')
-rwxr-xr-x | tests/tools/flex-diff.pl | 43 |
1 files changed, 43 insertions, 0 deletions
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(<A>) { + chomp; + s/^\s*//; + s/\s*$//; + my @cs = split //; + @cs = sort @cs; + my $o = join('', @cs); + print AA "$o\n"; + } + close AA; + close A; +} + |