diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp index efb6da8c8..0473f1f5c 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.cpp @@ -15,7 +15,7 @@ using namespace std; namespace Moses2 { -std::ostream& operator<<(std::ostream &out, const XMLNode &obj) +std::ostream& operator<<(std::ostream &out, const XMLOption &obj) { out << "[" << obj.startPos << "," << obj.phraseSize << "]=" << obj.nodeName; return out; @@ -28,12 +28,13 @@ Sentence *Sentence::CreateFromString(MemPool &pool, FactorCollection &vocab, { std::vector toks; - vector xmlNodes; + vector *xmlOptions; Sentence *ret; if (system.options.input.xml_policy) { // xml + xmlOptions = new vector(); pugi::xml_document doc; string str2 = "" + str + ""; @@ -41,10 +42,10 @@ Sentence *Sentence::CreateFromString(MemPool &pool, FactorCollection &vocab, pugi::parse_default | pugi::parse_comments); pugi::xml_node topNode = doc.child("xml"); - XMLParse(0, topNode, toks, xmlNodes); + XMLParse(0, topNode, toks, *xmlOptions); - for (size_t i = 0; i < xmlNodes.size(); ++i) { - cerr << *xmlNodes[i] << endl; + for (size_t i = 0; i < xmlOptions->size(); ++i) { + cerr << *(*xmlOptions)[i] << endl; } } else { @@ -61,9 +62,10 @@ Sentence *Sentence::CreateFromString(MemPool &pool, FactorCollection &vocab, // xml // clean up - for (size_t i = 0; i < xmlNodes.size(); ++i) { - delete xmlNodes[i]; + for (size_t i = 0; i < xmlOptions->size(); ++i) { + delete (*xmlOptions)[i]; } + delete xmlOptions; } @@ -75,7 +77,7 @@ void Sentence::XMLParse( size_t depth, const pugi::xml_node &parentNode, std::vector &toks, - vector &xmlNodes) + vector &xmlOptions) { // pugixml for (pugi::xml_node childNode = parentNode.first_child(); childNode; childNode = childNode.next_sibling()) { string nodeName = childNode.name(); @@ -93,13 +95,13 @@ void Sentence::XMLParse( } if (!nodeName.empty()) { - XMLNode *xmlNode = new XMLNode(); + XMLOption *xmlNode = new XMLOption(); xmlNode->nodeName = nodeName; xmlNode->startPos = startPos - 1; - xmlNodes.push_back(xmlNode); + xmlOptions.push_back(xmlNode); // recursively call this function. For proper recursive trees - XMLParse(depth + 1, childNode, toks, xmlNodes); + XMLParse(depth + 1, childNode, toks, xmlOptions); size_t endPos = toks.size(); xmlNode->phraseSize = endPos - startPos; diff --git a/contrib/other-builds/moses2/PhraseBased/Sentence.h b/contrib/other-builds/moses2/PhraseBased/Sentence.h index 71bd0b13b..f8c55591b 100644 --- a/contrib/other-builds/moses2/PhraseBased/Sentence.h +++ b/contrib/other-builds/moses2/PhraseBased/Sentence.h @@ -20,9 +20,9 @@ class FactorCollection; class System; ////////////////////////////////////////////////////////////////////////////// -class XMLNode +class XMLOption { - friend std::ostream& operator<<(std::ostream &out, const XMLNode &obj); + friend std::ostream& operator<<(std::ostream &out, const XMLOption &obj); public: std::string nodeName; @@ -49,7 +49,7 @@ protected: size_t depth, const pugi::xml_node &parentNode, std::vector &toks, - std::vector &xmlNodes); + std::vector &xmlOptions); };