diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-28 13:26:41 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-28 13:26:41 +0300 |
commit | 6a2e6feeed434966ba72adc9f26d7b3496070b87 (patch) | |
tree | e5d391f97ac84817851f906e85a3eed5a6cd7c97 /moses/ContextScope.h | |
parent | 50c109699618ef4372ba78c4e3bf7e788c6a0884 (diff) |
Context weights now live in the ContextScope, not any more on TranslationTask.
TargetPhrase now has weak ptr to ContextScope, not to TranslationTask any more,
because TargetPhrases can outlive the scope of a Translation Task.
Diffstat (limited to 'moses/ContextScope.h')
-rw-r--r-- | moses/ContextScope.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/moses/ContextScope.h b/moses/ContextScope.h index 18880db13..5a0d4feba 100644 --- a/moses/ContextScope.h +++ b/moses/ContextScope.h @@ -124,7 +124,24 @@ public: return m_context_weights; } #endif - + + bool + SetContextWeights(std::string const& spec) { + if (m_context_weights) return false; + boost::unique_lock<boost::shared_mutex> lock(m_lock); + m_context_weights.reset(new std::map<std::string, float>); + + // TO DO; This needs to be done with StringPiece.find, not Tokenize + // PRIORITY: low + std::vector<std::string> tokens = Tokenize(spec,":"); + for (std::vector<std::string>::iterator it = tokens.begin(); + it != tokens.end(); it++) { + std::vector<std::string> key_and_value = Tokenize(*it, ","); + (*m_context_weights)[key_and_value[0]] = atof(key_and_value[1].c_str()); + } + return true; + } + }; }; |