From b1fb21ecf063ba5d7eff0b8c2d90f0ff29dd33ba Mon Sep 17 00:00:00 2001 From: Michael Denkowski Date: Tue, 18 Oct 2016 22:27:47 -0400 Subject: Support multiple output factors for XML-specified translations --- moses/XmlOption.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/moses/XmlOption.cpp b/moses/XmlOption.cpp index 6e089c774..fbd336448 100644 --- a/moses/XmlOption.cpp +++ b/moses/XmlOption.cpp @@ -479,8 +479,18 @@ ProcessAndStripXMLTags(AllOptions const& opts, string &line, Range range(startPos + offset,endPos-1 + offset); // span covered by phrase TargetPhrase targetPhrase(firstPt); - // targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i],factorDelimiter, NULL); - targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i], NULL); + // Target factors may be used by intermediate models (example: a + // generation model produces a factor used by a class-based LM + // but NOT output. Fake the output factor order to match the + // number of factors specified in the alt text. A one-factor + // system would have "word", a two-factor system would have + // "word|class", and so on. + vector fakeOutputFactorOrder; + size_t factorsInAltText = Tokenize(altTexts[i], StaticData::Instance().GetFactorDelimiter()).size(); + for (size_t f = 0; f < factorsInAltText; ++f) { + fakeOutputFactorOrder.push_back(f); + } + targetPhrase.CreateFromString(Output, fakeOutputFactorOrder, altTexts[i], NULL); // lhs const UnknownLHSList &lhsList = opts.syntax.unknown_lhs; // staticData.GetUnknownLHS(); -- cgit v1.2.3