diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-08-07 18:02:36 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-08-07 18:02:36 +0400 |
commit | 0ab6a441b24d610a7fdd459ce033b2a4de36401b (patch) | |
tree | 5564d681094eb2c019c1419a8bdc37ee424afe9a /moses/DecodeStepTranslation.cpp | |
parent | b3a860fd4fdc003c7dbb32dea4321c7cf0671825 (diff) |
get ready to delete source phrase from TargetPhrase class
Diffstat (limited to 'moses/DecodeStepTranslation.cpp')
-rw-r--r-- | moses/DecodeStepTranslation.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp index 25e652166..4f88b223a 100644 --- a/moses/DecodeStepTranslation.cpp +++ b/moses/DecodeStepTranslation.cpp @@ -153,13 +153,21 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy( TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl); } + const std::vector<Phrase> &sourcePhrases = phraseColl->GetSourcePhrases(); + TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd; + std::vector<Phrase>::const_iterator iterSourcePhrase; iterEnd = (!adhereTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit; - for (iterTargetPhrase = phraseColl->begin() ; iterTargetPhrase != iterEnd ; ++iterTargetPhrase) { + for (iterTargetPhrase = phraseColl->begin(), iterSourcePhrase = sourcePhrases.begin() + ; iterTargetPhrase != iterEnd + ; ++iterTargetPhrase, ++iterSourcePhrase) { + CHECK(iterSourcePhrase != sourcePhrases.end()); + const TargetPhrase &targetPhrase = **iterTargetPhrase; + const Phrase &sourcePhrase = *iterSourcePhrase; - const InputPath &inputPath = GetInputPathLegacy(targetPhrase, inputPathList); + const InputPath &inputPath = GetInputPathLegacy(targetPhrase, sourcePhrase, inputPathList); TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase); transOpt->SetSourcePhrase(inputPath.GetPhrase()); @@ -172,11 +180,12 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy( } } -const InputPath &DecodeStepTranslation::GetInputPathLegacy(const TargetPhrase targetPhrase, - const InputPathList &inputPathList) const +const InputPath &DecodeStepTranslation::GetInputPathLegacy( + const TargetPhrase targetPhrase, + const Phrase sourcePhrase, + const InputPathList &inputPathList) const { - const Phrase &phraseFromTP = targetPhrase.GetSourcePhraseAA(); - const Word &wordTP = phraseFromTP.GetWord(0); + const Word &wordFromPt = sourcePhrase.GetWord(0); InputPathList::const_iterator iter; for (iter = inputPathList.begin(); iter != inputPathList.end(); ++iter) { @@ -186,7 +195,7 @@ const InputPath &DecodeStepTranslation::GetInputPathLegacy(const TargetPhrase ta const WordsRange &range = inputPath.GetWordsRange(); - if (wordTP == wordIP) { + if (wordFromPt == wordIP) { return inputPath; } } |