From 747309fcb0e0b1c6d060a68286ba1cf5ed1fbfa4 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Sat, 24 Sep 2011 11:33:22 -0400 Subject: Chris says remnant and oovs should not be null, so stop checking. Also, we were not properly doing ZeroRemaining, sorry. --- decoder/ff_klm.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'decoder') diff --git a/decoder/ff_klm.cc b/decoder/ff_klm.cc index 3b2113ad..6d9aca54 100644 --- a/decoder/ff_klm.cc +++ b/decoder/ff_klm.cc @@ -92,10 +92,9 @@ class KLanguageModelImpl { public: double LookupWords(const TRule& rule, const vector& ant_states, double* oovs, void* remnant) { - if (oovs) *oovs = 0; + *oovs = 0; const vector& e = rule.e(); - lm::ngram::ChartState state; - lm::ngram::RuleScore ruleScore(*ngram_, remnant ? *static_cast(remnant) : state); + lm::ngram::RuleScore ruleScore(*ngram_, *static_cast(remnant)); unsigned i = 0; if (e.size()) { if (e[i] == kCDEC_SOS) { @@ -115,13 +114,12 @@ class KLanguageModelImpl { const WordID cdec_word_or_class = ClassifyWordIfNecessary(e[i]); // in future, // maybe handle emission const lm::WordIndex cur_word = MapWord(cdec_word_or_class); // map to LM's id - const bool is_oov = (cur_word == 0); - if (is_oov && oovs) (*oovs) += 1.0; + if (cur_word == 0) (*oovs) += 1.0; ruleScore.Terminal(cur_word); } } double ret = ruleScore.Finish(); - state.ZeroRemaining(); + static_cast(remnant)->ZeroRemaining(); return ret; } -- cgit v1.2.3