diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-28 00:09:05 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-28 00:09:05 +0300 |
commit | 5b826611637386472d0aead46c8963f1b9ab475e (patch) | |
tree | beb23a324758f0680113b10acf42759acf9ff577 | |
parent | cafd01854d243e4e36568e81c6081ac5857535fa (diff) |
make GetParam() a const method with no side effect
-rw-r--r-- | moses/Parameter.cpp | 2 | ||||
-rw-r--r-- | moses/StaticData.cpp | 50 |
2 files changed, 8 insertions, 44 deletions
diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index 08a0f6684..369c222af 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -104,7 +104,7 @@ Parameter::Parameter() AddParam("output-search-graph", "osg", "Output connected hypotheses of search into specified filename"); AddParam("output-search-graph-extended", "osgx", "Output connected hypotheses of search into specified filename, in extended format"); AddParam("unpruned-search-graph", "usg", "When outputting chart search graph, do not exclude dead ends. Note: stack pruning may have eliminated some hypotheses"); - AddParam("output-search-graph-slf", "slf", "Output connected hypotheses of search into specified directory, one file per sentence, in HTK standard lattice format (SLF) - the flag should be followed byy a directory name, which must exist"); + AddParam("output-search-graph-slf", "slf", "Output connected hypotheses of search into specified directory, one file per sentence, in HTK standard lattice format (SLF) - the flag should be followed by a directory name, which must exist"); AddParam("output-search-graph-hypergraph", "Output connected hypotheses of search into specified directory, one file per sentence, in a hypergraph format (see Kenneth Heafield's lazy hypergraph decoder). This flag is followed by 3 values: 'true (gz|txt|bz) directory-name'"); AddParam("include-lhs-in-search-graph", "lhssg", "When outputting chart search graph, include the label of the LHS of the rule (useful when using syntax)"); #ifdef HAVE_PROTOBUF diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index 0172575b5..6e6e0495a 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -58,8 +58,6 @@ StaticData StaticData::s_instance; StaticData::StaticData() :m_sourceStartPosMattersForRecombination(false) ,m_inputType(SentenceInput) - ,m_detailedTranslationReportingFilePath() - ,m_detailedTreeFragmentsTranslationReportingFilePath() ,m_onlyDistinctNBest(false) ,m_needAlignmentInfo(false) ,m_lmEnableOOVFeature(false) @@ -240,15 +238,7 @@ bool StaticData::LoadData(Parameter *parameter) SetBooleanParameter( &m_unprunedSearchGraph, "unpruned-search-graph", false ); SetBooleanParameter( &m_includeLHSInSearchGraph, "include-lhs-in-search-graph", false ); - if (m_parameter->isParamSpecified("output-unknowns")) { - - if (m_parameter->GetParam("output-unknowns").size() == 1) { - m_outputUnknownsFile =Scan<string>(m_parameter->GetParam("output-unknowns")[0]); - } else { - UserMessage::Add(string("need to specify exactly one file name for unknowns")); - return false; - } - } + m_parameter->SetParameter<string>(m_outputUnknownsFile, "output-unknowns", ""); // include feature names in the n-best list SetBooleanParameter( &m_labeledNBestList, "labeled-n-best-list", true ); @@ -296,45 +286,19 @@ bool StaticData::LoadData(Parameter *parameter) SetBooleanParameter( &m_printAllDerivations , "print-all-derivations", false ); // additional output - if (m_parameter->isParamSpecified("translation-details")) { - const vector<string> &args = m_parameter->GetParam("translation-details"); - if (args.size() == 1) { - m_detailedTranslationReportingFilePath = args[0]; - } else { - UserMessage::Add(string("the translation-details option requires exactly one filename argument")); - return false; - } - } - if (m_parameter->isParamSpecified("tree-translation-details")) { - const vector<string> &args = m_parameter->GetParam("tree-translation-details"); - if (args.size() == 1) { - m_detailedTreeFragmentsTranslationReportingFilePath = args[0]; - } else { - UserMessage::Add(string("the tree-translation-details option requires exactly one filename argument")); - return false; - } - } + m_parameter->SetParameter<string>(m_detailedTranslationReportingFilePath, "translation-details", ""); + m_parameter->SetParameter<string>(m_detailedTreeFragmentsTranslationReportingFilePath, "tree-translation-details", ""); //DIMw - if (m_parameter->isParamSpecified("translation-all-details")) { - const vector<string> &args = m_parameter->GetParam("translation-all-details"); - if (args.size() == 1) { - m_detailedAllTranslationReportingFilePath = args[0]; - } else { - UserMessage::Add(string("the translation-all-details option requires exactly one filename argument")); - return false; - } - } + m_parameter->SetParameter<string>(m_detailedAllTranslationReportingFilePath, "translation-all-details", ""); // reordering constraints - m_maxDistortion = (m_parameter->GetParam("distortion-limit").size() > 0) ? - Scan<int>(m_parameter->GetParam("distortion-limit")[0]) - : -1; + m_parameter->SetParameter(m_maxDistortion, "distortion-limit", -1); + SetBooleanParameter( &m_reorderingConstraint, "monotone-at-punctuation", false ); // settings for pruning - m_maxHypoStackSize = (m_parameter->GetParam("stack").size() > 0) - ? Scan<size_t>(m_parameter->GetParam("stack")[0]) : DEFAULT_MAX_HYPOSTACK_SIZE; + m_parameter->SetParameter(m_maxHypoStackSize, "stack", DEFAULT_MAX_HYPOSTACK_SIZE); m_minHypoStackDiversity = 0; if (m_parameter->GetParam("stack-diversity").size() > 0) { |