diff options
author | redpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-07-19 00:38:58 +0400 |
---|---|---|
committer | redpony <redpony@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-07-19 00:38:58 +0400 |
commit | 89f3ab827c862744ae48115cbc4394aaea26f9b0 (patch) | |
tree | 68aa8008056c736e6601f7af1a04c49d0d876e45 /moses | |
parent | 507b8a7df764ff2f2928335baa43ed6d56f7d042 (diff) |
add constraints on word deletion, use default initializers in WordsRange.h
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@178 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses')
-rwxr-xr-x | moses/src/Manager.cpp | 64 | ||||
-rwxr-xr-x | moses/src/WordsRange.h | 6 |
2 files changed, 36 insertions, 34 deletions
diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp index 827e4b806..eb7140791 100755 --- a/moses/src/Manager.cpp +++ b/moses/src/Manager.cpp @@ -207,6 +207,12 @@ void Manager::ProcessOneHypothesis(const list < DecodeStep > &decodeStepList, co void Manager::ProcessInitialTranslation(const Hypothesis &hypothesis, const DecodeStep &decodeStep, HypothesisCollectionIntermediate &outputHypoColl) { + const WordsBitmap& hypoBitmap = hypothesis.GetWordsBitmap(); + size_t hypoWordCount = hypoBitmap.GetWordsCount() // pharaoh: foreignTranslated + ,hypoFirstGapPos = hypoBitmap.GetFirstGapPos(); // pharaoh: gapStart + + // TODO: handle this switch polymorphically or with stl algorithms? + // that could make this MUCH cleaner. ask cdyer int maxDistortion = m_staticData.GetMaxDistortion(); if (maxDistortion < 0) { // no limit on distortion @@ -217,18 +223,15 @@ void Manager::ProcessInitialTranslation(const Hypothesis &hypothesis, const Deco if ( !transOpt.Overlap(hypothesis)) { - Hypothesis* newHypo = hypothesis.CreateNext(transOpt); - outputHypoColl.AddNoPrune( newHypo ); + if (!transOpt.IsDeletionOption() || transOpt.GetStartPos() == hypoWordCount) { + Hypothesis* newHypo = hypothesis.CreateNext(transOpt); + outputHypoColl.AddNoPrune( newHypo ); + } } } } - else + else // limited reordering possible (maxDistortion # of words) { - const WordsBitmap hypoBitmap = hypothesis.GetWordsBitmap(); - size_t hypoWordCount = hypoBitmap.GetWordsCount() - ,hypoFirstGapPos = hypoBitmap.GetFirstGapPos(); - - // MAIN LOOP. go through each possible hypo TranslationOptionCollection::const_iterator iterTransOpt; for (iterTransOpt = m_possibleTranslations.begin(); iterTransOpt != m_possibleTranslations.end(); ++iterTransOpt) { @@ -237,23 +240,14 @@ void Manager::ProcessInitialTranslation(const Hypothesis &hypothesis, const Deco size_t transOptStartPos = transOpt.GetStartPos(); - if (hypoFirstGapPos == hypoWordCount) - { - if (transOptStartPos == hypoWordCount - || (transOptStartPos > hypoWordCount - && transOpt.GetEndPos() <= hypoWordCount + m_staticData.GetMaxDistortion()) - ) - { - Hypothesis *newHypo = hypothesis.CreateNext(transOpt); - outputHypoColl.AddNoPrune( newHypo ); - } - } - else + if (!transOpt.IsDeletionOption() || transOpt.GetStartPos() == hypoWordCount) { - if (transOptStartPos < hypoWordCount) + if (hypoFirstGapPos == hypoWordCount) // no gap so far { - if (transOptStartPos >= hypoFirstGapPos - && !transOpt.Overlap(hypothesis)) + if (transOptStartPos == hypoWordCount + || (transOptStartPos > hypoWordCount + && transOpt.GetEndPos() <= hypoWordCount + m_staticData.GetMaxDistortion()) + ) { Hypothesis *newHypo = hypothesis.CreateNext(transOpt); outputHypoColl.AddNoPrune( newHypo ); @@ -261,11 +255,23 @@ void Manager::ProcessInitialTranslation(const Hypothesis &hypothesis, const Deco } else { - if (transOpt.GetEndPos() <= hypoFirstGapPos + m_staticData.GetMaxDistortion() - && !transOpt.Overlap(hypothesis)) + if (transOptStartPos < hypoWordCount) { - Hypothesis *newHypo = hypothesis.CreateNext(transOpt); - outputHypoColl.AddNoPrune( newHypo ); + if (transOptStartPos >= hypoFirstGapPos + && !transOpt.Overlap(hypothesis)) + { + Hypothesis *newHypo = hypothesis.CreateNext(transOpt); + outputHypoColl.AddNoPrune( newHypo ); + } + } + else + { + if (transOpt.GetEndPos() <= hypoFirstGapPos + m_staticData.GetMaxDistortion() + && !transOpt.Overlap(hypothesis)) + { + Hypothesis *newHypo = hypothesis.CreateNext(transOpt); + outputHypoColl.AddNoPrune( newHypo ); + } } } } @@ -377,8 +383,8 @@ void Manager::CreateTranslationOptions(const Phrase &phrase, PhraseDictionary &p const TargetPhrase &targetPhrase = *iterTargetPhrase; const WordsRange wordsRange(startPos, endPos); - TranslationOption transOpt(wordsRange, targetPhrase); - m_possibleTranslations.push_back(transOpt); +// TranslationOption transOpt(wordsRange, targetPhrase); + m_possibleTranslations.push_back(TranslationOption(wordsRange, targetPhrase)); // if (m_staticData.GetVerboseLevel() >= 3) { // cout << "\t" << transOpt << "\n"; // } diff --git a/moses/src/WordsRange.h b/moses/src/WordsRange.h index dc85486a1..f06cf5633 100755 --- a/moses/src/WordsRange.h +++ b/moses/src/WordsRange.h @@ -41,11 +41,7 @@ public: { return m_endPos; } - inline WordsRange(size_t startPos, size_t endPos) - { - m_startPos = startPos; - m_endPos = endPos; - } + inline WordsRange(size_t startPos, size_t endPos) : m_startPos(startPos), m_endPos(endPos) {} inline int CalcDistortion(const WordsRange &prevRange) const { |