From a50b6162b1c5b18473db9de98aa1fa73620b9af9 Mon Sep 17 00:00:00 2001 From: redpony Date: Sun, 5 Dec 2010 01:42:19 +0000 Subject: small changes git-svn-id: https://ws10smt.googlecode.com/svn/trunk@740 ec762483-ff6d-05da-a07a-a48fb63a330f --- rescore/rescore_inv_model1.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'rescore') diff --git a/rescore/rescore_inv_model1.pl b/rescore/rescore_inv_model1.pl index 4fc3cfcc..780452f5 100755 --- a/rescore/rescore_inv_model1.pl +++ b/rescore/rescore_inv_model1.pl @@ -76,13 +76,17 @@ sub rescore { my @hyps = @$rh; my @feats = @$rf; my $nhyps = scalar @hyps; + my %cache = (); print STDERR "RESCORING SENTENCE id=$id (# hypotheses=$nhyps)...\n"; for (my $i=0; $i < $nhyps; $i++) { - my $score = 0; - if ($reverse_model) { - die "not implemented"; - } else { - $score = m1_prob($src, $hyps[$i]); + my $score = $cache{$hyps[$i]}; + if (!defined $score) { + if ($reverse_model) { + die "not implemented"; + } else { + $score = m1_prob($src, $hyps[$i]); + } + $cache{$hyps[$i]} = $score; } print "$id ||| $hyps[$i] ||| $feats[$i] $feature_name=$score\n"; } -- cgit v1.2.3