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:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-10-21 02:56:29 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-10-21 02:56:29 +0300
commit06a516842d9618c1d8e30759facb15c97d87b15a (patch)
tree5942125014b0f4f211a9083e01b7635582f6577a /moses/server
parent08b8157042330141a8e7ae6e8274d15e111ef6ac (diff)
Moses server now accepts context weights as translation request parameters.
Diffstat (limited to 'moses/server')
-rw-r--r--moses/server/Session.h4
-rw-r--r--moses/server/TranslationRequest.cpp15
2 files changed, 15 insertions, 4 deletions
diff --git a/moses/server/Session.h b/moses/server/Session.h
index daba6d006..f56780839 100644
--- a/moses/server/Session.h
+++ b/moses/server/Session.h
@@ -17,7 +17,7 @@ namespace MosesServer{
time_t start_time;
time_t last_access;
boost::shared_ptr<Moses::ContextScope> const scope; // stores local info
-
+ SPTR<std::map<std::string,float> > m_context_weights;
Session(uint64_t const session_id)
@@ -27,6 +27,8 @@ namespace MosesServer{
}
bool is_new() const { return last_access == start_time; }
+
+ void setup(std::map<std::string, xmlrpc_c::value> const& params);
};
class SessionCache
diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp
index bdccd8b87..8c1efb628 100644
--- a/moses/server/TranslationRequest.cpp
+++ b/moses/server/TranslationRequest.cpp
@@ -39,9 +39,11 @@ void
TranslationRequest::
Run()
{
- std::map<std::string,xmlrpc_c::value>const& params = m_paramList.getStruct(0);
+ typedef std::map<std::string,xmlrpc_c::value> param_t;
+ param_t const& params = m_paramList.getStruct(0);
parse_request(params);
// cerr << "SESSION ID" << ret->m_session_id << endl;
+
if (m_session_id)
{
Session const& S = m_translator->get_session(m_session_id);
@@ -51,6 +53,11 @@ Run()
}
else m_scope.reset(new Moses::ContextScope);
+ // settings within the session scope
+ param_t::const_iterator si = params.find("context-weights");
+ if (si != params.end())
+ m_context_weights = m_scope->GetContextWeights(&si->second);
+
Moses::StaticData const& SD = Moses::StaticData::Instance();
//Make sure alternative paths are retained, if necessary
@@ -239,6 +246,7 @@ TranslationRequest(xmlrpc_c::paramList const& paramList,
m_options = StaticData::Instance().options();
}
+
void
TranslationRequest::
parse_request(std::map<std::string, xmlrpc_c::value> const& params)
@@ -262,7 +270,7 @@ parse_request(std::map<std::string, xmlrpc_c::value> const& params)
m_session_id = xmlrpc_c::value_int(si->second);
else
m_session_id = 0;
-
+
m_withAlignInfo = check(params, "align");
m_withWordAlignInfo = check(params, "word-align");
m_withGraphInfo = check(params, "sg");
@@ -347,7 +355,8 @@ pack_hypothesis(vector<Hypothesis const* > const& edges, string const& key,
ostringstream target;
BOOST_REVERSE_FOREACH(Hypothesis const* e, edges)
output_phrase(target, e->GetCurrTargetPhrase());
- std::cerr << "SERVER TRANSLATION: " << target.str() << std::endl;
+ XVERBOSE(1,"SERVER TRANSLATION: " << target.str() << std::endl);
+
dest[key] = xmlrpc_c::value_string(target.str());
if (m_withAlignInfo) {