diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-11-04 21:12:49 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-11-04 21:12:49 +0300 |
commit | ec1ef78d51921cdb64d0078293fe2e19b161eca2 (patch) | |
tree | 5e11d5d62ba8239db540e60193f5ef50f27c8201 /moses/server | |
parent | c435e46560c96f7e07f6090016331b2416641c73 (diff) |
Reduction in number of #ifdef HAVE_XMLRPC_C, as per Hieu's request.
Diffstat (limited to 'moses/server')
-rw-r--r-- | moses/server/PackScores.cpp | 3 | ||||
-rw-r--r-- | moses/server/PackScores.h | 10 | ||||
-rw-r--r-- | moses/server/Server.cpp | 16 | ||||
-rw-r--r-- | moses/server/Server.h | 6 | ||||
-rw-r--r-- | moses/server/TranslationRequest.cpp | 15 |
5 files changed, 19 insertions, 31 deletions
diff --git a/moses/server/PackScores.cpp b/moses/server/PackScores.cpp index db5710132..4ec6109d3 100644 --- a/moses/server/PackScores.cpp +++ b/moses/server/PackScores.cpp @@ -1,5 +1,4 @@ // -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*- -#ifdef HAVE_XMLRPC_C #include "PackScores.h" #include "moses/FF/StatefulFeatureFunction.h" #include "moses/FF/StatelessFeatureFunction.h" @@ -44,5 +43,3 @@ PackScores(ScoreComponentCollection const& S) return xmlrpc_c::value_struct(M); } } -#endif - diff --git a/moses/server/PackScores.h b/moses/server/PackScores.h index 98c57059d..5d875bc3b 100644 --- a/moses/server/PackScores.h +++ b/moses/server/PackScores.h @@ -1,16 +1,10 @@ // -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*- -#ifdef HAVE_XMLRPC_C #pragma once #include <xmlrpc-c/base.hpp> #include "moses/FF/FeatureFunction.h" #include "moses/ScoreComponentCollection.h" namespace Moses { - -xmlrpc_c::value -PackScores(ScoreComponentCollection const& S); - + xmlrpc_c::value + PackScores(ScoreComponentCollection const& S); } - - -#endif diff --git a/moses/server/Server.cpp b/moses/server/Server.cpp index 8f8c7d6a9..b5814e969 100644 --- a/moses/server/Server.cpp +++ b/moses/server/Server.cpp @@ -1,11 +1,9 @@ // -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*- #include "Server.h" - namespace MosesServer { Server:: Server(Moses::Parameter& params) -#ifdef HAVE_XMLRPC_C : m_server_options(params), m_updater(new Updater), m_optimizer(new Optimizer), @@ -17,15 +15,11 @@ namespace MosesServer m_registry.addMethod("optimize", m_optimizer); m_registry.addMethod("close_session", m_close_session); } -#else - { } -#endif int Server:: run() { -#ifdef HAVE_XMLRPC_C xmlrpc_c::serverAbyss myAbyssServer (xmlrpc_c::serverAbyss::constrOpt() .registryP(&m_registry) @@ -42,12 +36,8 @@ namespace MosesServer } else myAbyssServer.run(); - std::cerr << "xmlrpc_c::serverAbyss.run() returned but should not." << std::endl; - // #pragma message("BUILDING MOSES WITH SERVER SUPPORT") -#else - // #pragma message("BUILDING MOSES WITHOUT SERVER SUPPORT") - std::cerr << "Moses was compiled without server support." << std::endl; -#endif + std::cerr << "xmlrpc_c::serverAbyss.run() returned but it should not." + << std::endl; return 1; } @@ -71,6 +61,4 @@ namespace MosesServer { return m_session_cache.erase(session_id); } - - } diff --git a/moses/server/Server.h b/moses/server/Server.h index 81fbf2953..4afbf5d91 100644 --- a/moses/server/Server.h +++ b/moses/server/Server.h @@ -1,11 +1,12 @@ // -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*- #pragma once -#ifdef HAVE_XMLRPC_C #include "moses/TypeDef.h" + #ifdef WITH_THREADS #include <boost/thread.hpp> #include "moses/ThreadPool.h" #endif + #include <xmlrpc-c/base.hpp> #include <xmlrpc-c/registry.hpp> #include <xmlrpc-c/server_abyss.hpp> @@ -14,7 +15,6 @@ #include "Updater.h" #include "CloseSession.h" #include "Session.h" -#endif #include "moses/parameters/ServerOptions.h" namespace MosesServer @@ -23,13 +23,11 @@ namespace MosesServer { Moses::ServerOptions m_server_options; SessionCache m_session_cache; -#ifdef HAVE_XMLRPC_C xmlrpc_c::registry m_registry; xmlrpc_c::methodPtr const m_updater; xmlrpc_c::methodPtr const m_optimizer; xmlrpc_c::methodPtr const m_translator; xmlrpc_c::methodPtr const m_close_session; -#endif public: Server(Moses::Parameter& params); diff --git a/moses/server/TranslationRequest.cpp b/moses/server/TranslationRequest.cpp index 5f7841ce0..83463dcae 100644 --- a/moses/server/TranslationRequest.cpp +++ b/moses/server/TranslationRequest.cpp @@ -36,6 +36,17 @@ create(Translator* translator, xmlrpc_c::paramList const& paramList, } void +SetContextWeights(Moses::ContextScope& s, xmlrpc_c::value const& w) +{ + SPTR<std::map<std::string,float> > M(new std::map<std::string, float>); + typedef std::map<std::string,xmlrpc_c::value> tmap; + tmap const tmp = static_cast<tmap>(xmlrpc_c::value_struct(w)); + for(tmap::const_iterator m = tmp.begin(); m != tmp.end(); ++m) + (*M)[m->first] = xmlrpc_c::value_double(m->second); + s.SetContextWeights(M); +} + +void TranslationRequest:: Run() { @@ -55,8 +66,8 @@ Run() // settings within the session scope param_t::const_iterator si = params.find("context-weights"); - if (si != params.end()) m_scope->GetContextWeights(&si->second); - + if (si != params.end()) SetContextWeights(*m_scope, si->second); + Moses::StaticData const& SD = Moses::StaticData::Instance(); //Make sure alternative paths are retained, if necessary |