mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 21:42:19 +03:00
Fix a segmentation fault produced when both 'constraint' and
'translation-details' are used, and no hypothesis that matches the reference translation is found. The problem resulted from a missing check if a vector is empty before incrementing its iterator. git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3950 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
a836747b4e
commit
83d02c11c6
@ -16,14 +16,17 @@ void PrintTranslationAnalysis(const TranslationSystem* system, std::ostream &os,
|
||||
{
|
||||
os << std::endl << "TRANSLATION HYPOTHESIS DETAILS:" << std::endl;
|
||||
std::vector<const Hypothesis*> translationPath;
|
||||
|
||||
while (hypo) {
|
||||
translationPath.push_back(hypo);
|
||||
hypo = hypo->GetPrevHypo();
|
||||
}
|
||||
std::reverse(translationPath.begin(), translationPath.end());
|
||||
|
||||
std::reverse(translationPath.begin(), translationPath.end());
|
||||
std::vector<std::string> droppedWords;
|
||||
std::vector<const Hypothesis*>::iterator tpi = translationPath.begin();
|
||||
if(tpi == translationPath.end())
|
||||
return;
|
||||
++tpi; // skip initial translation state
|
||||
std::vector<std::string> sourceMap;
|
||||
std::vector<std::string> targetMap;
|
||||
@ -39,9 +42,7 @@ void PrintTranslationAnalysis(const TranslationSystem* system, std::ostream &os,
|
||||
std::string source = (*tpi)->GetSourcePhraseStringRep();
|
||||
WordsRange twr = (*tpi)->GetCurrTargetWordsRange();
|
||||
WordsRange swr = (*tpi)->GetCurrSourceWordsRange();
|
||||
|
||||
const AlignmentInfo &alignmentInfo = (*tpi)->GetCurrTargetPhrase().GetAlignmentInfo();
|
||||
|
||||
// language model backoff stats,
|
||||
if (doLMStats) {
|
||||
std::vector<std::vector<unsigned int> >& lmstats = *(*tpi)->GetLMStats();
|
||||
|
Loading…
Reference in New Issue
Block a user