Set defaults in option group constructors.

This commit is contained in:
Ulrich Germann 2015-12-08 12:28:35 +00:00
parent c1a008bf6d
commit 9528b56242
20 changed files with 148 additions and 33 deletions

View File

@ -2,6 +2,7 @@
namespace Moses
{
bool
BookkeepingOptions::
init(Parameter const& P)
@ -15,4 +16,10 @@ init(Parameter const& P)
}
return true;
}
BookkeepingOptions::
BookkeepingOptions()
: need_alignment_info(false)
{ }
}

View File

@ -9,6 +9,7 @@ namespace Moses
{
bool need_alignment_info;
bool init(Parameter const& param);
BookkeepingOptions();
};

View File

@ -4,6 +4,14 @@
namespace Moses
{
CubePruningOptions::
CubePruningOptions()
: pop_limit(DEFAULT_CUBE_PRUNING_POP_LIMIT)
, diversity(DEFAULT_CUBE_PRUNING_DIVERSITY)
, lazy_scoring(false)
, deterministic_search(false)
{}
bool
CubePruningOptions::
init(Parameter const& param)

View File

@ -16,7 +16,7 @@ namespace Moses
bool init(Parameter const& param);
CubePruningOptions(Parameter const& param);
CubePruningOptions() {};
CubePruningOptions();
bool
update(std::map<std::string,xmlrpc_c::value>const& params);

View File

@ -9,10 +9,15 @@ namespace Moses {
InputOptions::
InputOptions()
: continue_partial_translation(false)
, default_non_term_only_for_empty_range(false)
, input_type(SentenceInput)
, xml_policy(XmlPassThrough)
, placeholder_factor(NOT_FOUND)
{
xml_brackets.first = "<";
xml_brackets.second = ">";
input_type = SentenceInput;
factor_order.assign(1,0);
}
bool

View File

@ -3,6 +3,16 @@
namespace Moses {
LMBR_Options::
LMBR_Options()
: enabled(false)
, use_lattice_hyp_set(false)
, precision(0.8f)
, ratio(0.6f)
, map_weight(0.8f)
, pruning_factor(30)
{ }
bool
LMBR_Options::
init(Parameter const& param)
@ -20,5 +30,8 @@ namespace Moses {
return true;
}
}

View File

@ -19,7 +19,7 @@ namespace Moses
size_t pruning_factor; //! average number of nodes per word wanted in pruned lattice
std::vector<float> theta; //! theta(s) for lattice mbr calculation
bool init(Parameter const& param);
LMBR_Options() {}
LMBR_Options();
};
}

View File

@ -3,14 +3,22 @@
namespace Moses {
bool
MBR_Options::
init(Parameter const& param)
{
param.SetParameter(enabled, "minimum-bayes-risk", false);
param.SetParameter<size_t>(size, "mbr-size", 200);
param.SetParameter(scale, "mbr-scale", 1.0f);
return true;
}
MBR_Options::
MBR_Options()
: enabled(false)
, size(200)
, scale(1.0f)
{}
bool
MBR_Options::
init(Parameter const& param)
{
param.SetParameter(enabled, "minimum-bayes-risk", false);
param.SetParameter<size_t>(size, "mbr-size", 200);
param.SetParameter(scale, "mbr-scale", 1.0f);
return true;
}
}

View File

@ -13,9 +13,9 @@ namespace Moses
bool enabled;
size_t size; //! number of translation candidates considered
float scale; /*! scaling factor for computing marginal probability
* of candidate translation */
* of candidate translation */
bool init(Parameter const& param);
MBR_Options() {}
MBR_Options();
};
}

View File

@ -5,6 +5,21 @@
namespace Moses
{
NBestOptions::
NBestOptions()
: nbest_size(0)
, factor(20)
, enabled(false)
, print_trees(false)
, only_distinct(false)
, include_alignment_info(false)
, include_feature_labels(true)
, include_segmentation(false)
, include_passthrough(false)
, include_all_factors(false)
{}
bool
NBestOptions::
init(Parameter const& P)

View File

@ -25,7 +25,8 @@ struct NBestOptions : public OptionsBaseClass
bool init(Parameter const& param);
bool update(std::map<std::string,xmlrpc_c::value>const& param);
NBestOptions();
};
}

View File

@ -3,6 +3,14 @@
namespace Moses {
ReorderingOptions::
ReorderingOptions()
: max_distortion(-1)
, monotone_at_punct(false)
, use_early_distortion_cost(false)
{}
ReorderingOptions::
ReorderingOptions(Parameter const& param)
{

View File

@ -14,7 +14,7 @@ namespace Moses
bool use_early_distortion_cost;
bool init(Parameter const& param);
ReorderingOptions(Parameter const& param);
ReorderingOptions() {}
ReorderingOptions();
};
}

View File

@ -4,6 +4,26 @@
namespace Moses {
using namespace std;
ReportingOptions::
ReportingOptions()
: ReportAllFactors(false)
, ReportSegmentation(0)
, PrintAlignmentInfo(false)
, PrintAllDerivations(false)
, PrintTranslationOptions(false)
, WA_SortOrder(NoSort)
, WordGraph(false)
, DontPruneSearchGraph(false)
, RecoverPath(false)
, ReportHypoScore(false)
, PrintID(false)
, PrintPassThrough(false)
, lattice_sample_size(0)
{
factor_order.assign(1,0);
}
bool
ReportingOptions::
init(Parameter const& param)
@ -21,16 +41,16 @@ namespace Moses {
param.SetParameter(WA_SortOrder, "sort-word-alignment", NoSort);
std::string e; // hack to save us param.SetParameter<string>(...)
param.SetParameter(AlignmentOutputFile,"alignment-output-file", e);
param.SetParameter(PrintAllDerivations, "print-all-derivations", false);
param.SetParameter(PrintTranslationOptions, "print-translation-option", false);
// output a word graph
PARAM_VEC const* params;
params = param.GetParam("output-word-graph");
WordGraph = (params && params->size() == 2); // what are the two options?
// dump the search graph
param.SetParameter(SearchGraph, "output-search-graph", e);
param.SetParameter(SearchGraphExtended, "output-search-graph-extended", e);
@ -39,7 +59,7 @@ namespace Moses {
#ifdef HAVE_PROTOBUF
param.SetParameter(SearchGraphPB, "output-search-graph-pb", e);
#endif
param.SetParameter(DontPruneSearchGraph, "unpruned-search-graph", false);
@ -63,8 +83,6 @@ namespace Moses {
std::cerr <<"wrong format for switch -lattice-samples file size";
return false;
}
} else {
lattice_sample_size = 0;
}
params= param.GetParam("output-factors");
@ -81,7 +99,7 @@ namespace Moses {
return true;
}
#ifdef HAVE_XMLRPC_C
bool
ReportingOptions::
@ -121,5 +139,4 @@ namespace Moses {
return true;
}
#endif
}

View File

@ -38,9 +38,6 @@ namespace Moses
bool PrintID;
bool PrintPassThrough;
// print ..
bool aln_info; // m_PrintAlignmentInfo;
// transrep = translation reporting
std::string detailed_transrep_filepath;
std::string detailed_tree_transrep_filepath;
@ -59,7 +56,10 @@ namespace Moses
#ifdef HAVE_XMLRPC_C
bool update(std::map<std::string, xmlrpc_c::value>const& param);
#endif
};
ReportingOptions();
};
}

View File

@ -3,6 +3,23 @@
namespace Moses
{
SearchOptions::
SearchOptions()
: algo(Normal)
, stack_size(DEFAULT_MAX_HYPOSTACK_SIZE)
, stack_diversity(0)
, disable_discarding(false)
, max_phrase_length(DEFAULT_MAX_PHRASE_LENGTH)
, max_trans_opt_per_cov(DEFAULT_MAX_TRANS_OPT_SIZE)
, max_partial_trans_opt(DEFAULT_MAX_PART_TRANS_OPT_SIZE)
, beam_width(DEFAULT_BEAM_WIDTH)
, timeout(0)
, consensus(false)
, early_discarding_threshold(DEFAULT_EARLY_DISCARDING_THRESHOLD)
, trans_opt_threshold(DEFAULT_TRANSLATION_OPTION_THRESHOLD)
{ }
SearchOptions::
SearchOptions(Parameter const& param)
: stack_diversity(0)

View File

@ -37,7 +37,7 @@ namespace Moses
bool init(Parameter const& param);
SearchOptions(Parameter const& param);
SearchOptions() {}
SearchOptions();
bool
UseEarlyDiscarding() const {

View File

@ -34,6 +34,20 @@ parse_timespec(std::string const& spec)
return timeout;
}
ServerOptions::
ServerOptions()
: is_serial(false)
, numThreads(15) // why 15?
, sessionTimeout(1800) // = 30 min
, sessionCacheSize(25)
, port(8080)
, maxConn(15)
, maxConnBacklog(15)
, keepaliveTimeout(15)
, keepaliveMaxConn(30)
, timeout(15)
{ }
ServerOptions::
ServerOptions(Parameter const& P)
{

View File

@ -24,6 +24,7 @@ namespace Moses
bool init(Parameter const& param);
ServerOptions(Parameter const& param);
ServerOptions();
};
}

View File

@ -9,8 +9,8 @@ namespace Moses {
SyntaxOptions::
SyntaxOptions()
{
}
: s2t_parsing_algo(RecursiveCYKPlus)
{ }
bool
SyntaxOptions::