Change parameters only when specified during parameter updates in server mode.

This commit is contained in:
Ulrich Germann 2015-11-23 16:59:39 +00:00
parent 6f1e39d64e
commit a074efc7cc
4 changed files with 9 additions and 5 deletions

View File

@ -43,7 +43,7 @@ update(std::map<std::string,xmlrpc_c::value>const& param)
params_t::const_iterator si = param.find("nbest");
if (si != param.end())
nbest_size = xmlrpc_c::value_int(si->second);
only_distinct = check(param, "nbest-distinct");
only_distinct = check(param, "nbest-distinct", only_distinct);
enabled = (nbest_size > 0);
return true;
}

View File

@ -1,5 +1,7 @@
// -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*-
#include "OptionsBaseClass.h"
#include "moses/Util.h"
namespace Moses {
#ifdef HAVE_XMLRPC_C
@ -15,10 +17,12 @@ namespace Moses {
bool
OptionsBaseClass::
check(std::map<std::string, xmlrpc_c::value> const& param,
std::string const key)
std::string const key, bool dfltval)
{
std::map<std::string, xmlrpc_c::value>::const_iterator m;
return (param.find(key) != param.end());
m = param.find(key);
if (m == param.end()) return dfltval;
return Scan<bool>(xmlrpc_c::value_string(m->second));
}
#endif
}

View File

@ -13,6 +13,6 @@ namespace Moses
#endif
bool
check(std::map<std::string, xmlrpc_c::value> const& param,
std::string const key);
std::string const key, bool dfltval);
};
}

View File

@ -75,7 +75,7 @@ namespace Moses {
ReportingOptions::
update(std::map<std::string, xmlrpc_c::value>const& param)
{
ReportAllFactors = check(param, "report-all-factors");
ReportAllFactors = check(param, "report-all-factors", ReportAllFactors);
return true;
}
#endif