Check factor is not null before outputting

This commit is contained in:
Hieu Hoang 2012-05-17 16:25:53 +01:00
parent b46107231d
commit 22ca90bd8a
2 changed files with 9 additions and 0 deletions

View File

@ -159,9 +159,12 @@ void OutputSurface(std::ostream &out, const Phrase &phrase, const std::vector<Fa
for (size_t pos = 0 ; pos < size ; pos++) {
const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
out << *factor;
CHECK(factor);
for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) {
const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]);
CHECK(factor);
out << "|" << *factor;
}
out << " ";
@ -203,6 +206,8 @@ void IOWrapper::OutputBestHypo(const std::vector<const Factor*>& mbrBestHypo, l
{
for (size_t i = 0 ; i < mbrBestHypo.size() ; i++) {
const Factor *factor = mbrBestHypo[i];
CHECK(factor);
cout << *factor << " ";
}
}

View File

@ -198,9 +198,12 @@ void OutputSurface(std::ostream &out, const Hypothesis &edge, const std::vector<
for (size_t pos = 0 ; pos < size ; pos++) {
const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
out << *factor;
CHECK(factor);
for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) {
const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]);
CHECK(factor);
out << "|" << *factor;
}
out << " ";
@ -307,6 +310,7 @@ void OutputBestHypo(const std::vector<Word>& mbrBestHypo, long /*translationId*
for (size_t i = 0 ; i < mbrBestHypo.size() ; i++) {
const Factor *factor = mbrBestHypo[i].GetFactor(StaticData::Instance().GetOutputFactorOrder()[0]);
CHECK(factor);
if (i>0) out << " " << *factor;
else out << *factor;
}