#include <Parameter.h>
Public Member Functions | |
Parameter () | |
~Parameter () | |
bool | LoadParam (int argc, char const *argv[]) |
bool | LoadParam (const std::string &filePath) |
void | Explain () |
const PARAM_VEC * | GetParam (const std::string ¶mName) const |
bool | isParamSpecified (const std::string ¶mName) const |
void | OverwriteParam (const std::string ¶mName, PARAM_VEC values) |
std::vector< float > | GetWeights (const std::string &name) |
const std::map< std::string, std::vector< float > > & | GetAllWeights () const |
std::set< std::string > | GetWeightNames () const |
const PARAM_MAP & | GetParams () const |
void | Save (const std::string path) |
template<typename T > | |
void | SetParameter (T &var, const std::string &name, const T &defaultValue) const |
void | SetParameter (bool &var, std::string const &name) |
bool | SetBooleanSwitch (bool &val, std::string const name) |
template<> | |
void | SetParameter (bool ¶meter, std::string const ¶meterName, bool const &defaultValue) const |
template<> | |
void | SetParameter (bool &var, const std::string &name, const bool &defaultValue) const |
Protected Member Functions | |
std::string | FindParam (const std::string ¶mSwitch, int argc, char const *argv[]) |
void | OverwriteParam (const std::string ¶mSwitch, const std::string ¶mName, int argc, char const *argv[]) |
bool | ReadConfigFile (const std::string &filePath) |
bool | FilesExist (const std::string ¶mName, int fieldNo, std::vector< std::string > const &fileExtension=std::vector< std::string >(1,"")) |
bool | isOption (const char *token) |
bool | Validate () |
void | AddParam (options_description &optgroup, value_semantic const *optvalue, std::string const ¶mName, std::string const &description) |
void | AddParam (options_description &optgroup, std::string const ¶mName, std::string const &description) |
void | AddParam (options_description &optgroup, value_semantic const *optvalue, std::string const ¶mName, std::string const &abbrevName, std::string const &description) |
void | AddParam (options_description &optgroup, std::string const ¶mName, std::string const &abbrevName, std::string const &description) |
void | PrintCredit () |
void | PrintFF () const |
void | SetWeight (const std::string &name, size_t ind, float weight) |
void | SetWeight (const std::string &name, size_t ind, const std::vector< float > &weights) |
void | AddWeight (const std::string &name, size_t ind, const std::vector< float > &weights) |
void | ConvertWeightArgs () |
void | ConvertWeightArgsSingleWeight (const std::string &oldWeightName, const std::string &newWeightName) |
void | ConvertWeightArgsPhraseModel (const std::string &oldWeightName) |
void | ConvertWeightArgsLM () |
void | ConvertWeightArgsDistortion () |
void | ConvertWeightArgsGeneration (const std::string &oldWeightName, const std::string &newWeightName) |
void | ConvertWeightArgsPhrasePenalty () |
void | ConvertWeightArgsWordPenalty () |
void | ConvertPhrasePenalty () |
void | CreateWeightsMap () |
void | CreateWeightsMap (const PARAM_VEC &vec) |
void | WeightOverwrite () |
void | AddFeature (const std::string &line) |
void | AddFeaturesCmd () |
Protected Attributes | |
PARAM_MAP | m_setting |
PARAM_BOOL | m_valid |
PARAM_STRING | m_abbreviation |
PARAM_STRING | m_description |
PARAM_STRING | m_fullname |
options_description | m_options |
std::map< std::string, std::vector< float > > | m_weights |
Definition at line 44 of file Parameter.h.
Parameter::Parameter | ( | ) |
define allowed parameters
Definition at line 50 of file Parameter.cpp.
References AddParam(), and m_options.
Parameter::~Parameter | ( | ) |
Definition at line 361 of file Parameter.cpp.
void Parameter::AddFeature | ( | const std::string & | line | ) | [protected] |
Definition at line 867 of file Parameter.cpp.
References m_setting.
Referenced by AddFeaturesCmd(), ConvertPhrasePenalty(), ConvertWeightArgs(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), and ConvertWeightArgsLM().
void Parameter::AddFeaturesCmd | ( | ) | [protected] |
Definition at line 603 of file Parameter.cpp.
References AddFeature(), GetParam(), m_setting, and params.
Referenced by LoadParam().
void Moses::Parameter::AddParam | ( | options_description & | optgroup, | |
std::string const & | paramName, | |||
std::string const & | abbrevName, | |||
std::string const & | description | |||
) | [protected] |
void Moses::Parameter::AddParam | ( | options_description & | optgroup, | |
value_semantic const * | optvalue, | |||
std::string const & | paramName, | |||
std::string const & | abbrevName, | |||
std::string const & | description | |||
) | [protected] |
void Moses::Parameter::AddParam | ( | options_description & | optgroup, | |
std::string const & | paramName, | |||
std::string const & | description | |||
) | [protected] |
void Moses::Parameter::AddParam | ( | options_description & | optgroup, | |
value_semantic const * | optvalue, | |||
std::string const & | paramName, | |||
std::string const & | description | |||
) | [protected] |
void Parameter::AddWeight | ( | const std::string & | name, | |
size_t | ind, | |||
const std::vector< float > & | weights | |||
) | [protected] |
Definition at line 653 of file Parameter.cpp.
References m_setting, SetWeight(), and Moses::SPrint().
void Parameter::ConvertPhrasePenalty | ( | ) | [protected] |
Definition at line 1116 of file Parameter.cpp.
References AddFeature(), GetParam(), m_setting, SetWeight(), and UTIL_THROW_IF2.
Referenced by ConvertWeightArgs().
void Parameter::ConvertWeightArgs | ( | ) | [protected] |
Definition at line 1133 of file Parameter.cpp.
References AddFeature(), ConvertPhrasePenalty(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), ConvertWeightArgsLM(), ConvertWeightArgsPhraseModel(), ConvertWeightArgsSingleWeight(), ConvertWeightArgsWordPenalty(), m_setting, and UTIL_THROW_IF2.
Referenced by LoadParam().
void Parameter::ConvertWeightArgsDistortion | ( | ) | [protected] |
Definition at line 875 of file Parameter.cpp.
References AddFeature(), GetParam(), m_setting, NULL, SetWeight(), util::StringStream::str(), Moses::Tokenize(), Moses::Trim(), and UTIL_THROW_IF2.
Referenced by ConvertWeightArgs().
void Parameter::ConvertWeightArgsGeneration | ( | const std::string & | oldWeightName, | |
const std::string & | newWeightName | |||
) | [protected] |
Definition at line 1037 of file Parameter.cpp.
References AddFeature(), m_setting, SetWeight(), util::StringStream::str(), Moses::Tokenize(), and UTIL_THROW_IF2.
Referenced by ConvertWeightArgs().
void Parameter::ConvertWeightArgsLM | ( | ) | [protected] |
Definition at line 942 of file Parameter.cpp.
References AddFeature(), GetParam(), m_setting, NULL, SetWeight(), Moses::SPrint(), Moses::Tokenize(), Moses::Trim(), Moses::UntransformLMScore(), UTIL_THROW2, and UTIL_THROW_IF2.
Referenced by ConvertWeightArgs().
void Moses::Parameter::ConvertWeightArgsPhraseModel | ( | const std::string & | oldWeightName | ) | [protected] |
void Moses::Parameter::ConvertWeightArgsPhrasePenalty | ( | ) | [protected] |
void Moses::Parameter::ConvertWeightArgsSingleWeight | ( | const std::string & | oldWeightName, | |
const std::string & | newWeightName | |||
) | [protected] |
void Parameter::ConvertWeightArgsWordPenalty | ( | ) | [protected] |
Definition at line 1081 of file Parameter.cpp.
References GetParam(), m_setting, NULL, SetWeight(), and Moses::Trim().
Referenced by ConvertWeightArgs().
void Parameter::CreateWeightsMap | ( | const PARAM_VEC & | vec | ) | [protected] |
Definition at line 1185 of file Parameter.cpp.
References m_weights, Moses::Tokenize(), and UTIL_THROW_IF2.
void Parameter::CreateWeightsMap | ( | ) | [protected] |
Definition at line 1177 of file Parameter.cpp.
References m_setting.
Referenced by LoadParam().
void Parameter::Explain | ( | ) |
print descriptions of all parameters
Definition at line 412 of file Parameter.cpp.
References m_options.
Referenced by LoadParam(), and main().
bool Moses::Parameter::FilesExist | ( | const std::string & | paramName, | |
int | fieldNo, | |||
std::vector< std::string > const & | fileExtension = std::vector< std::string >(1,"") | |||
) | [protected] |
std::string Moses::Parameter::FindParam | ( | const std::string & | paramSwitch, | |
int | argc, | |||
char const * | argv[] | |||
) | [protected] |
const std::map<std::string, std::vector<float> >& Moses::Parameter::GetAllWeights | ( | ) | const [inline] |
Definition at line 132 of file Parameter.h.
References m_weights.
Referenced by Moses::StaticData::LoadSparseWeightsFromConfig().
const PARAM_VEC * Parameter::GetParam | ( | const std::string & | paramName | ) | const |
return a vector of strings holding the whitespace-delimited values on the ini-file line corresponding to the given parameter name
Definition at line 365 of file Parameter.cpp.
References m_setting, and NULL.
Referenced by AddFeaturesCmd(), ConvertPhrasePenalty(), ConvertWeightArgsDistortion(), ConvertWeightArgsLM(), ConvertWeightArgsWordPenalty(), decoder_main(), Moses::Manager::GetWordGraph(), Moses::StaticData::ini_performance_options(), Moses::ReportingOptions::init(), Moses::NBestOptions::init(), Moses::LMBR_Options::init(), Moses::InputOptions::init(), Moses::BookkeepingOptions::init(), Moses::StaticData::initialize_features(), Moses::IOWrapper::IOWrapper(), Moses::StaticData::LoadAlternateWeightSettings(), Moses::StaticData::LoadData(), Moses::StaticData::LoadDecodeGraphs(), Moses::StaticData::LoadDecodeGraphsNew(), Moses::StaticData::LoadNonTerminals(), Moses::SyntaxOptions::LoadNonTerminals(), LoadParam(), Moses::StaticData::OverrideFeatureNames(), Moses::StaticData::OverrideFeatures(), run_as_server(), SetBooleanSwitch(), and SetParameter().
const PARAM_MAP& Moses::Parameter::GetParams | ( | ) | const [inline] |
std::set< std::string > Parameter::GetWeightNames | ( | ) | const |
Definition at line 1616 of file Parameter.cpp.
References key, and m_weights.
Referenced by Moses::StaticData::CheckWeights().
std::vector< float > Parameter::GetWeights | ( | const std::string & | name | ) |
Definition at line 619 of file Parameter.cpp.
References m_weights.
Referenced by Moses::FeatureFactory::DefaultSetup().
bool Parameter::isOption | ( | const char * | token | ) | [protected] |
check whether an item on the command line is a switch or a value
token | token on the command line to checked |
Definition at line 434 of file Parameter.cpp.
References starts_with().
Referenced by LoadParam().
bool Moses::Parameter::isParamSpecified | ( | const std::string & | paramName | ) | const [inline] |
check if parameter is defined (either in moses.ini or as switch)
Definition at line 125 of file Parameter.h.
References m_setting.
Referenced by batch_run(), decoder_main(), and main().
bool Moses::Parameter::LoadParam | ( | const std::string & | filePath | ) |
bool Parameter::LoadParam | ( | int | argc, | |
char const * | xargv[] | |||
) |
load all parameters from the configuration file and the command line switches
Definition at line 486 of file Parameter.cpp.
References AddFeaturesCmd(), ConvertWeightArgs(), CreateWeightsMap(), Explain(), FindParam(), GetParam(), isOption(), m_abbreviation, m_description, m_setting, m_valid, NULL, OverwriteParam(), PrintCredit(), PrintFF(), ReadConfigFile(), Moses::show_version(), TRACE_ERR, UTIL_THROW, Validate(), verbose, and WeightOverwrite().
Referenced by decoder_main(), and main().
void Moses::Parameter::OverwriteParam | ( | const std::string & | paramName, | |
PARAM_VEC | values | |||
) |
void Moses::Parameter::OverwriteParam | ( | const std::string & | paramSwitch, | |
const std::string & | paramName, | |||
int | argc, | |||
char const * | argv[] | |||
) | [protected] |
void Parameter::PrintCredit | ( | ) | [protected] |
Definition at line 1494 of file Parameter.cpp.
Referenced by LoadParam().
void Parameter::PrintFF | ( | ) | const [protected] |
Definition at line 1609 of file Parameter.cpp.
References Moses::StaticData::GetFeatureRegistry(), Moses::StaticData::Instance(), and Moses::FeatureRegistry::PrintFF().
Referenced by LoadParam().
bool Moses::Parameter::ReadConfigFile | ( | const std::string & | filePath | ) | [protected] |
void Parameter::Save | ( | const std::string | path | ) |
bool Moses::Parameter::SetBooleanSwitch | ( | bool & | val, | |
std::string const | name | |||
) | [inline] |
Definition at line 155 of file Parameter.h.
References GetParam(), params, and TRACE_ERR.
void Moses::Parameter::SetParameter | ( | bool & | var, | |
const std::string & | name, | |||
const bool & | defaultValue | |||
) | const [inline] |
void Moses::Parameter::SetParameter | ( | bool & | parameter, | |
std::string const & | parameterName, | |||
bool const & | defaultValue | |||
) | const [inline] |
void Parameter::SetParameter | ( | bool & | var, | |
std::string const & | name | |||
) |
Definition at line 1680 of file Parameter.cpp.
References SetParameter().
void Moses::Parameter::SetParameter | ( | T & | var, | |
const std::string & | name, | |||
const T & | defaultValue | |||
) | const [inline] |
Definition at line 144 of file Parameter.h.
References GetParam(), and params.
Referenced by batch_run(), Moses::SyntaxOptions::init(), Moses::ServerOptions::init(), Moses::SearchOptions::init(), Moses::ReportingOptions::init(), Moses::ReorderingOptions::init(), Moses::OOVHandlingOptions::init(), Moses::NBestOptions::init(), Moses::MBR_Options::init(), Moses::LMBR_Options::init(), Moses::InputOptions::init(), Moses::CubePruningOptions::init(), Moses::ContextParameters::init(), Moses::BookkeepingOptions::init(), Moses::AllOptions::init(), Moses::IOWrapper::IOWrapper(), Moses::StaticData::LoadChartDecodingParameters(), Moses::StaticData::LoadData(), Moses::StaticData::LoadNonTerminals(), Moses::SyntaxOptions::LoadNonTerminals(), main(), Moses::StaticData::NoCache(), SetParameter(), Moses::PhraseDictionaryCompact::SetStaticDefaultParameters(), and Moses::LexicalReorderingTableCompact::SetStaticDefaultParameters().
void Moses::Parameter::SetWeight | ( | const std::string & | name, | |
size_t | ind, | |||
const std::vector< float > & | weights | |||
) | [protected] |
void Parameter::SetWeight | ( | const std::string & | name, | |
size_t | ind, | |||
float | weight | |||
) | [protected] |
Definition at line 633 of file Parameter.cpp.
References m_setting, and Moses::SPrint().
Referenced by AddWeight(), ConvertPhrasePenalty(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), ConvertWeightArgsLM(), and ConvertWeightArgsWordPenalty().
bool Parameter::Validate | ( | ) | [protected] |
check that parameter settings make sense
Definition at line 1266 of file Parameter.cpp.
References Moses::FileExists(), FilesExist(), key, m_setting, and m_valid.
Referenced by LoadParam().
void Parameter::WeightOverwrite | ( | ) | [protected] |
Definition at line 1207 of file Parameter.cpp.
References m_setting, m_weights, NULL, Moses::Tokenize(), and UTIL_THROW_IF2.
Referenced by LoadParam().
PARAM_STRING Moses::Parameter::m_abbreviation [protected] |
PARAM_STRING Moses::Parameter::m_description [protected] |
PARAM_STRING Moses::Parameter::m_fullname [protected] |
Definition at line 53 of file Parameter.h.
options_description Moses::Parameter::m_options [protected] |
PARAM_MAP Moses::Parameter::m_setting [protected] |
Definition at line 49 of file Parameter.h.
Referenced by AddFeature(), AddFeaturesCmd(), AddWeight(), ConvertPhrasePenalty(), ConvertWeightArgs(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), ConvertWeightArgsLM(), ConvertWeightArgsWordPenalty(), CreateWeightsMap(), GetParam(), GetParams(), isParamSpecified(), LoadParam(), Save(), SetWeight(), Validate(), and WeightOverwrite().
PARAM_BOOL Moses::Parameter::m_valid [protected] |
std::map<std::string, std::vector<float> > Moses::Parameter::m_weights [protected] |
Definition at line 58 of file Parameter.h.
Referenced by CreateWeightsMap(), GetAllWeights(), GetWeightNames(), GetWeights(), and WeightOverwrite().