diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-07-03 17:30:33 +0300 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-07-03 17:30:33 +0300 |
commit | 98c03dc04767bebd4db889ffdacede80bed6c108 (patch) | |
tree | c1f31cc2e77dc85b245f9981254543dd3a25f564 /moses/TranslationTask.cpp | |
parent | f78bb4a6e93297d56408e085b9311e1c23aa548c (diff) | |
parent | 9dae3eb78520b7d574c8415a4fbebd84e37383bd (diff) |
Merge branch 'mmt-dev' into ranked-sampling.
Conflicts:
moses/TranslationModel/UG/mm/ug_bitext.h
moses/TranslationModel/UG/mm/ug_bitext_jstats.cc
moses/TranslationModel/UG/mm/ug_bitext_jstats.h
moses/TranslationModel/UG/mm/ug_bitext_pstats.cc
moses/TranslationModel/UG/mm/ug_sampling_bias.cc
moses/TranslationModel/UG/mm/ug_sampling_bias.h
Diffstat (limited to 'moses/TranslationTask.cpp')
-rw-r--r-- | moses/TranslationTask.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/moses/TranslationTask.cpp b/moses/TranslationTask.cpp index bf0228b14..ad3e3bb56 100644 --- a/moses/TranslationTask.cpp +++ b/moses/TranslationTask.cpp @@ -30,6 +30,19 @@ TranslationTask return m_context_string; } +std::map<std::string, float> const& +TranslationTask::GetContextWeights() const +{ + return m_context_weights; +} + +void +TranslationTask +::ReSetContextWeights(std::map<std::string, float> const& new_weights) +{ + m_context_weights = new_weights; +} + void TranslationTask ::SetContextString(std::string const& context) @@ -37,6 +50,16 @@ TranslationTask m_context_string = context; } +void +TranslationTask +::SetContextWeights(std::string const& context_weights) +{ + std::vector<std::string> tokens = Tokenize(context_weights,":"); + 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.insert(std::pair<std::string, float>(key_and_value[0], atof(key_and_value[1].c_str()))); + } +} boost::shared_ptr<TranslationTask> |