diff options
author | Lane Schwartz <dowobeha@gmail.com> | 2017-01-02 23:22:26 +0300 |
---|---|---|
committer | Lane Schwartz <dowobeha@gmail.com> | 2017-01-02 23:22:26 +0300 |
commit | a18b6676b1aecd60973d1a4a81abc995ba1b9fe0 (patch) | |
tree | 2cb3cf6d3cca76368a1b0ec5937bd7a94d12e03d /moses/TranslationModel | |
parent | 76a8850487fade594e44034f803a999225d1783e (diff) |
Allow user to specify whether PhraseDictionaryMemoryPerSentenceOnDemand are probability values or not
Diffstat (limited to 'moses/TranslationModel')
-rw-r--r-- | moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.cpp | 10 | ||||
-rw-r--r-- | moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.cpp b/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.cpp index 4675d06c8..072e482de 100644 --- a/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.cpp +++ b/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.cpp @@ -8,7 +8,7 @@ using namespace std; namespace Moses { PhraseDictionaryMemoryPerSentenceOnDemand::PhraseDictionaryMemoryPerSentenceOnDemand(const std::string &line) - : PhraseDictionary(line, true) + : PhraseDictionary(line, true), m_valuesAreProbabilities(true) { ReadParameters(); } @@ -67,8 +67,10 @@ void PhraseDictionaryMemoryPerSentenceOnDemand::InitializeForInput(ttasksptr con // score for this phrase table vector<float> scores = Tokenize<float>(toks[2]); - std::transform(scores.begin(), scores.end(), scores.begin(),TransformScore); - std::transform(scores.begin(), scores.end(), scores.begin(),FloorScore); + if (m_valuesAreProbabilities) { + std::transform(scores.begin(), scores.end(), scores.begin(),TransformScore); + std::transform(scores.begin(), scores.end(), scores.begin(),FloorScore); + } target->GetScoreBreakdown().PlusEquals(this, scores); // score of all other ff when this rule is being loaded @@ -129,6 +131,8 @@ PhraseDictionaryMemoryPerSentenceOnDemand::SetParameter(const std::string& key, { if (key == "path") { UTIL_THROW(util::Exception, "PhraseDictionaryMemoryPerSentenceOnDemand does not support key \"path\"."); + } else if (key == "valuesAreProbabilities") { + m_valuesAreProbabilities = Scan<bool>(value); } else { PhraseDictionary::SetParameter(key, value); } diff --git a/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.h b/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.h index bcda0ef77..e3fe6514a 100644 --- a/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.h +++ b/moses/TranslationModel/PhraseDictionaryMemoryPerSentenceOnDemand.h @@ -39,6 +39,8 @@ protected: typedef boost::unordered_map<Phrase, TargetPhraseCollection::shared_ptr> Coll; mutable boost::thread_specific_ptr<Coll> m_coll; + bool m_valuesAreProbabilities; + Coll &GetColl() const; }; |