diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-21 02:56:29 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-21 02:56:29 +0300 |
commit | 06a516842d9618c1d8e30759facb15c97d87b15a (patch) | |
tree | 5942125014b0f4f211a9083e01b7635582f6577a /moses/ContextScope.h | |
parent | 08b8157042330141a8e7ae6e8274d15e111ef6ac (diff) |
Moses server now accepts context weights as translation request parameters.
Diffstat (limited to 'moses/ContextScope.h')
-rw-r--r-- | moses/ContextScope.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/moses/ContextScope.h b/moses/ContextScope.h index e1173cbdc..fd869ef0e 100644 --- a/moses/ContextScope.h +++ b/moses/ContextScope.h @@ -12,6 +12,15 @@ #include <boost/foreach.hpp> #endif +// for some reason, the xmlrpc_c headers must be included AFTER the +// boost thread-related ones ... +#ifdef HAVE_XMLRPC_C +#include <xmlrpc-c/base.hpp> +#include <xmlrpc-c/registry.hpp> +#include <xmlrpc-c/server_abyss.hpp> +#endif + + #include <map> #include <boost/shared_ptr.hpp> // #include "thread_safe_container.h" @@ -29,6 +38,7 @@ protected: #ifdef WITH_THREADS mutable boost::shared_mutex m_lock; #endif + SPTR<std::map<std::string,float> > m_context_weights; public: // class write_access // { @@ -99,6 +109,24 @@ public: m_scratchpad = other.m_scratchpad; } +#ifdef HAVE_XMLRPC_C + SPTR<std::map<std::string,float> > + GetContextWeights(xmlrpc_c::value const* spec = NULL) + { + if (spec && m_context_weights == NULL) + { + boost::unique_lock<boost::shared_mutex> lock(m_lock); + m_context_weights.reset(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(*spec)); + for(tmap::const_iterator m = tmp.begin(); m != tmp.end(); ++m) + (*m_context_weights)[m->first] = xmlrpc_c::value_double(m->second); + } + return m_context_weights; + } +#endif + }; }; |