diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-08 14:28:31 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-08 14:28:31 +0400 |
commit | a1b2f66d91a3bb2122674f727e257ed256d9f729 (patch) | |
tree | 3444c8d7670ead653bec883eeac5efeb7692fc62 /moses/DecodeStepTranslation.cpp | |
parent | 8a371f65474ca8c242bbee833579a77a306ec153 (diff) |
each new target phrase in factored decomposition holds scores from previous steps.
Diffstat (limited to 'moses/DecodeStepTranslation.cpp')
-rw-r--r-- | moses/DecodeStepTranslation.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp index ad00c51b1..5424a07e8 100644 --- a/moses/DecodeStepTranslation.cpp +++ b/moses/DecodeStepTranslation.cpp @@ -34,19 +34,6 @@ DecodeStepTranslation::DecodeStepTranslation(const PhraseDictionary* pdf, const { } - -TranslationOption *DecodeStepTranslation::MergeTranslation(const TranslationOption& oldTO, const TargetPhrase &targetPhrase) const -{ - if (IsFilteringStep()) { - if (!oldTO.IsCompatible(targetPhrase, m_conflictFactors)) return 0; - } - - TranslationOption *newTransOpt = new TranslationOption(oldTO); - newTransOpt->MergeNewFeatures(targetPhrase, targetPhrase.GetScoreBreakdown(), m_newOutputFactors); - return newTransOpt; -} - - void DecodeStepTranslation::Process(const TranslationSystem* system , const TranslationOption &inputPartialTranslOpt , const DecodeStep &decodeStep @@ -66,7 +53,8 @@ void DecodeStepTranslation::Process(const TranslationSystem* system const WordsRange &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange(); const PhraseDictionary* phraseDictionary = decodeStep.GetPhraseDictionaryFeature(); - const size_t currSize = inputPartialTranslOpt.GetTargetPhrase().GetSize(); + const TargetPhrase &inPhrase = inputPartialTranslOpt.GetTargetPhrase(); + const size_t currSize = inPhrase.GetSize(); const size_t tableLimit = phraseDictionary->GetTableLimit(); const TargetPhraseCollection *phraseColl= @@ -78,13 +66,27 @@ void DecodeStepTranslation::Process(const TranslationSystem* system for (iterTargetPhrase = phraseColl->begin(); iterTargetPhrase != iterEnd; ++iterTargetPhrase) { const TargetPhrase& targetPhrase = **iterTargetPhrase; + const ScoreComponentCollection &transScores = targetPhrase.GetScoreBreakdown(); // skip if the if (targetPhrase.GetSize() != currSize) continue; - TranslationOption *newTransOpt = MergeTranslation(inputPartialTranslOpt, targetPhrase); - if (newTransOpt != NULL) { - outputPartialTranslOptColl.Add(system, newTransOpt ); + TargetPhrase outPhrase(inPhrase); + + if (IsFilteringStep()) { + if (!inputPartialTranslOpt.IsCompatible(targetPhrase, m_conflictFactors)) + continue; } + + outPhrase.SetScore(transScores); + outPhrase.Evaluate(); // need to do this as all non-transcores would be screwed up + + outPhrase.MergeFactors(targetPhrase, m_newOutputFactors); + + TranslationOption *newTransOpt = new TranslationOption(sourceWordsRange, outPhrase); + assert(newTransOpt != NULL); + + outputPartialTranslOptColl.Add(system, newTransOpt ); + } } else if (sourceWordsRange.GetNumWordsCovered() == 1) { // unknown handler @@ -117,7 +119,7 @@ void DecodeStepTranslation::ProcessInitialTranslation(const TranslationSystem* s for (iterTargetPhrase = phraseColl->begin() ; iterTargetPhrase != iterEnd ; ++iterTargetPhrase) { const TargetPhrase &targetPhrase = **iterTargetPhrase; - TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase, source); + TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase); outputPartialTranslOptColl.Add (system, transOpt); |