diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-30 23:15:15 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-30 23:15:15 +0300 |
commit | 46e7aebce49d4f769c41e144472dd6c6c7881b62 (patch) | |
tree | c26a7fa771c3762cc7f704d9cb6230d8dcca642e /moses/Parameter.cpp | |
parent | b2c0fa097c1484db538b39d7c981c7037479a8c2 (diff) |
move SetBooleanParameter to Parameter class. Make it a specialized version of template SetParameter
Diffstat (limited to 'moses/Parameter.cpp')
-rw-r--r-- | moses/Parameter.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index 54b940f15..4fe477a39 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -1389,6 +1389,27 @@ void Parameter::Save(const std::string path) file.close(); } +template<> +void Parameter::SetParameter<bool>(bool ¶meter, const std::string ¶meterName, const bool &defaultValue) const +{ + const PARAM_VEC *params = GetParam(parameterName); + + // default value if nothing is specified + parameter = defaultValue; + if (params == NULL) { + return; + } + + // if parameter is just specified as, e.g. "-parameter" set it true + if (params->size() == 0) { + parameter = true; + } + // if paramter is specified "-parameter true" or "-parameter false" + else if (params->size() == 1) { + parameter = Scan<bool>( params->at(0)); + } } +} // namespace + |