First attempt at fixing missing-backoffs bug in lmplz

This commit is contained in:
Marcin Junczys-Dowmunt 2014-07-27 20:33:34 +02:00
parent 846cf724ec
commit e094d670d7

View File

@ -25,6 +25,7 @@ class Callback {
~Callback() {
for (std::size_t i = 0; i < backoffs_.size(); ++i) {
if(prune_thresholds_[i + 1] > 0)
while(backoffs_[i])
++backoffs_[i];
@ -54,10 +55,8 @@ class Callback {
uint64_t current_hash = util::MurmurHashNative(gram.begin(), gram.Order() * sizeof(WordIndex));
const HashGamma *hashed_backoff = static_cast<const HashGamma*>(backoffs_[order_minus_1].Get());
while(backoffs_[order_minus_1] && current_hash != hashed_backoff->hash_value) {
++backoffs_[order_minus_1];
while(current_hash != hashed_backoff->hash_value && ++backoffs_[order_minus_1])
hashed_backoff = static_cast<const HashGamma*>(backoffs_[order_minus_1].Get());
}
if(current_hash == hashed_backoff->hash_value) {
pay.complete.backoff = log10(hashed_backoff->gamma);