summaryrefslogtreecommitdiff
path: root/rescore/rescore_inv_model1.pl
diff options
context:
space:
mode:
Diffstat (limited to 'rescore/rescore_inv_model1.pl')
-rwxr-xr-xrescore/rescore_inv_model1.pl14
1 files changed, 9 insertions, 5 deletions
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";
}