mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Fix 'Use of uninitialized value' error through explicit setting of 0s in hash.
Fixes the following errors in bootstrap-hypothesis-difference-significance.pl on Perl v5.14.2: Use of uninitialized value $coocUpd in numeric gt (>) at /fs/lofn0/dmadl/software/mosesdecoder/scripts/analysis/bootstrap-hypothesis-difference-significance.pl line 317. Use of uninitialized value $b in numeric lt (<) at /fs/lofn0/dmadl/software/mosesdecoder/scripts/analysis/bootstrap-hypothesis-difference-significance.pl line 543. Use of uninitialized value $coocUpd in addition (+) at /fs/lofn0/dmadl/software/mosesdecoder/scripts/analysis/bootstrap-hypothesis-difference-significance.pl line 314. Use of uninitialized value $coocUpd in numeric gt (>) at /fs/lofn0/dmadl/software/mosesdecoder/scripts/analysis/bootstrap-hypothesis-difference-significance.pl line 317. Use of uninitialized value $a in numeric gt (>) at /fs/lofn0/dmadl/software/mosesdecoder/scripts/analysis/bootstrap-hypothesis-difference-significance.pl line 552.
This commit is contained in:
parent
7e3050f7f2
commit
3c30210dad
@ -313,6 +313,9 @@ sub preEvalHypoSnt {
|
||||
|
||||
#correct, total
|
||||
for my $ngram (keys %$hypNgramCounts) {
|
||||
if (!exists $refNgramCounts->{$ngram}) {
|
||||
$refNgramCounts->{$ngram} = 0;
|
||||
}
|
||||
$coocUpd = min($hypNgramCounts->{$ngram}, $refNgramCounts->{$ngram});
|
||||
$correctNgramCounts += $coocUpd;
|
||||
$totalNgramCounts += $hypNgramCounts->{$ngram};
|
||||
@ -514,6 +517,9 @@ sub groupNgramsMultiSrc {
|
||||
my $currNgramCounts = groupNgrams($ref->[$lineIdx], $order);
|
||||
|
||||
for my $currNgram (keys %$currNgramCounts) {
|
||||
if (!exists $result{$currNgram}) {
|
||||
$result{$currNgram} = 0;
|
||||
}
|
||||
$result{$currNgram} = max($result{$currNgram}, $currNgramCounts->{$currNgram});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user