From 0e8699342517814db136365d96d643ca1bb405cc Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 1 Mar 2016 19:56:18 +0000 Subject: [PATCH] use InputPathBase --- contrib/other-builds/moses2/InputPathsBase.h | 8 ++++---- .../moses2/PhraseBased/CubePruningMiniStack/Search.cpp | 4 ++-- contrib/other-builds/moses2/PhraseBased/InputPath.cpp | 2 +- contrib/other-builds/moses2/PhraseBased/InputPath.h | 2 +- contrib/other-builds/moses2/PhraseBased/InputPaths.cpp | 4 ++-- contrib/other-builds/moses2/PhraseBased/Normal/Search.cpp | 4 ++-- .../other-builds/moses2/TranslationModel/PhraseTable.cpp | 4 +++- .../other-builds/moses2/TranslationModel/ProbingPT.cpp | 3 ++- .../moses2/TranslationModel/UnknownWordPenalty.cpp | 3 ++- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/contrib/other-builds/moses2/InputPathsBase.h b/contrib/other-builds/moses2/InputPathsBase.h index 3d74d826f..25b3fbcf4 100644 --- a/contrib/other-builds/moses2/InputPathsBase.h +++ b/contrib/other-builds/moses2/InputPathsBase.h @@ -8,7 +8,6 @@ #pragma once #include -#include "PhraseBased/InputPath.h" #include "MemPool.h" #include "legacy/Matrix.h" @@ -18,10 +17,11 @@ namespace Moses2 class Sentence; class System; class ManagerBase; +class InputPathBase; class InputPathsBase { - typedef std::vector Coll; + typedef std::vector Coll; public: InputPathsBase() {} virtual ~InputPathsBase(); @@ -46,12 +46,12 @@ public: virtual void Init(const Sentence &input, const ManagerBase &mgr) = 0; - const Matrix &GetMatrix() const + const Matrix &GetMatrix() const { return *m_matrix; } protected: Coll m_inputPaths; - Matrix *m_matrix; + Matrix *m_matrix; }; } diff --git a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp index 04ca9a740..188e42c1d 100644 --- a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp +++ b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp @@ -155,7 +155,7 @@ void Search::PostDecode(size_t stackInd) MemPool &pool = mgr.GetPool(); const InputPaths &paths = mgr.GetInputPaths(); - const Matrix &pathMatrix = paths.GetMatrix(); + const Matrix &pathMatrix = paths.GetMatrix(); size_t inputSize = pathMatrix.GetRows(); size_t numPaths = pathMatrix.GetCols(); @@ -168,7 +168,7 @@ void Search::PostDecode(size_t stackInd) // create edges to next hypos from existing hypos for (size_t startPos = firstGap; startPos < inputSize; ++startPos) { for (size_t pathInd = 0; pathInd < numPaths; ++pathInd) { - const InputPath *path = pathMatrix.GetValue(startPos, pathInd); + const InputPath *path = static_cast(pathMatrix.GetValue(startPos, pathInd)); if (path == NULL) { break; diff --git a/contrib/other-builds/moses2/PhraseBased/InputPath.cpp b/contrib/other-builds/moses2/PhraseBased/InputPath.cpp index 38ec9caef..3c871cbc9 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPath.cpp +++ b/contrib/other-builds/moses2/PhraseBased/InputPath.cpp @@ -14,7 +14,7 @@ InputPath::InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, - const InputPath *prefixPath) + const InputPathBase *prefixPath) :InputPathBase(pool, subPhrase, range, numPt, prefixPath) ,m_isUsed(false) { diff --git a/contrib/other-builds/moses2/PhraseBased/InputPath.h b/contrib/other-builds/moses2/PhraseBased/InputPath.h index a57b122b4..69fe76a24 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPath.h +++ b/contrib/other-builds/moses2/PhraseBased/InputPath.h @@ -20,7 +20,7 @@ class InputPath : public InputPathBase public: const TargetPhrases** targetPhrases; - InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, const InputPath *prefixPath); + InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, const InputPathBase *prefixPath); virtual ~InputPath(); void AddTargetPhrases(const PhraseTable &pt, const TargetPhrases *tps); diff --git a/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp b/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp index c55772313..7c54e0dba 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp +++ b/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp @@ -23,7 +23,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr) size_t size = input.GetSize(); size_t maxLength = min(size, mgr.system.maxPhraseLength); - m_matrix = new (pool.Allocate< Matrix >()) Matrix(pool, size, maxLength); + m_matrix = new (pool.Allocate< Matrix >()) Matrix(pool, size, maxLength); m_matrix->Init(NULL); // create blank path for initial hypo @@ -33,7 +33,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr) // create normal paths of subphrases through the sentence for (size_t startPos = 0; startPos < size; ++startPos) { - const InputPath *prefixPath = NULL; + const InputPathBase *prefixPath = NULL; for (size_t phaseSize = 1; phaseSize <= maxLength; ++phaseSize) { size_t endPos = startPos + phaseSize - 1; diff --git a/contrib/other-builds/moses2/PhraseBased/Normal/Search.cpp b/contrib/other-builds/moses2/PhraseBased/Normal/Search.cpp index 2ac235795..06f704d11 100644 --- a/contrib/other-builds/moses2/PhraseBased/Normal/Search.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Normal/Search.cpp @@ -68,9 +68,9 @@ void SearchNormal::Decode(size_t stackInd) const InputPaths &paths = mgr.GetInputPaths(); - BOOST_FOREACH(const InputPath *path, paths) { + BOOST_FOREACH(const InputPathBase *path, paths) { BOOST_FOREACH(const HypothesisBase *hypo, hypos) { - Extend(*static_cast(hypo), *path); + Extend(*static_cast(hypo), *static_cast(path)); } } } diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp b/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp index fb956e1d1..2a5ee5c5e 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTable.cpp @@ -54,7 +54,9 @@ void PhraseTable::SetParameter(const std::string& key, const std::string& value) void PhraseTable::Lookup(const Manager &mgr, InputPaths &inputPaths) const { - BOOST_FOREACH(InputPath *path, inputPaths) { + BOOST_FOREACH(InputPathBase *pathBase, inputPaths) { + InputPath *path = static_cast(pathBase); + const SubPhrase &phrase = path->subPhrase; TargetPhrases *tpsPtr = tpsPtr = Lookup(mgr, mgr.GetPool(), *path); diff --git a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp index 939aeceaf..8602dda22 100644 --- a/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp +++ b/contrib/other-builds/moses2/TranslationModel/ProbingPT.cpp @@ -91,7 +91,8 @@ void ProbingPT::Load(System &system) void ProbingPT::Lookup(const Manager &mgr, InputPaths &inputPaths) const { - BOOST_FOREACH(InputPath *path, inputPaths) { + BOOST_FOREACH(InputPathBase *pathBase, inputPaths) { + InputPath *path = static_cast(pathBase); TargetPhrases *tpsPtr; tpsPtr = Lookup(mgr, mgr.GetPool(), *path); path->AddTargetPhrases(*this, tpsPtr); diff --git a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp index 4e01dfb84..d216438d7 100644 --- a/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp +++ b/contrib/other-builds/moses2/TranslationModel/UnknownWordPenalty.cpp @@ -27,7 +27,8 @@ UnknownWordPenalty::~UnknownWordPenalty() { void UnknownWordPenalty::Lookup(const Manager &mgr, InputPaths &inputPaths) const { - BOOST_FOREACH(InputPath *path, inputPaths) { + BOOST_FOREACH(InputPathBase *pathBase, inputPaths) { + InputPath *path = static_cast(pathBase); const SubPhrase &phrase = path->subPhrase; TargetPhrases *tpsPtr;