Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-08-06 20:09:53 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-08-06 20:09:53 +0400
commit7a808a2edb5ce9304a2d6dd043188c64a1f23b46 (patch)
treec16f395ed454cdd52e6f423571d07fce87d93b20 /moses/DecodeStepTranslation.cpp
parent646cf93c1f8e1e72e0907d1c3c03e644cff51e2f (diff)
push InpuutPath down into phrase dictionary for legacy methods
Diffstat (limited to 'moses/DecodeStepTranslation.cpp')
-rw-r--r--moses/DecodeStepTranslation.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp
index 3ce531684..12b36b75b 100644
--- a/moses/DecodeStepTranslation.cpp
+++ b/moses/DecodeStepTranslation.cpp
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "TranslationOptionCollection.h"
#include "PartialTranslOptColl.h"
#include "FactorCollection.h"
+#include "util/exception.hh"
using namespace std;
@@ -214,7 +215,11 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy(
for (iterTargetPhrase = phraseColl->begin() ; iterTargetPhrase != iterEnd ; ++iterTargetPhrase) {
const TargetPhrase &targetPhrase = **iterTargetPhrase;
+
+ const InputPath &inputPath = GetInputPathLegacy(targetPhrase, inputPathList);
+
TranslationOption *transOpt = new TranslationOption(wordsRange, targetPhrase);
+ transOpt->SetSourcePhrase(inputPath.GetPhrase());
outputPartialTranslOptColl.Add (transOpt);
@@ -224,6 +229,27 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy(
}
}
+const InputPath &DecodeStepTranslation::GetInputPathLegacy(const TargetPhrase targetPhrase,
+ const InputPathList &inputPathList) const
+{
+ const Phrase &phraseFromTP = targetPhrase.GetSourcePhrase();
+ const Word &wordTP = phraseFromTP.GetWord(0);
+
+ InputPathList::const_iterator iter;
+ for (iter = inputPathList.begin(); iter != inputPathList.end(); ++iter) {
+ const InputPath &inputPath = **iter;
+ const Phrase &phraseFromIP = inputPath.GetPhrase();
+ const Word &wordIP = phraseFromIP.GetWord(0);
+
+ const WordsRange &range = inputPath.GetWordsRange();
+
+ if (wordTP == wordIP) {
+ return inputPath;
+ }
+ }
+
+ UTIL_THROW(util::Exception, "Input path not found");
+}
}