diff options
author | bhaddow <barry.haddow@gmail.com> | 2011-12-16 21:00:13 +0400 |
---|---|---|
committer | bhaddow <barry.haddow@gmail.com> | 2011-12-16 21:00:13 +0400 |
commit | b0e0546dd901983f2cda726656e3855f5da298c5 (patch) | |
tree | d27ac7770db8a89f68d8c3d5d0e87902f1dba5c1 /scripts/generic | |
parent | 63f2b4b07adde3259fc3e9a25ac3fc6ba341602b (diff) |
Add option to lowercase input
Diffstat (limited to 'scripts/generic')
-rwxr-xr-x | scripts/generic/multi-bleu.perl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/generic/multi-bleu.perl b/scripts/generic/multi-bleu.perl index a24cd2cc7..06f01acff 100755 --- a/scripts/generic/multi-bleu.perl +++ b/scripts/generic/multi-bleu.perl @@ -3,9 +3,15 @@ # $Id$ use strict; +my $lowercase = 0; +if ($ARGV[0] eq "-lc") { + $lowercase = 1; + shift; +} + my $stem = $ARGV[0]; if (!defined $stem) { - print STDERR "usage: multi-bleu.pl reference < hypothesis\n"; + print STDERR "usage: multi-bleu.pl [-lc] reference < hypothesis\n"; print STDERR "Reads the references from reference or reference0, reference1, ...\n"; exit(1); } @@ -35,12 +41,14 @@ my(@CORRECT,@TOTAL,$length_translation,$length_reference); my $s=0; while(<STDIN>) { chop; + $_ = lc if $lowercase; my @WORD = split; my %REF_NGRAM = (); my $length_translation_this_sentence = scalar(@WORD); my ($closest_diff,$closest_length) = (9999,9999); foreach my $reference (@{$REF[$s]}) { # print "$s $_ <=> $reference\n"; + $reference = lc($reference) if $lowercase; my @WORD = split(/ /,$reference); my $length = scalar(@WORD); my $diff = abs($length_translation_this_sentence-$length); |