summaryrefslogtreecommitdiff
path: root/decoder
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
commit97b85c082b3e55c28a8b0c0eb762483ac84a1577 (patch)
treee9e97e924007f3d195907ea83b290cf67b70f363 /decoder
parent9b99cb844e3e379b557ff8578df27893ce147f1a (diff)
Fix segfault, accurate decoding
Diffstat (limited to 'decoder')
-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;