|
#include "SHyperedge.h" |
|
|
|
#include "moses/StaticData.h" |
|
|
|
#include "SVertex.h" |
|
|
|
namespace Moses |
|
{ |
|
namespace Syntax |
|
{ |
|
|
|
Phrase GetOneBestTargetYield(const SHyperedge &h) |
|
{ |
|
FactorType placeholderFactor = StaticData::Instance().options()->input.placeholder_factor; |
|
|
|
Phrase ret(ARRAY_SIZE_INCR); |
|
|
|
const AlignmentInfo::NonTermIndexMap &targetToSourceMap = |
|
h.label.translation->GetAlignNonTerm().GetNonTermIndexMap2(); |
|
|
|
for (std::size_t pos = 0; pos < h.label.translation->GetSize(); ++pos) { |
|
const Word &word = h.label.translation->GetWord(pos); |
|
if (word.IsNonTerminal()) { |
|
std::size_t sourceIndex = targetToSourceMap[pos]; |
|
const SHyperedge &incoming = *h.tail[sourceIndex]->best; |
|
Phrase subPhrase = GetOneBestTargetYield(incoming); |
|
ret.Append(subPhrase); |
|
} else { |
|
ret.AddWord(word); |
|
if (placeholderFactor == NOT_FOUND) { |
|
continue; |
|
} |
|
assert(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
} |
|
return ret; |
|
} |
|
|
|
} |
|
} |
|
|