From 97b85c082b3e55c28a8b0c0eb762483ac84a1577 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Sun, 14 Oct 2012 09:54:01 -0400 Subject: Fix segfault, accurate decoding --- decoder/lazy.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'decoder') diff --git a/decoder/lazy.cc b/decoder/lazy.cc index 9dc657d6..1e6a94fe 100644 --- a/decoder/lazy.cc +++ b/decoder/lazy.cc @@ -138,10 +138,12 @@ template unsigned char Lazy::ConvertEdge(const search::Cont std::vector words; unsigned int terminals = 0; unsigned char nt = 0; + out.score = 0.0; for (std::vector::const_iterator word = e.begin(); word != e.end(); ++word) { if (*word <= 0) { out.nt[nt] = vertices[in.tail_nodes_[-*word]].RootPartial(); if (out.nt[nt].Empty()) return 255; + out.score += out.nt[nt].Bound(); ++nt; words.push_back(lm::kMaxWordIndex); } else { @@ -150,14 +152,14 @@ template unsigned char Lazy::ConvertEdge(const search::Cont } } for (unsigned char fill = nt; fill < search::kMaxArity; ++fill) { - out.nt[nt] = search::kBlankPartialVertex; + out.nt[fill] = search::kBlankPartialVertex; } if (final) { words.push_back(m_.GetVocabulary().EndSentence()); } - out.score = in.rule_->GetFeatureValues().dot(cdec_weights_); + out.score += in.rule_->GetFeatureValues().dot(cdec_weights_); out.score -= static_cast(terminals) * context.GetWeights().WordPenalty() / M_LN10; out.score += search::ScoreRule(context, words, final, out.between); return nt; -- cgit v1.2.3