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-06-07 20:36:30 +0300
committerMichael Denkowski <mdenkows@amazon.com>2016-08-12 13:05:11 +0300
commita407452d3993b88d725a7838f7c76522ac11a7c8 (patch)
tree13a215c26d21d5b684b36672fca686cc884f611e
parent7db3fedc3b6a2498fec82ea648661140c56e1040 (diff)
XML option for sentence coordinates
-rw-r--r--moses/InputType.h3
-rw-r--r--moses/Sentence.cpp3
-rw-r--r--moses/XmlOption.cpp11
-rw-r--r--moses/XmlOption.h3
4 files changed, 17 insertions, 3 deletions
diff --git a/moses/InputType.h b/moses/InputType.h
index 80080a3f2..30b86180d 100644
--- a/moses/InputType.h
+++ b/moses/InputType.h
@@ -68,6 +68,9 @@ public:
size_t m_frontSpanCoveredLength;
// how many words from the beginning are covered
+ // coordinates in some space, populated by xml tag "coord"
+ boost::shared_ptr<std::vector<float> > m_coord;
+
InputType(AllOptions::ptr const& opts, long translationId = 0);
virtual ~InputType();
diff --git a/moses/Sentence.cpp b/moses/Sentence.cpp
index 98bfb9e0a..b7e24a85f 100644
--- a/moses/Sentence.cpp
+++ b/moses/Sentence.cpp
@@ -154,7 +154,8 @@ aux_interpret_xml(std::string& line, std::vector<size_t> & xmlWalls,
bool OK = ProcessAndStripXMLTags(*m_options, line,
m_xmlOptions,
m_reorderingConstraint,
- xmlWalls, placeholders);
+ xmlWalls, placeholders,
+ *this);
if (!OK) {
TRACE_ERR("Unable to parse XML in line: " << line);
}
diff --git a/moses/XmlOption.cpp b/moses/XmlOption.cpp
index 8a517386f..7e65a5443 100644
--- a/moses/XmlOption.cpp
+++ b/moses/XmlOption.cpp
@@ -163,7 +163,8 @@ ProcessAndStripXMLTags(AllOptions const& opts, string &line,
vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint,
vector< size_t > &walls,
- std::vector< std::pair<size_t, std::string> > &placeholders)
+ std::vector< std::pair<size_t, std::string> > &placeholders,
+ InputType &input)
{
//parse XML markup in translation line
@@ -401,6 +402,14 @@ ProcessAndStripXMLTags(AllOptions const& opts, string &line,
StaticData::InstanceNonConst().SetAllWeights(allWeights);
}
+ // coord: coordinate(s) of the input sentence in some space
+ // (one or more floats)
+ else if (tagName == "coord") {
+ vector<string> toks = Tokenize(ParseXmlTagAttribute(tagContent, "coord"));
+ input.m_coord.reset(new vector<float>());
+ Scan<float>(*(input.m_coord), toks);
+ }
+
// default: opening tag that specifies translation options
else {
if (startPos > endPos) {
diff --git a/moses/XmlOption.h b/moses/XmlOption.h
index 00bebc2e6..da3ee8044 100644
--- a/moses/XmlOption.h
+++ b/moses/XmlOption.h
@@ -34,7 +34,8 @@ bool ProcessAndStripXMLTags(AllOptions const& opts,
std::string &line, std::vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint,
std::vector< size_t > &walls,
- std::vector< std::pair<size_t, std::string> > &placeholders);
+ std::vector< std::pair<size_t, std::string> > &placeholders,
+ InputType &input);
}