diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2014-06-02 21:18:17 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2014-06-02 21:18:17 +0400 |
commit | 39ef678b32d4646e8c0914bba759d2cbf530d2b8 (patch) | |
tree | f719827c8296c1a3bfbc9b29d8c22a20e218302a /moses/Parameter.cpp | |
parent | 40d5a9873349939f2a7e99d9a8df8408dd518ba4 (diff) | |
parent | 31a583b0bc322626356a42965f02534249070525 (diff) |
Merge ../mosesdecoder into hieu
Diffstat (limited to 'moses/Parameter.cpp')
-rw-r--r-- | moses/Parameter.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index fa9b3802f..10ac56627 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -191,6 +191,7 @@ Parameter::Parameter() AddParam("weight", "weights for ALL models, 1 per line 'WeightName value'. Weight names can be repeated"); AddParam("weight-overwrite", "special parameter for mert. All on 1 line. Overrides weights specified in 'weights' argument"); AddParam("feature-overwrite", "Override arguments in a particular feature function with a particular key. Format: -feature-overwrite \"FeatureName key=value\""); + AddParam("weight-add", "Add weight for FF if it doesn't exist, i.e weights here are added 1st, and can be override by the ini file or on the command line. Used to specify initial weights for FF that was also specified on the copmmand line"); AddParam("feature-add", "Add a feature function on the command line. Used by mira to add BLEU feature"); AddParam("feature-name-overwrite", "Override feature name (NOT arguments). Eg. SRILM-->KENLM, PhraseDictionaryMemory-->PhraseDictionaryScope3"); @@ -902,24 +903,28 @@ void Parameter::ConvertWeightArgs() void Parameter::CreateWeightsMap() { - PARAM_VEC &vec = m_setting["weight"]; - for (size_t i = 0; i < vec.size(); ++i) { - const string &line = vec[i]; - vector<string> toks = Tokenize(line); - UTIL_THROW_IF2(toks.size() < 2, - "Error in format of weights: " << line); - - string name = toks[0]; - name = name.substr(0, name.size() - 1); + CreateWeightsMap(m_setting["weight-add"]); + CreateWeightsMap(m_setting["weight"]); +} - vector<float> weights(toks.size() - 1); - for (size_t i = 1; i < toks.size(); ++i) { - float weight = Scan<float>(toks[i]); - weights[i - 1] = weight; - } - m_weights[name] = weights; +void Parameter::CreateWeightsMap(const PARAM_VEC &vec) +{ + for (size_t i = 0; i < vec.size(); ++i) { + const string &line = vec[i]; + vector<string> toks = Tokenize(line); + UTIL_THROW_IF2(toks.size() < 2, + "Error in format of weights: " << line); + + string name = toks[0]; + name = name.substr(0, name.size() - 1); + + vector<float> weights(toks.size() - 1); + for (size_t i = 1; i < toks.size(); ++i) { + float weight = Scan<float>(toks[i]); + weights[i - 1] = weight; + } + m_weights[name] = weights; } - } void Parameter::WeightOverwrite() |