diff options
author | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2015-02-09 16:52:05 +0300 |
---|---|---|
committer | Matthias Huck <huck@i6.informatik.rwth-aachen.de> | 2015-02-09 16:52:05 +0300 |
commit | 53ce063214d9c942847ddf7b2b7e3b43f2f882b6 (patch) | |
tree | e60928d34625b259fd8e3582b664d8a4d1c93373 /moses/Parameter.cpp | |
parent | ce80e53b30f766ab85cb58c4a2d06742b4a4f38b (diff) |
tuneable-components config parameter for feature functions
Diffstat (limited to 'moses/Parameter.cpp')
-rw-r--r-- | moses/Parameter.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index c5677b73b..0289eebff 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -970,11 +970,13 @@ void Parameter::WeightOverwrite() // should only be on 1 line UTIL_THROW_IF2(vec.size() != 1, - "Weight override should only be on 1 line"); + "weight-overwrite should only be on 1 line"); string name(""); vector<float> weights; vector<string> toks = Tokenize(vec[0]); + size_t cnt = 0; + const std::vector<float>* oldWeights = NULL; for (size_t i = 0; i < toks.size(); ++i) { const string &tok = toks[i]; @@ -988,10 +990,24 @@ void Parameter::WeightOverwrite() } name = tok.substr(0, tok.size() - 1); + std::map<std::string, std::vector<float> >::const_iterator found = m_weights.find(name); + if (found!=m_weights.end()) { + oldWeights = &(found->second); + } else { + oldWeights = NULL; + } + cnt = 0; } else { // a weight for curr ff - float weight = Scan<float>(toks[i]); - weights.push_back(weight); + if (toks[i] == "x") { + UTIL_THROW_IF2(!oldWeights || cnt>=oldWeights->size(), + "Keeping previous weight failed in weight-overwrite"); + weights.push_back(oldWeights->at(cnt)); + } else { + float weight = Scan<float>(toks[i]); + weights.push_back(weight); + } + ++cnt; } } |