2015-08-07 21:17:37 +03:00
|
|
|
// -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
|
2015-08-05 04:15:34 +03:00
|
|
|
#include "CubePruningOptions.h"
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2015-12-08 15:28:35 +03:00
|
|
|
CubePruningOptions::
|
|
|
|
CubePruningOptions()
|
|
|
|
: pop_limit(DEFAULT_CUBE_PRUNING_POP_LIMIT)
|
|
|
|
, diversity(DEFAULT_CUBE_PRUNING_DIVERSITY)
|
|
|
|
, lazy_scoring(false)
|
|
|
|
, deterministic_search(false)
|
|
|
|
{}
|
|
|
|
|
2015-08-05 04:15:34 +03:00
|
|
|
bool
|
|
|
|
CubePruningOptions::
|
|
|
|
init(Parameter const& param)
|
|
|
|
{
|
|
|
|
param.SetParameter(pop_limit, "cube-pruning-pop-limit",
|
|
|
|
DEFAULT_CUBE_PRUNING_POP_LIMIT);
|
|
|
|
param.SetParameter(diversity, "cube-pruning-diversity",
|
|
|
|
DEFAULT_CUBE_PRUNING_DIVERSITY);
|
|
|
|
param.SetParameter(lazy_scoring, "cube-pruning-lazy-scoring", false);
|
2015-09-25 12:03:23 +03:00
|
|
|
param.SetParameter(deterministic_search, "cube-pruning-deterministic-search", false);
|
2015-08-05 04:15:34 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-07 21:17:37 +03:00
|
|
|
#ifdef HAVE_XMLRPC_C
|
|
|
|
bool
|
|
|
|
CubePruningOptions::
|
|
|
|
update(std::map<std::string,xmlrpc_c::value>const& params)
|
|
|
|
{
|
|
|
|
typedef std::map<std::string, xmlrpc_c::value> params_t;
|
|
|
|
|
|
|
|
params_t::const_iterator si = params.find("cube-pruning-pop-limit");
|
|
|
|
if (si != params.end()) pop_limit = xmlrpc_c::value_int(si->second);
|
|
|
|
|
|
|
|
si = params.find("cube-pruning-diversity");
|
|
|
|
if (si != params.end()) diversity = xmlrpc_c::value_int(si->second);
|
|
|
|
|
|
|
|
si = params.find("cube-pruning-lazy-scoring");
|
2015-09-25 12:03:23 +03:00
|
|
|
if (si != params.end())
|
2015-08-07 21:17:37 +03:00
|
|
|
{
|
2015-09-25 12:03:23 +03:00
|
|
|
std::string spec = xmlrpc_c::value_string(si->second);
|
|
|
|
if (spec == "true" or spec == "on" or spec == "1")
|
|
|
|
lazy_scoring = true;
|
|
|
|
else if (spec == "false" or spec == "off" or spec == "0")
|
|
|
|
lazy_scoring = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char const* msg
|
|
|
|
= "Error parsing specification for cube-pruning-lazy-scoring";
|
|
|
|
xmlrpc_c::fault(msg, xmlrpc_c::fault::CODE_PARSE);
|
|
|
|
}
|
2015-08-07 21:17:37 +03:00
|
|
|
}
|
2015-09-25 12:03:23 +03:00
|
|
|
|
|
|
|
si = params.find("cube-pruning-deterministic-search");
|
|
|
|
if (si != params.end())
|
|
|
|
{
|
|
|
|
std::string spec = xmlrpc_c::value_string(si->second);
|
|
|
|
if (spec == "true" or spec == "on" or spec == "1")
|
|
|
|
deterministic_search = true;
|
|
|
|
else if (spec == "false" or spec == "off" or spec == "0")
|
|
|
|
deterministic_search = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char const* msg
|
|
|
|
= "Error parsing specification for cube-pruning-deterministic-search";
|
|
|
|
xmlrpc_c::fault(msg, xmlrpc_c::fault::CODE_PARSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-07 21:17:37 +03:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-01 14:41:04 +03:00
|
|
|
#else
|
|
|
|
bool
|
|
|
|
CubePruningOptions::
|
|
|
|
update(std::map<std::string,xmlrpc_c::value>const& params)
|
|
|
|
{}
|
2015-08-07 21:17:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-08-05 04:15:34 +03:00
|
|
|
}
|