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
path: root/moses
diff options
context:
space:
mode:
authorLane Schwartz <dowobeha@gmail.com>2017-02-25 00:52:39 +0300
committerLane Schwartz <dowobeha@gmail.com>2017-02-25 00:52:39 +0300
commit31f19a15e7038dca9ac755b6697fd7a6d1298dba (patch)
tree5c02242bdb56f9fb7188b072d597c0ccbe8c3e6e /moses
parent2c061823bbb009cbf2631e1f5b3bdbf3cb572071 (diff)
Added alignment options to Moses server
Diffstat (limited to 'moses')
-rw-r--r--moses/Manager.cpp2
-rw-r--r--moses/parameters/ReportingOptions.cpp14
-rw-r--r--moses/server/TranslationRequest.cpp19
-rw-r--r--moses/server/TranslationRequest.h4
4 files changed, 26 insertions, 13 deletions
diff --git a/moses/Manager.cpp b/moses/Manager.cpp
index 3650baabb..c9842be6e 100644
--- a/moses/Manager.cpp
+++ b/moses/Manager.cpp
@@ -1737,7 +1737,7 @@ OutputSurface(std::ostream &out, Hypothesis const& edge, bool const recursive) c
// trace ("report segmentation") option "-t" / "-tt"
int reportSegmentation = options()->output.ReportSegmentation;
- if (reportSegmentation > 0 && phrase.GetSize() > 0) {
+ if (reportSegmentation > 0 && phrase.GetSize() > 0) {
const Range &sourceRange = edge.GetCurrSourceWordsRange();
const int sourceStart = sourceRange.GetStartPos();
const int sourceEnd = sourceRange.GetEndPos();
diff --git a/moses/parameters/ReportingOptions.cpp b/moses/parameters/ReportingOptions.cpp
index 210950a3c..fe56a7356 100644
--- a/moses/parameters/ReportingOptions.cpp
+++ b/moses/parameters/ReportingOptions.cpp
@@ -128,11 +128,17 @@ namespace Moses {
for (size_t i = 0; i < MAX_NUM_FACTORS; ++i)
factor_order.push_back(i);
}
+
+ m = param.find("no-ReportSegmentation");
+ if (m == param.end() || !Scan<bool>(xmlrpc_c::value_string(m->second))) {
+
+ // If we are reporting alignment info, turn on ReportSegmentation, unless XML request explicitly says not to
+ m = param.find("align");
+ if (m != param.end() && Scan<bool>(xmlrpc_c::value_string(m->second)))
+ ReportSegmentation = 1;
- m = param.find("align");
- if (m != param.end() && Scan<bool>(xmlrpc_c::value_string(m->second)))
- ReportSegmentation = 1;
-
+ }
+
PrintAlignmentInfo = check(param,"word-align",PrintAlignmentInfo);
m = param.find("factor-delimiter");
diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp
index e2580fe2f..767358e5c 100644
--- a/moses/server/TranslationRequest.cpp
+++ b/moses/server/TranslationRequest.cpp
@@ -85,13 +85,14 @@ void
TranslationRequest::
add_phrase_aln_info(Hypothesis const& h, vector<xmlrpc_c::value>& aInfo) const
{
- // if (!m_withAlignInfo) return;
- if (!options()->output.ReportSegmentation) return;
+ if (!m_withAlignInfo) return;
+ // if (!options()->output.ReportSegmentation) return;
Range const& trg = h.GetCurrTargetWordsRange();
Range const& src = h.GetCurrSourceWordsRange();
std::map<std::string, xmlrpc_c::value> pAlnInfo;
pAlnInfo["tgt-start"] = xmlrpc_c::value_int(trg.GetStartPos());
+ pAlnInfo["tgt-end"] = xmlrpc_c::value_int(trg.GetEndPos());
pAlnInfo["src-start"] = xmlrpc_c::value_int(src.GetStartPos());
pAlnInfo["src-end"] = xmlrpc_c::value_int(src.GetEndPos());
aInfo.push_back(xmlrpc_c::value_struct(pAlnInfo));
@@ -356,6 +357,12 @@ parse_request(std::map<std::string, xmlrpc_c::value> const& params)
}
}
+ // Report alignment info if Moses config says to or if XML request says to
+ m_withAlignInfo = options()->output.ReportSegmentation || check(params, "align");
+
+ // Report word alignment info if Moses config says to or if XML request says to
+ m_withWordAlignInfo = options()->output.PrintAlignmentInfo || check(params, "word-align");
+
si = params.find("weights");
if (si != params.end())
{
@@ -465,8 +472,8 @@ pack_hypothesis(const Moses::Manager& manager,
<< std::endl);
dest[key] = xmlrpc_c::value_string(target.str());
- // if (m_withAlignInfo) {
- if (options()->output.ReportSegmentation) {
+ if (m_withAlignInfo) {
+ // if (options()->output.ReportSegmentation) {
// phrase alignment, if requested
vector<xmlrpc_c::value> p_aln;
@@ -475,8 +482,8 @@ pack_hypothesis(const Moses::Manager& manager,
dest["align"] = xmlrpc_c::value_array(p_aln);
}
- // if (m_withWordAlignInfo) {
- if (options()->output.PrintAlignmentInfo) {
+ if (m_withWordAlignInfo) {
+ //if (options()->output.PrintAlignmentInfo) {
// word alignment, if requested
vector<xmlrpc_c::value> w_aln;
BOOST_REVERSE_FOREACH(Hypothesis const* e, edges)
diff --git a/moses/server/TranslationRequest.h b/moses/server/TranslationRequest.h
index 2554e5544..3463c72c8 100644
--- a/moses/server/TranslationRequest.h
+++ b/moses/server/TranslationRequest.h
@@ -38,8 +38,8 @@ TranslationRequest : public virtual Moses::TranslationTask
Translator* m_translator;
std::string m_source_string, m_target_string;
- // bool m_withAlignInfo;
- // bool m_withWordAlignInfo;
+ bool m_withAlignInfo;
+ bool m_withWordAlignInfo;
bool m_withGraphInfo;
bool m_withTopts;
bool m_withScoreBreakdown;