diff options
-rw-r--r-- | moses/XmlOption.cpp | 14 |
1 files 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<FactorType> 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(); |