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:
authorhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2008-01-29 22:28:13 +0300
committerhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2008-01-29 22:28:13 +0300
commitfd60fe93b9e1bb2f210fbea861d78d7a84b37624 (patch)
treed9cdbd6c1cc4b788bfcfc6f49f634aff8693bae3 /moses/src/XmlOption.cpp
parent060d26cbb309afe517a4685aeb0726022a405270 (diff)
roll back last change. seg fault in release build
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1549 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses/src/XmlOption.cpp')
-rw-r--r--moses/src/XmlOption.cpp44
1 files changed, 4 insertions, 40 deletions
diff --git a/moses/src/XmlOption.cpp b/moses/src/XmlOption.cpp
index 6c18aac12..e71dfc97f 100644
--- a/moses/src/XmlOption.cpp
+++ b/moses/src/XmlOption.cpp
@@ -26,7 +26,6 @@
#include <iostream>
#include "Util.h"
#include "StaticData.h"
-#include "TranslationOption.h"
namespace {
@@ -92,11 +91,10 @@ inline std::vector<std::string> TokenizeXml(const std::string& str)
}
-std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const InputType &source) {
+std::vector<XmlOption> ProcessAndStripXMLTags(std::string& line) {
//parse XML markup in translation line
- std::vector<TranslationOption*> res;
+ std::vector<XmlOption> res;
std::string rstr;
- std::string linkedStr;
if (line.find_first_of('<') == std::string::npos) { return res; }
std::vector<std::string> xmlTokens = TokenizeXml(line);
std::string tagName = "";
@@ -108,7 +106,6 @@ std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const
size_t curWord=0;
int numUnary = 0;
bool doClose = false;
- bool isLinked = false;
for (size_t xmlTokenPos = 0 ; xmlTokenPos < xmlTokens.size() ; xmlTokenPos++)
{
if(!isXmlTag(xmlTokens[xmlTokenPos]))
@@ -130,30 +127,7 @@ std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const
nextTagName = tag.substr(0,endOfName);
tagContents = tag.substr(endOfName+1);
}
- if (nextTagName == "linked") {
- isLinked = true;
- linkedStr = "";
- }
- else if (nextTagName == "/linked") {
- isLinked = false;
- // recurse to process linked tags
- std::vector<TranslationOption*> tOptions = ProcessAndStripXMLTags(linkedStr, source);
- // link them together
- std::vector<TranslationOption*>::const_iterator iterTransOpts1;
- std::vector<TranslationOption*>::const_iterator iterTransOpts2;
- for (iterTransOpts1 = tOptions.begin(); iterTransOpts1 != tOptions.end(); iterTransOpts1++) {
- for (iterTransOpts2 = tOptions.begin(); iterTransOpts2 != tOptions.end(); iterTransOpts2++) {
- if (iterTransOpts1 != iterTransOpts2) {
- (**iterTransOpts1).AddLinkedTransOpt(*iterTransOpts2);
- }
- }
- res.push_back(*iterTransOpts1);
- }
- }
- else if (isLinked) {
- linkedStr += xmlTokens[xmlTokenPos];
- }
- else if (isOpen)
+ if (isOpen)
{
//this is an open tag
tagName = nextTagName;
@@ -208,7 +182,6 @@ std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const
//TODO: deal with multiple XML options here
if (StaticData::Instance().GetXmlInputType() != XmlIgnore) {
- const std::vector<FactorType> &outputFactorOrder = StaticData::Instance().GetOutputFactorOrder();
for (size_t i=0; i<altTexts.size(); ++i) {
//only store options if we aren't ignoring them
//set default probability
@@ -216,15 +189,7 @@ std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const
if (altProbs[i] != "") probValue = Scan<float>(altProbs[i]);
//Convert from prob to log-prob
float scoreValue = FloorScore(TransformScore(probValue));
-
- TargetPhrase targetPhrase(Output);
- targetPhrase.CreateFromString(outputFactorOrder,altTexts[i],StaticData::Instance().GetFactorDelimiter());
- targetPhrase.SetScore(scoreValue);
- WordsRange range(tagStart,tagEnd);
-
- TranslationOption *option = new TranslationOption(range,targetPhrase,source);
- assert(option);
-
+ XmlOption option(tagStart,tagEnd,altTexts[i],scoreValue);
res.push_back(option);
}
}
@@ -240,4 +205,3 @@ std::vector<TranslationOption*> ProcessAndStripXMLTags(std::string& line, const
return res;
}
-