diff options
author | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-03-09 03:30:01 +0300 |
---|---|---|
committer | Ulrich Germann <ugermann@inf.ed.ac.uk> | 2015-03-09 03:30:01 +0300 |
commit | c1d2313a661c5d995ceb6c5e0acc7c3971243395 (patch) | |
tree | 29a7844d2a07652b72243f7ba94725add5f61b1c /moses/TranslationOption.cpp | |
parent | ddea89312e0fa7017094f1061ca4a15091ab467d (diff) |
Moved caching of lexical reordering scores from class TranslationOption to class TargetPhrase.
This was done so that phrase tables can add this information (if available) as extra annotation
to TargetPhrases, in preparation of providing lexical reordering models with sampling phrase tables.
Diffstat (limited to 'moses/TranslationOption.cpp')
-rw-r--r-- | moses/TranslationOption.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/moses/TranslationOption.cpp b/moses/TranslationOption.cpp index ecd9e7f0e..610df63f7 100644 --- a/moses/TranslationOption.cpp +++ b/moses/TranslationOption.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "GenerationDictionary.h" #include "StaticData.h" #include "InputType.h" +#include "moses/FF/LexicalReordering/LexicalReordering.h" using namespace std; @@ -35,8 +36,7 @@ TranslationOption::TranslationOption() :m_targetPhrase(NULL) ,m_inputPath(NULL) ,m_sourceWordsRange(NOT_FOUND, NOT_FOUND) -{ -} +{ } //TODO this should be a factory function! TranslationOption::TranslationOption(const WordsRange &wordsRange @@ -66,9 +66,14 @@ bool TranslationOption::Overlap(const Hypothesis &hypothesis) const return bitmap.Overlap(GetSourceWordsRange()); } -void TranslationOption::CacheLexReorderingScores(const LexicalReordering &producer, const Scores &score) +void +TranslationOption:: +CacheLexReorderingScores(const LexicalReordering &producer, const Scores &score) { - m_lexReorderingScores[&producer] = score; + if (score.empty()) return; + boost::shared_ptr<Scores> stored(new Scores(score)); + m_targetPhrase.SetExtraScores(&producer,stored); + // m_lexReorderingScores[&producer] = score; } void TranslationOption::EvaluateWithSourceContext(const InputType &input) @@ -104,6 +109,19 @@ ostream& operator<<(ostream& out, const TranslationOption& possibleTranslation) return out; } + /** returns cached scores */ +const Scores* +TranslationOption:: +GetLexReorderingScores(LexicalReordering const* scoreProducer) const +{ + return m_targetPhrase.GetExtraScores(scoreProducer); + // _ScoreCacheMap::const_iterator it; + // it = m_lexReorderingScores.find(scoreProducer); + // if(it == m_lexReorderingScores.end()) + // return NULL; + // else + // return &(it->second); +} } |