summaryrefslogtreecommitdiff
path: root/decoder/lazy.cc
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-10-14 09:54:01 -0400
committerKenneth Heafield <github@kheafield.com>2012-10-14 09:54:01 -0400
commitcf9994131993b40be62e90e213b1e11e6b550143 (patch)
tree7922cfaa2262d4d5368c9c28bcc6dc64f11e72df /decoder/lazy.cc
parentf568b392f82fd94b788a1b38094855234d318205 (diff)
Fix segfault, accurate decoding
Diffstat (limited to 'decoder/lazy.cc')
-rw-r--r--decoder/lazy.cc6
1 files changed, 4 insertions, 2 deletions
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 <class Model> unsigned char Lazy<Model>::ConvertEdge(const search::Cont
std::vector<lm::WordIndex> words;
unsigned int terminals = 0;
unsigned char nt = 0;
+ out.score = 0.0;
for (std::vector<WordID>::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 <class Model> unsigned char Lazy<Model>::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<float>(terminals) * context.GetWeights().WordPenalty() / M_LN10;
out.score += search::ScoreRule(context, words, final, out.between);
return nt;