Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@amazon.com>2016-10-19 05:27:47 +0300
committerMichael Denkowski <mdenkows@amazon.com>2016-10-19 05:28:36 +0300
commitb1fb21ecf063ba5d7eff0b8c2d90f0ff29dd33ba (patch)
tree560c0e230fc4348def6c71eb420ecb94d8c2db0d
parent883cbc2a4f6e955fe2e94d20fd541a0ab721fa3b (diff)
Support multiple output factors for XML-specified translations
-rw-r--r--moses/XmlOption.cpp14
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();