Moses::Parameter Class Reference

#include <Parameter.h>

List of all members.

Public Member Functions

 Parameter ()
 ~Parameter ()
bool LoadParam (int argc, char *argv[])
bool LoadParam (const std::string &filePath)
void Explain ()
const PARAM_VECGetParam (const std::string &paramName) const
bool isParamSpecified (const std::string &paramName) const
void OverwriteParam (const std::string &paramName, PARAM_VEC values)
std::vector< float > GetWeights (const std::string &name)
std::map< std::string,
std::vector< float > > 
GetAllWeights () const
std::set< std::string > GetWeightNames () const
const PARAM_MAPGetParams () const
void Save (const std::string path)
template<typename T >
void SetParameter (T &var, const std::string &name, const T &defaultValue) const
template<>
void SetParameter (bool &parameter, std::string const &parameterName, 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 &paramSwitch, int argc, char *argv[])
void OverwriteParam (const std::string &paramSwitch, const std::string &paramName, int argc, char *argv[])
bool ReadConfigFile (const std::string &filePath)
bool FilesExist (const std::string &paramName, 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 &paramName, std::string const &description)
void AddParam (options_description &optgroup, std::string const &paramName, std::string const &description)
void AddParam (options_description &optgroup, value_semantic const *optvalue, std::string const &paramName, std::string const &abbrevName, std::string const &description)
void AddParam (options_description &optgroup, std::string const &paramName, 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


Detailed Description

Handles parameter values set in config file or on command line. Process raw parameter data (names and values as strings) for StaticData to parse; to get useful values, see StaticData.

Definition at line 44 of file Parameter.h.


Constructor & Destructor Documentation

Parameter::Parameter (  ) 

define allowed parameters

Definition at line 46 of file Parameter.cpp.

References AddParam(), and m_options.

Here is the call graph for this function:

Parameter::~Parameter (  ) 

Definition at line 334 of file Parameter.cpp.


Member Function Documentation

void Parameter::AddFeature ( const std::string &  line  )  [protected]

Definition at line 805 of file Parameter.cpp.

References m_setting.

Referenced by AddFeaturesCmd(), ConvertPhrasePenalty(), ConvertWeightArgs(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), and ConvertWeightArgsLM().

Here is the caller graph for this function:

void Parameter::AddFeaturesCmd (  )  [protected]

Definition at line 541 of file Parameter.cpp.

References AddFeature(), GetParam(), m_setting, and params.

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:

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]

Referenced by Parameter().

Here is the caller graph for this function:

void Parameter::AddWeight ( const std::string &  name,
size_t  ind,
const std::vector< float > &  weights 
) [protected]

Definition at line 591 of file Parameter.cpp.

References m_setting, SetWeight(), and Moses::SPrint().

Here is the call graph for this function:

void Parameter::ConvertPhrasePenalty (  )  [protected]

Definition at line 1053 of file Parameter.cpp.

References AddFeature(), GetParam(), m_setting, SetWeight(), and UTIL_THROW_IF2.

Referenced by ConvertWeightArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::ConvertWeightArgs (  )  [protected]

void Parameter::ConvertWeightArgsDistortion (  )  [protected]

Definition at line 813 of file Parameter.cpp.

References AddFeature(), GetParam(), m_setting, NULL, SetWeight(), Moses::Tokenize(), Moses::Trim(), and UTIL_THROW_IF2.

Referenced by ConvertWeightArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::ConvertWeightArgsGeneration ( const std::string &  oldWeightName,
const std::string &  newWeightName 
) [protected]

Definition at line 974 of file Parameter.cpp.

References AddFeature(), m_setting, SetWeight(), Moses::Tokenize(), and UTIL_THROW_IF2.

Referenced by ConvertWeightArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::ConvertWeightArgsLM (  )  [protected]

Definition at line 880 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Parameter::ConvertWeightArgsPhraseModel ( const std::string &  oldWeightName  )  [protected]

Referenced by ConvertWeightArgs().

Here is the caller graph for this function:

void Moses::Parameter::ConvertWeightArgsPhrasePenalty (  )  [protected]

void Moses::Parameter::ConvertWeightArgsSingleWeight ( const std::string &  oldWeightName,
const std::string &  newWeightName 
) [protected]

Referenced by ConvertWeightArgs().

Here is the caller graph for this function:

void Parameter::ConvertWeightArgsWordPenalty (  )  [protected]

Definition at line 1018 of file Parameter.cpp.

References GetParam(), m_setting, NULL, SetWeight(), and Moses::Trim().

Referenced by ConvertWeightArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::CreateWeightsMap ( const PARAM_VEC vec  )  [protected]

Definition at line 1122 of file Parameter.cpp.

References m_weights, Moses::Tokenize(), and UTIL_THROW_IF2.

Here is the call graph for this function:

void Parameter::CreateWeightsMap (  )  [protected]

Definition at line 1114 of file Parameter.cpp.

References m_setting.

Referenced by LoadParam().

Here is the caller graph for this function:

void Parameter::Explain (  ) 

print descriptions of all parameters

Definition at line 385 of file Parameter.cpp.

References m_options.

Referenced by LoadParam(), and main().

Here is the caller graph for this function:

bool Moses::Parameter::FilesExist ( const std::string &  paramName,
int  fieldNo,
std::vector< std::string > const &  fileExtension = std::vector< std::string >(1,"") 
) [protected]

Referenced by Validate().

Here is the caller graph for this function:

std::string Moses::Parameter::FindParam ( const std::string &  paramSwitch,
int  argc,
char *  argv[] 
) [protected]

Referenced by LoadParam().

Here is the caller graph for this function:

std::map<std::string, std::vector<float> > Moses::Parameter::GetAllWeights (  )  const [inline]

Definition at line 131 of file Parameter.h.

References m_weights.

Referenced by Moses::StaticData::LoadSparseWeightsFromConfig().

Here is the caller graph for this function:

const PARAM_VEC * Parameter::GetParam ( const std::string &  paramName  )  const

const PARAM_MAP& Moses::Parameter::GetParams (  )  const [inline]

Definition at line 136 of file Parameter.h.

References m_setting.

std::set< std::string > Parameter::GetWeightNames (  )  const

Definition at line 1552 of file Parameter.cpp.

References key, and m_weights.

Referenced by Moses::StaticData::CheckWeights().

Here is the caller graph for this function:

std::vector< float > Parameter::GetWeights ( const std::string &  name  ) 

Definition at line 557 of file Parameter.cpp.

References m_weights.

Referenced by Moses::FeatureFactory::DefaultSetup().

Here is the caller graph for this function:

bool Parameter::isOption ( const char *  token  )  [protected]

check whether an item on the command line is a switch or a value

Parameters:
token token on the command line to checked

Definition at line 407 of file Parameter.cpp.

References starts_with().

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:

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 124 of file Parameter.h.

References m_setting.

Referenced by batch_run(), decoder_main(), and main().

Here is the caller graph for this function:

bool Moses::Parameter::LoadParam ( const std::string &  filePath  ) 

bool Parameter::LoadParam ( int  argc,
char *  xargv[] 
)

load all parameters from the configuration file and the command line switches

Definition at line 430 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(), TRACE_ERR, UTIL_THROW, Validate(), verbose, and WeightOverwrite().

Referenced by decoder_main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

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 *  argv[] 
) [protected]

Referenced by LoadParam().

Here is the caller graph for this function:

void Parameter::PrintCredit (  )  [protected]

Definition at line 1430 of file Parameter.cpp.

References NULL, and sort().

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::PrintFF (  )  const [protected]

Definition at line 1545 of file Parameter.cpp.

References Moses::StaticData::GetFeatureRegistry(), Moses::StaticData::Instance(), and Moses::FeatureRegistry::PrintFF().

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::Parameter::ReadConfigFile ( const std::string &  filePath  )  [protected]

Referenced by LoadParam().

Here is the caller graph for this function:

void Parameter::Save ( const std::string  path  ) 

Definition at line 1565 of file Parameter.cpp.

References m_setting.

template<>
void Moses::Parameter::SetParameter ( bool &  var,
const std::string &  name,
const bool &  defaultValue 
) const [inline]

template<>
void Moses::Parameter::SetParameter ( bool &  parameter,
std::string const &  parameterName,
bool const &  defaultValue 
) const [inline]

template<typename T >
void Moses::Parameter::SetParameter ( T var,
const std::string &  name,
const T defaultValue 
) const [inline]

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 571 of file Parameter.cpp.

References m_setting, and Moses::SPrint().

Referenced by AddWeight(), ConvertPhrasePenalty(), ConvertWeightArgsDistortion(), ConvertWeightArgsGeneration(), ConvertWeightArgsLM(), and ConvertWeightArgsWordPenalty().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Parameter::Validate (  )  [protected]

check that parameter settings make sense

Definition at line 1203 of file Parameter.cpp.

References Moses::FileExists(), FilesExist(), key, m_setting, and m_valid.

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:

void Parameter::WeightOverwrite (  )  [protected]

Definition at line 1144 of file Parameter.cpp.

References m_setting, m_weights, NULL, Moses::Tokenize(), and UTIL_THROW_IF2.

Referenced by LoadParam().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 51 of file Parameter.h.

Referenced by LoadParam().

Definition at line 52 of file Parameter.h.

Referenced by LoadParam().

Definition at line 53 of file Parameter.h.

options_description Moses::Parameter::m_options [protected]

Definition at line 56 of file Parameter.h.

Referenced by Explain(), and Parameter().

Definition at line 50 of file Parameter.h.

Referenced by LoadParam(), and Validate().

std::map<std::string, std::vector<float> > Moses::Parameter::m_weights [protected]


The documentation for this class was generated from the following files:

Generated on Thu Jul 2 00:33:30 2015 for Moses by  doxygen 1.5.9