From 91afa4b4f17247f015c7a4cff7aa0c4425557ebe Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 8 May 2014 18:48:10 +0100 Subject: [PATCH] delete chart translation option if -inf score --- moses/ChartTranslationOptions.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/moses/ChartTranslationOptions.cpp b/moses/ChartTranslationOptions.cpp index 103d6e5b0..0bdad2b12 100644 --- a/moses/ChartTranslationOptions.cpp +++ b/moses/ChartTranslationOptions.cpp @@ -65,6 +65,22 @@ void ChartTranslationOptions::Evaluate(const InputType &input, const InputPath & transOpt.Evaluate(input, inputPath, m_stackVec); } + // get rid of -inf trans opts + size_t numDiscard = 0; + for (size_t i = 0; i < m_collection.size(); ++i) { + ChartTranslationOption *transOpt = m_collection[i].get(); + + if (transOpt->GetScores().GetWeightedScore() == - std::numeric_limits::infinity()) { + ++numDiscard; + } + else if (numDiscard) { + m_collection[i - numDiscard] = boost::shared_ptr(transOpt); + } + } + + m_collection.resize(m_collection.size() - numDiscard); + + } void ChartTranslationOptions::SetInputPath(const InputPath *inputPath)