diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp index e83a1759b..0a4b0ef85 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp @@ -32,6 +32,28 @@ Sentence *Sentence::CreateFromString(MemPool &pool, FactorCollection &vocab, if (system.options.input.xml_policy) { // xml + ret = CreateFromStringXML(pool, vocab, system, str, translationId); + } + else { + // no xml + //cerr << "PB Sentence" << endl; + std::vector toks = Tokenize(str); + + size_t size = toks.size(); + ret = new (pool.Allocate()) Sentence(translationId, pool, size); + ret->PhraseImplTemplate::CreateFromString(vocab, system, toks, false); + } + + //cerr << "REORDERING CONSTRAINTS:" << ret->GetReorderingConstraint() << endl; + + return ret; +} + +Sentence *Sentence::CreateFromStringXML(MemPool &pool, FactorCollection &vocab, + const System &system, const std::string &str, long translationId) +{ + Sentence *ret; + vector xmlOptions; pugi::xml_document doc; @@ -85,23 +107,10 @@ Sentence *Sentence::CreateFromString(MemPool &pool, FactorCollection &vocab, for (size_t i = 0; i < xmlOptions.size(); ++i) { delete xmlOptions[i]; } - } - else { - // no xml - //cerr << "PB Sentence" << endl; - std::vector toks = Tokenize(str); - size_t size = toks.size(); - ret = new (pool.Allocate()) Sentence(translationId, pool, size); - ret->PhraseImplTemplate::CreateFromString(vocab, system, toks, false); - } - - //cerr << "REORDERING CONSTRAINTS:" << ret->GetReorderingConstraint() << endl; - - return ret; + return ret; } - void Sentence::XMLParse( size_t depth, const pugi::xml_node &parentNode, diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.h b/contrib/other-builds/moses2/PhraseBased/Sentence.h index 5521c102a..fc0b04cdd 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.h +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.h @@ -48,6 +48,9 @@ public: {} protected: + static Sentence *CreateFromStringXML(MemPool &pool, FactorCollection &vocab, + const System &system, const std::string &str, long translationId); + static void XMLParse( size_t depth, const pugi::xml_node &parentNode,