check there are hypos in stack vector before create translation options. constrained decoding works for syntax model

This commit is contained in:
Hieu Hoang 2013-09-18 04:45:19 +02:00
parent f88908f972
commit 7873dbb77a
2 changed files with 9 additions and 3 deletions

View File

@ -60,15 +60,13 @@ ChartHypothesisCollection::~ChartHypothesisCollection()
*/
bool ChartHypothesisCollection::AddHypothesis(ChartHypothesis *hypo, ChartManager &manager)
{
/*
cerr << *hypo << endl;
if (hypo->GetTotalScore() == - std::numeric_limits<float>::infinity()) {
manager.GetSentenceStats().AddDiscarded();
VERBOSE(3,"discarded, -inf score" << std::endl);
ChartHypothesis::Delete(hypo);
return false;
}
*/
if (hypo->GetTotalScore() < m_bestScore + m_beamWidth) {
// really bad score. don't bother adding hypo into collection
manager.GetSentenceStats().AddDiscarded();

View File

@ -67,6 +67,14 @@ void ChartTranslationOptionList::Add(const TargetPhraseCollection &tpc,
return;
}
for (size_t i = 0; i < stackVec.size(); ++i) {
const ChartCellLabel &chartCellLabel = *stackVec[i];
size_t numHypos = chartCellLabel.GetStack().cube->size();
if (numHypos == 0) {
return; // empty stack. These rules can't be used
}
}
float score = ChartTranslationOptions::CalcEstimateOfBestScore(tpc, stackVec);
// If the rule limit has already been reached then don't add the option