Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2014-11-28 20:15:01 +0300
committerHieu Hoang <hieuhoang@gmail.com>2014-11-28 20:15:01 +0300
commit79e1c12c1cc63a13ca18eba81fe975d79d5862c4 (patch)
tree4b4de651fc39cd6f59fae1cf32cd14910454cc2f
parente8cdbcd84b241711d5735f2a6ea3f9fed1bf0d7b (diff)
make GetParam() a const method with no side effect
-rw-r--r--moses/StaticData.cpp239
-rw-r--r--moses/StaticData.h2
-rw-r--r--moses/Util.h12
3 files changed, 130 insertions, 123 deletions
diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp
index de066413a..8736c94ad 100644
--- a/moses/StaticData.cpp
+++ b/moses/StaticData.cpp
@@ -138,19 +138,19 @@ bool StaticData::LoadData(Parameter *parameter)
m_factorDelimiter = "";
}
- SetBooleanParameter( &m_continuePartialTranslation, "continue-partial-translation", false );
- SetBooleanParameter( &m_outputHypoScore, "output-hypo-score", false );
+ SetBooleanParameter( m_continuePartialTranslation, "continue-partial-translation", false );
+ SetBooleanParameter( m_outputHypoScore, "output-hypo-score", false );
//word-to-word alignment
// alignments
- SetBooleanParameter( &m_PrintAlignmentInfo, "print-alignment-info", false );
+ SetBooleanParameter( m_PrintAlignmentInfo, "print-alignment-info", false );
if (m_PrintAlignmentInfo) {
m_needAlignmentInfo = true;
}
m_parameter->SetParameter(m_wordAlignmentSort, "sort-word-alignment", NoSort);
- SetBooleanParameter( &m_PrintAlignmentInfoNbest, "print-alignment-info-in-n-best", false );
+ SetBooleanParameter( m_PrintAlignmentInfoNbest, "print-alignment-info-in-n-best", false );
if (m_PrintAlignmentInfoNbest) {
m_needAlignmentInfo = true;
}
@@ -250,26 +250,26 @@ bool StaticData::LoadData(Parameter *parameter)
m_outputSearchGraphPB = false;
#endif
- SetBooleanParameter( &m_unprunedSearchGraph, "unpruned-search-graph", false );
- SetBooleanParameter( &m_includeLHSInSearchGraph, "include-lhs-in-search-graph", false );
+ SetBooleanParameter( m_unprunedSearchGraph, "unpruned-search-graph", false );
+ SetBooleanParameter( m_includeLHSInSearchGraph, "include-lhs-in-search-graph", 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 );
+ SetBooleanParameter( m_labeledNBestList, "labeled-n-best-list", true );
// include word alignment in the n-best list
- SetBooleanParameter( &m_nBestIncludesSegmentation, "include-segmentation-in-n-best", false );
+ SetBooleanParameter( m_nBestIncludesSegmentation, "include-segmentation-in-n-best", false );
// printing source phrase spans
- SetBooleanParameter( &m_reportSegmentation, "report-segmentation", false );
- SetBooleanParameter( &m_reportSegmentationEnriched, "report-segmentation-enriched", false );
+ SetBooleanParameter( m_reportSegmentation, "report-segmentation", false );
+ SetBooleanParameter( m_reportSegmentationEnriched, "report-segmentation-enriched", false );
// print all factors of output translations
- SetBooleanParameter( &m_reportAllFactors, "report-all-factors", false );
+ SetBooleanParameter( m_reportAllFactors, "report-all-factors", false );
// print all factors of output translations
- SetBooleanParameter( &m_reportAllFactorsNBest, "report-all-factors-in-n-best", false );
+ SetBooleanParameter( m_reportAllFactorsNBest, "report-all-factors-in-n-best", false );
//input factors
params = m_parameter->GetParam2("input-factors");
@@ -291,13 +291,13 @@ bool StaticData::LoadData(Parameter *parameter)
}
//source word deletion
- SetBooleanParameter( &m_wordDeletionEnabled, "phrase-drop-allowed", false );
+ SetBooleanParameter(m_wordDeletionEnabled, "phrase-drop-allowed", false );
//Disable discarding
- SetBooleanParameter(&m_disableDiscarding, "disable-discarding", false);
+ SetBooleanParameter(m_disableDiscarding, "disable-discarding", false);
//Print All Derivations
- SetBooleanParameter( &m_printAllDerivations , "print-all-derivations", false );
+ SetBooleanParameter(m_printAllDerivations , "print-all-derivations", false );
// additional output
m_parameter->SetParameter<string>(m_detailedTranslationReportingFilePath, "translation-details", "");
@@ -309,13 +309,14 @@ bool StaticData::LoadData(Parameter *parameter)
// reordering constraints
m_parameter->SetParameter(m_maxDistortion, "distortion-limit", -1);
- SetBooleanParameter( &m_reorderingConstraint, "monotone-at-punctuation", false );
+ SetBooleanParameter(m_reorderingConstraint, "monotone-at-punctuation", false );
// settings for pruning
m_parameter->SetParameter(m_maxHypoStackSize, "stack", DEFAULT_MAX_HYPOSTACK_SIZE);
m_minHypoStackDiversity = 0;
- if (m_parameter->GetParam("stack-diversity").size() > 0) {
+ params = m_parameter->GetParam2("stack-diversity");
+ if (params && params->size()) {
if (m_maxDistortion > 15) {
UserMessage::Add("stack diversity > 0 is not allowed for distortion limits larger than 15");
return false;
@@ -324,7 +325,7 @@ bool StaticData::LoadData(Parameter *parameter)
UserMessage::Add("stack diversity > 0 is not allowed for lattice input");
return false;
}
- m_parameter->SetParameter<size_t>(m_minHypoStackDiversity, "stack-diversity", 0);
+ m_minHypoStackDiversity = Scan<size_t>(params->at(0));
}
m_parameter->SetParameter(m_beamWidth, "beam-threshold", DEFAULT_BEAM_WIDTH);
@@ -333,99 +334,83 @@ bool StaticData::LoadData(Parameter *parameter)
m_parameter->SetParameter(m_earlyDiscardingThreshold, "early-discarding-threshold", DEFAULT_EARLY_DISCARDING_THRESHOLD);
m_earlyDiscardingThreshold = TransformScore(m_earlyDiscardingThreshold);
- m_translationOptionThreshold = (m_parameter->GetParam("translation-option-threshold").size() > 0) ?
- TransformScore(Scan<float>(m_parameter->GetParam("translation-option-threshold")[0]))
- : TransformScore(DEFAULT_TRANSLATION_OPTION_THRESHOLD);
-
- m_maxNoTransOptPerCoverage = (m_parameter->GetParam("max-trans-opt-per-coverage").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("max-trans-opt-per-coverage")[0]) : DEFAULT_MAX_TRANS_OPT_SIZE;
-
- m_maxNoPartTransOpt = (m_parameter->GetParam("max-partial-trans-opt").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("max-partial-trans-opt")[0]) : DEFAULT_MAX_PART_TRANS_OPT_SIZE;
-
- m_maxPhraseLength = (m_parameter->GetParam("max-phrase-length").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("max-phrase-length")[0]) : DEFAULT_MAX_PHRASE_LENGTH;
+ m_parameter->SetParameter(m_translationOptionThreshold, "translation-option-threshold", DEFAULT_TRANSLATION_OPTION_THRESHOLD);
+ m_translationOptionThreshold = TransformScore(m_translationOptionThreshold);
- m_cubePruningPopLimit = (m_parameter->GetParam("cube-pruning-pop-limit").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("cube-pruning-pop-limit")[0]) : DEFAULT_CUBE_PRUNING_POP_LIMIT;
+ m_parameter->SetParameter(m_maxNoTransOptPerCoverage, "max-trans-opt-per-coverage", DEFAULT_MAX_TRANS_OPT_SIZE);
+ m_parameter->SetParameter(m_maxNoPartTransOpt, "max-partial-trans-opt", DEFAULT_MAX_PART_TRANS_OPT_SIZE);
+ m_parameter->SetParameter(m_maxPhraseLength, "max-phrase-length", DEFAULT_MAX_PHRASE_LENGTH);
+ m_parameter->SetParameter(m_cubePruningPopLimit, "cube-pruning-pop-limit", DEFAULT_CUBE_PRUNING_POP_LIMIT);
+ m_parameter->SetParameter(m_cubePruningDiversity, "cube-pruning-diversity", DEFAULT_CUBE_PRUNING_DIVERSITY);
- m_cubePruningDiversity = (m_parameter->GetParam("cube-pruning-diversity").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("cube-pruning-diversity")[0]) : DEFAULT_CUBE_PRUNING_DIVERSITY;
-
- SetBooleanParameter(&m_cubePruningLazyScoring, "cube-pruning-lazy-scoring", false);
+ SetBooleanParameter(m_cubePruningLazyScoring, "cube-pruning-lazy-scoring", false);
// early distortion cost
- SetBooleanParameter( &m_useEarlyDistortionCost, "early-distortion-cost", false );
+ SetBooleanParameter(m_useEarlyDistortionCost, "early-distortion-cost", false );
// unknown word processing
- SetBooleanParameter( &m_dropUnknown, "drop-unknown", false );
- SetBooleanParameter( &m_markUnknown, "mark-unknown", false );
+ SetBooleanParameter(m_dropUnknown, "drop-unknown", false );
+ SetBooleanParameter(m_markUnknown, "mark-unknown", false );
- SetBooleanParameter( &m_lmEnableOOVFeature, "lmodel-oov-feature", false);
+ SetBooleanParameter(m_lmEnableOOVFeature, "lmodel-oov-feature", false);
// minimum Bayes risk decoding
- SetBooleanParameter( &m_mbr, "minimum-bayes-risk", false );
- m_mbrSize = (m_parameter->GetParam("mbr-size").size() > 0) ?
- Scan<size_t>(m_parameter->GetParam("mbr-size")[0]) : 200;
- m_mbrScale = (m_parameter->GetParam("mbr-scale").size() > 0) ?
- Scan<float>(m_parameter->GetParam("mbr-scale")[0]) : 1.0f;
+ SetBooleanParameter(m_mbr, "minimum-bayes-risk", false );
+ m_parameter->SetParameter<size_t>(m_mbrSize, "mbr-size", 200);
+ m_parameter->SetParameter(m_mbrScale, "mbr-scale", 1.0f);
//lattice mbr
- SetBooleanParameter( &m_useLatticeMBR, "lminimum-bayes-risk", false );
+ SetBooleanParameter(m_useLatticeMBR, "lminimum-bayes-risk", false );
if (m_useLatticeMBR && m_mbr) {
cerr << "Errror: Cannot use both n-best mbr and lattice mbr together" << endl;
- exit(1);
+ return false;
}
//mira training
- SetBooleanParameter( &m_mira, "mira", false );
+ SetBooleanParameter(m_mira, "mira", false );
// lattice MBR
if (m_useLatticeMBR) m_mbr = true;
- m_lmbrPruning = (m_parameter->GetParam("lmbr-pruning-factor").size() > 0) ?
- Scan<size_t>(m_parameter->GetParam("lmbr-pruning-factor")[0]) : 30;
- m_lmbrThetas = Scan<float>(m_parameter->GetParam("lmbr-thetas"));
- SetBooleanParameter( &m_useLatticeHypSetForLatticeMBR, "lattice-hypo-set", false );
- m_lmbrPrecision = (m_parameter->GetParam("lmbr-p").size() > 0) ?
- Scan<float>(m_parameter->GetParam("lmbr-p")[0]) : 0.8f;
- m_lmbrPRatio = (m_parameter->GetParam("lmbr-r").size() > 0) ?
- Scan<float>(m_parameter->GetParam("lmbr-r")[0]) : 0.6f;
- m_lmbrMapWeight = (m_parameter->GetParam("lmbr-map-weight").size() >0) ?
- Scan<float>(m_parameter->GetParam("lmbr-map-weight")[0]) : 0.0f;
+ m_parameter->SetParameter<size_t>(m_lmbrPruning, "lmbr-pruning-factor", 30);
+ m_parameter->SetParameter(m_lmbrPrecision, "lmbr-p", 0.8f);
+ m_parameter->SetParameter(m_lmbrPRatio, "lmbr-r", 0.6f);
+ m_parameter->SetParameter(m_lmbrMapWeight, "lmbr-map-weight", 0.0f);
+ SetBooleanParameter(m_useLatticeHypSetForLatticeMBR, "lattice-hypo-set", false );
+
+ params = m_parameter->GetParam2("lmbr-thetas");
+ if (params) {
+ m_lmbrThetas = Scan<float>(*params);
+ }
//consensus decoding
- SetBooleanParameter( &m_useConsensusDecoding, "consensus-decoding", false );
+ SetBooleanParameter(m_useConsensusDecoding, "consensus-decoding", false );
if (m_useConsensusDecoding && m_mbr) {
cerr<< "Error: Cannot use consensus decoding together with mbr" << endl;
exit(1);
}
if (m_useConsensusDecoding) m_mbr=true;
- SetBooleanParameter( &m_defaultNonTermOnlyForEmptyRange, "default-non-term-for-empty-range-only", false );
- SetBooleanParameter( &m_printNBestTrees, "n-best-trees", false );
+ SetBooleanParameter(m_defaultNonTermOnlyForEmptyRange, "default-non-term-for-empty-range-only", false );
+ SetBooleanParameter(m_printNBestTrees, "n-best-trees", false );
// S2T decoder
- SetBooleanParameter( &m_useS2TDecoder, "s2t", false );
- m_s2tParsingAlgorithm = (m_parameter->GetParam("s2t-parsing-algorithm").size() > 0) ?
- (S2TParsingAlgorithm) Scan<size_t>(m_parameter->GetParam("s2t-parsing-algorithm")[0]) : RecursiveCYKPlus;
+ SetBooleanParameter(m_useS2TDecoder, "s2t", false );
+ m_parameter->SetParameter(m_s2tParsingAlgorithm, "s2t-parsing-algorithm", RecursiveCYKPlus);
// Compact phrase table and reordering model
- SetBooleanParameter( &m_minphrMemory, "minphr-memory", false );
- SetBooleanParameter( &m_minlexrMemory, "minlexr-memory", false );
+ SetBooleanParameter(m_minphrMemory, "minphr-memory", false );
+ SetBooleanParameter(m_minlexrMemory, "minlexr-memory", false );
- m_timeout_threshold = (m_parameter->GetParam("time-out").size() > 0) ?
- Scan<size_t>(m_parameter->GetParam("time-out")[0]) : -1;
+ m_parameter->SetParameter<size_t>(m_timeout_threshold, "time-out", -1);
m_timeout = (GetTimeoutThreshold() == (size_t)-1) ? false : true;
-
- m_lmcache_cleanup_threshold = (m_parameter->GetParam("clean-lm-cache").size() > 0) ?
- Scan<size_t>(m_parameter->GetParam("clean-lm-cache")[0]) : 1;
+ m_parameter->SetParameter<size_t>(m_lmcache_cleanup_threshold, "clean-lm-cache", 1);
m_threadCount = 1;
- const std::vector<std::string> &threadInfo = m_parameter->GetParam("threads");
- if (!threadInfo.empty()) {
- if (threadInfo[0] == "all") {
+ params = m_parameter->GetParam2("threads");
+ if (params && params->size()) {
+ if (params->at(0) == "all") {
#ifdef WITH_THREADS
m_threadCount = boost::thread::hardware_concurrency();
if (!m_threadCount) {
@@ -437,14 +422,14 @@ bool StaticData::LoadData(Parameter *parameter)
return false;
#endif
} else {
- m_threadCount = Scan<int>(threadInfo[0]);
+ m_threadCount = Scan<int>(params->at(0));
if (m_threadCount < 1) {
UserMessage::Add("Specify at least one thread.");
return false;
}
#ifndef WITH_THREADS
if (m_threadCount > 1) {
- UserMessage::Add(std::string("Error: Thread count of ") + threadInfo[0] + " but moses not built with thread support");
+ UserMessage::Add(std::string("Error: Thread count of ") + params->at(0) + " but moses not built with thread support");
return false;
}
#endif
@@ -457,8 +442,9 @@ bool StaticData::LoadData(Parameter *parameter)
m_parameter->SetParameter<XmlInputType>(m_xmlInputType, "xml-input", XmlPassThrough);
// specify XML tags opening and closing brackets for XML option
- if (m_parameter->GetParam("xml-brackets").size() > 0) {
- std::vector<std::string> brackets = Tokenize(m_parameter->GetParam("xml-brackets")[0]);
+ params = m_parameter->GetParam2("xml-brackets");
+ if (params && params->size()) {
+ std::vector<std::string> brackets = Tokenize(params->at(0));
if(brackets.size()!=2) {
cerr << "invalid xml-brackets value, must specify exactly 2 blank-delimited strings for XML tags opening and closing brackets" << endl;
exit(1);
@@ -476,9 +462,9 @@ bool StaticData::LoadData(Parameter *parameter)
// all features
map<string, int> featureIndexMap;
- const vector<string> *features = m_parameter->GetParam2("feature");
- for (size_t i = 0; features && i < features->size(); ++i) {
- const string &line = Trim(features->at(i));
+ params = m_parameter->GetParam2("feature");
+ for (size_t i = 0; params && i < params->size(); ++i) {
+ const string &line = Trim(params->at(i));
VERBOSE(1,"line=" << line << endl);
if (line.empty())
continue;
@@ -532,7 +518,8 @@ bool StaticData::LoadData(Parameter *parameter)
LoadSparseWeightsFromConfig();
// alternate weight settings
- if (m_parameter->GetParam("alternate-weight-setting").size() > 0) {
+ params = m_parameter->GetParam2("alternate-weight-setting");
+ if (params && params->size()) {
if (!LoadAlternateWeightSettings()) {
return false;
}
@@ -540,22 +527,23 @@ bool StaticData::LoadData(Parameter *parameter)
return true;
}
-void StaticData::SetBooleanParameter( bool *parameter, string parameterName, bool defaultValue )
+void StaticData::SetBooleanParameter( bool &parameter, string parameterName, bool defaultValue )
{
+ const PARAM_VEC *params = m_parameter->GetParam2(parameterName);
+
// default value if nothing is specified
- *parameter = defaultValue;
- if (! m_parameter->isParamSpecified( parameterName ) ) {
+ parameter = defaultValue;
+ if (params == NULL) {
return;
}
// if parameter is just specified as, e.g. "-parameter" set it true
- if (m_parameter->GetParam( parameterName ).size() == 0) {
- *parameter = true;
+ if (params->size() == 0) {
+ parameter = true;
}
-
// if paramter is specified "-parameter true" or "-parameter false"
- else if (m_parameter->GetParam( parameterName ).size() == 1) {
- *parameter = Scan<bool>( m_parameter->GetParam( parameterName )[0]);
+ else if (params->size() == 1) {
+ parameter = Scan<bool>( params->at(0));
}
}
@@ -574,13 +562,7 @@ void StaticData::SetWeights(const FeatureFunction* sp, const std::vector<float>&
void StaticData::LoadNonTerminals()
{
string defaultNonTerminals;
-
- if (m_parameter->GetParam("non-terminals").size() == 0) {
- defaultNonTerminals = "X";
- } else {
- vector<std::string> tokens = Tokenize(m_parameter->GetParam("non-terminals")[0]);
- defaultNonTerminals = tokens[0];
- }
+ m_parameter->SetParameter<string>(defaultNonTerminals, "non-terminals", "X");
FactorCollection &factorCollection = FactorCollection::Instance();
@@ -592,12 +574,13 @@ void StaticData::LoadNonTerminals()
const Factor *targetFactor = factorCollection.AddFactor(Output, 0, defaultNonTerminals, true);
m_outputDefaultNonTerminal.SetFactor(0, targetFactor);
- // for unknwon words
- if (m_parameter->GetParam("unknown-lhs").size() == 0) {
+ // for unknown words
+ const PARAM_VEC *params = m_parameter->GetParam2("unknown-lhs");
+ if (params == NULL || params->size() == 0) {
UnknownLHSEntry entry(defaultNonTerminals, 0.0f);
m_unknownLHS.push_back(entry);
} else {
- const string &filePath = m_parameter->GetParam("unknown-lhs")[0];
+ const string &filePath = params->at(0);
InputFileStream inStream(filePath);
string line;
@@ -620,20 +603,28 @@ void StaticData::LoadChartDecodingParameters()
LoadNonTerminals();
// source label overlap
- if (m_parameter->GetParam("source-label-overlap").size() > 0) {
- m_sourceLabelOverlap = (SourceLabelOverlap) Scan<int>(m_parameter->GetParam("source-label-overlap")[0]);
- } else {
- m_sourceLabelOverlap = SourceLabelOverlapAdd;
- }
+ m_parameter->SetParameter(m_sourceLabelOverlap, "source-label-overlap", SourceLabelOverlapAdd);
+ m_parameter->SetParameter(m_ruleLimit, "rule-limit", DEFAULT_MAX_TRANS_OPT_SIZE);
- m_ruleLimit = (m_parameter->GetParam("rule-limit").size() > 0)
- ? Scan<size_t>(m_parameter->GetParam("rule-limit")[0]) : DEFAULT_MAX_TRANS_OPT_SIZE;
}
bool StaticData::LoadDecodeGraphs()
{
- const vector<string> &mappingVector = m_parameter->GetParam("mapping");
- const vector<size_t> &maxChartSpans = Scan<size_t>(m_parameter->GetParam("max-chart-span"));
+ vector<string> mappingVector;
+ vector<size_t> maxChartSpans;
+
+ const PARAM_VEC *params;
+
+ params = m_parameter->GetParam2("mapping");
+ if (params && params->size()) {
+ mappingVector = *params;
+ }
+
+ params = m_parameter->GetParam2("max-chart-span");
+ if (params && params->size()) {
+ maxChartSpans = Scan<size_t>(*params);
+ }
+
const vector<PhraseDictionary*>& pts = PhraseDictionary::GetColl();
const vector<GenerationDictionary*>& gens = GenerationDictionary::GetColl();
@@ -719,12 +710,12 @@ bool StaticData::LoadDecodeGraphs()
// set maximum n-gram size for backoff approach to decoding paths
// default is always use subsequent paths (value = 0)
// if specified, record maxmimum unseen n-gram size
- const vector<string> &backoffVector = m_parameter->GetParam("decoding-graph-backoff");
- for(size_t i=0; i<m_decodeGraphs.size() && i<backoffVector.size(); i++) {
+ const vector<string> *backoffVector = m_parameter->GetParam2("decoding-graph-backoff");
+ for(size_t i=0; i<m_decodeGraphs.size() && backoffVector && i<backoffVector->size(); i++) {
DecodeGraph &decodeGraph = *m_decodeGraphs[i];
- if (i < backoffVector.size()) {
- decodeGraph.SetBackoff(Scan<size_t>(backoffVector[i]));
+ if (i < backoffVector->size()) {
+ decodeGraph.SetBackoff(Scan<size_t>(backoffVector->at(i)));
}
}
@@ -986,7 +977,11 @@ bool StaticData::LoadAlternateWeightSettings()
return false;
}
- const vector<string> &weightSpecification = m_parameter->GetParam("alternate-weight-setting");
+ vector<string> weightSpecification;
+ const PARAM_VEC *params = m_parameter->GetParam2("alternate-weight-setting");
+ if (params && params->size()) {
+ weightSpecification = *params;
+ }
// get mapping from feature names to feature functions
map<string,FeatureFunction*> nameToFF;
@@ -1086,7 +1081,7 @@ bool StaticData::LoadAlternateWeightSettings()
void StaticData::NoCache()
{
bool noCache;
- SetBooleanParameter( &noCache, "no-cache", false );
+ SetBooleanParameter(noCache, "no-cache", false );
if (noCache) {
const std::vector<PhraseDictionary*> &pts = PhraseDictionary::GetColl();
@@ -1101,10 +1096,10 @@ std::map<std::string, std::string> StaticData::OverrideFeatureNames()
{
std::map<std::string, std::string> ret;
- const PARAM_VEC &params = m_parameter->GetParam("feature-name-overwrite");
- if (params.size()) {
- UTIL_THROW_IF2(params.size() != 1, "Only provide 1 line in the section [feature-name-overwrite]");
- vector<string> toks = Tokenize(params[0]);
+ const PARAM_VEC *params = m_parameter->GetParam2("feature-name-overwrite");
+ if (params && params->size()) {
+ UTIL_THROW_IF2(params->size() != 1, "Only provide 1 line in the section [feature-name-overwrite]");
+ vector<string> toks = Tokenize(params->at(0));
UTIL_THROW_IF2(toks.size() % 2 != 0, "Format of -feature-name-overwrite must be [old-name new-name]*");
for (size_t i = 0; i < toks.size(); i += 2) {
@@ -1128,9 +1123,9 @@ std::map<std::string, std::string> StaticData::OverrideFeatureNames()
void StaticData::OverrideFeatures()
{
- const PARAM_VEC &params = m_parameter->GetParam("feature-overwrite");
- for (size_t i = 0; i < params.size(); ++i) {
- const string &str = params[i];
+ const PARAM_VEC *params = m_parameter->GetParam2("feature-overwrite");
+ for (size_t i = 0; params && i < params->size(); ++i) {
+ const string &str = params->at(i);
vector<string> toks = Tokenize(str);
UTIL_THROW_IF2(toks.size() <= 1, "Incorrect format for feature override: " << str);
diff --git a/moses/StaticData.h b/moses/StaticData.h
index feb6c8c85..1a6cd6cf1 100644
--- a/moses/StaticData.h
+++ b/moses/StaticData.h
@@ -212,7 +212,7 @@ protected:
void LoadNonTerminals();
//! helper fn to set bool param from ini file/command line
- void SetBooleanParameter(bool *paramter, std::string parameterName, bool defaultValue);
+ void SetBooleanParameter(bool &paramter, std::string parameterName, bool defaultValue);
//! load decoding steps
bool LoadDecodeGraphs();
diff --git a/moses/Util.h b/moses/Util.h
index 8e8ccf34b..74a130b9e 100644
--- a/moses/Util.h
+++ b/moses/Util.h
@@ -121,6 +121,18 @@ inline SearchAlgorithm Scan<SearchAlgorithm>(const std::string &input)
}
template<>
+inline S2TParsingAlgorithm Scan<S2TParsingAlgorithm>(const std::string &input)
+{
+ return (S2TParsingAlgorithm) Scan<size_t>(input);
+}
+
+template<>
+inline SourceLabelOverlap Scan<SourceLabelOverlap>(const std::string &input)
+{
+ return (SourceLabelOverlap) Scan<size_t>(input);
+}
+
+template<>
inline XmlInputType Scan<XmlInputType>(const std::string &input)
{
XmlInputType ret;