diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-01-07 11:59:08 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-01-07 11:59:08 +0300 |
commit | 99b4b63c0cd857185cf2d99972d1150a8b2faf7f (patch) | |
tree | 6e976b55abc1cf3efa2ab21895f42ffe67e2eaad | |
parent | b9bef2fc44fce020f78018cbc71f2f375f5071ee (diff) |
change signature of GetChartRuleCollection()
15 files changed, 25 insertions, 16 deletions
diff --git a/moses/ChartParser.cpp b/moses/ChartParser.cpp index a9a1e6aa1..40f18e7e8 100644 --- a/moses/ChartParser.cpp +++ b/moses/ChartParser.cpp @@ -191,7 +191,8 @@ void ChartParser::Create(const WordsRange &wordsRange, ChartParserCallback &to) last = min(last, wordsRange.GetStartPos()+maxSpan); } if (maxSpan == 0 || wordsRange.GetNumWordsCovered() <= maxSpan) { - ruleLookupManager.GetChartRuleCollection(wordsRange, last, to); + const InputPath &inputPath = GetInputPath(wordsRange); + ruleLookupManager.GetChartRuleCollection(inputPath, last, to); } } @@ -236,7 +237,7 @@ void ChartParser::CreateInputPaths(const InputType &input) } } -const InputPath &ChartParser::GetInputPath(WordsRange &range) const +const InputPath &ChartParser::GetInputPath(const WordsRange &range) const { return GetInputPath(range.GetStartPos(), range.GetEndPos()); } diff --git a/moses/ChartParser.h b/moses/ChartParser.h index b9e82d2e7..e438cf8ad 100644 --- a/moses/ChartParser.h +++ b/moses/ChartParser.h @@ -70,7 +70,7 @@ public: long GetTranslationId() const; size_t GetSize() const; const InputPath &GetInputPath(size_t startPos, size_t endPos) const; - const InputPath &GetInputPath(WordsRange &range) const; + const InputPath &GetInputPath(const WordsRange &range) const; const std::vector<Phrase*> &GetUnknownSources() const { return m_unknown.GetUnknownSources(); } diff --git a/moses/ChartRuleLookupManager.h b/moses/ChartRuleLookupManager.h index 94263b22e..be1a8c7d1 100644 --- a/moses/ChartRuleLookupManager.h +++ b/moses/ChartRuleLookupManager.h @@ -65,7 +65,7 @@ public: * \param outColl return argument */ virtual void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, // last position to consider if using lookahead ChartParserCallback &outColl) = 0; diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp index f229a0f4b..1223126ae 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp @@ -52,10 +52,11 @@ ChartRuleLookupManagerMemory::ChartRuleLookupManagerMemory( } void ChartRuleLookupManagerMemory::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, ChartParserCallback &outColl) { + const WordsRange &range = inputPath.GetWordsRange(); size_t startPos = range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h index 80b6f7246..1abbc25ca 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.h @@ -51,7 +51,7 @@ public: ~ChartRuleLookupManagerMemory() {}; virtual void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, // last position to consider if using lookahead ChartParserCallback &outColl); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp index 23d357f10..07c562a60 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp @@ -52,10 +52,11 @@ ChartRuleLookupManagerMemoryPerSentence::ChartRuleLookupManagerMemoryPerSentence } void ChartRuleLookupManagerMemoryPerSentence::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, ChartParserCallback &outColl) { + const WordsRange &range = inputPath.GetWordsRange(); size_t startPos = range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h index d6a6f6535..742e25355 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.h @@ -50,7 +50,7 @@ public: ~ChartRuleLookupManagerMemoryPerSentence() {}; virtual void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, // last position to consider if using lookahead ChartParserCallback &outColl); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.cpp index f348ea62d..4e9ccdbfd 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.cpp @@ -52,10 +52,12 @@ ChartRuleLookupManagerOOVPT::~ChartRuleLookupManagerOOVPT() } void ChartRuleLookupManagerOOVPT::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl) { + const WordsRange &range = inputPath.GetWordsRange(); + //m_tpColl.push_back(TargetPhraseCollection()); //TargetPhraseCollection &tpColl = m_tpColl.back(); TargetPhraseCollection *tpColl = new TargetPhraseCollection(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.h index fb9fdbabf..2d5d6ad46 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOOVPT.h @@ -41,7 +41,7 @@ public: ~ChartRuleLookupManagerOOVPT(); virtual void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp index a57e66881..6f7fafcc2 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp @@ -75,12 +75,13 @@ ChartRuleLookupManagerOnDisk::~ChartRuleLookupManagerOnDisk() } void ChartRuleLookupManagerOnDisk::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t lastPos, ChartParserCallback &outColl) { const StaticData &staticData = StaticData::Instance(); const Word &defaultSourceNonTerm = staticData.GetInputDefaultNonTerminal(); + const WordsRange &range = inputPath.GetWordsRange(); size_t relEndPos = range.GetEndPos() - range.GetStartPos(); size_t absEndPos = range.GetEndPos(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.h index 6f2f71cdd..0ff87b378 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.h @@ -45,7 +45,7 @@ public: ~ChartRuleLookupManagerOnDisk(); - virtual void GetChartRuleCollection(const WordsRange &range, + virtual void GetChartRuleCollection(const InputPath &inputPath, size_t last, ChartParserCallback &outColl); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp index 93ddc82db..53011e5ac 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.cpp @@ -52,7 +52,7 @@ ChartRuleLookupManagerSkeleton::~ChartRuleLookupManagerSkeleton() } void ChartRuleLookupManagerSkeleton::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl) { @@ -61,6 +61,8 @@ void ChartRuleLookupManagerSkeleton::GetChartRuleCollection( TargetPhraseCollection *tpColl = new TargetPhraseCollection(); m_tpColl.push_back(tpColl); + const WordsRange &range = inputPath.GetWordsRange(); + if (range.GetNumWordsCovered() == 1) { const ChartCellLabel &sourceWordLabel = GetSourceAt(range.GetStartPos()); const Word &sourceWord = sourceWordLabel.GetLabel(); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h index dd8b82278..0c141d2ef 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerSkeleton.h @@ -41,7 +41,7 @@ public: ~ChartRuleLookupManagerSkeleton(); virtual void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl); diff --git a/moses/TranslationModel/Scope3Parser/Parser.cpp b/moses/TranslationModel/Scope3Parser/Parser.cpp index 1491260a1..1b08ec94e 100644 --- a/moses/TranslationModel/Scope3Parser/Parser.cpp +++ b/moses/TranslationModel/Scope3Parser/Parser.cpp @@ -39,10 +39,11 @@ namespace Moses { void Scope3Parser::GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl) { + const WordsRange &range = inputPath.GetWordsRange(); const size_t start = range.GetStartPos(); const size_t end = range.GetEndPos(); diff --git a/moses/TranslationModel/Scope3Parser/Parser.h b/moses/TranslationModel/Scope3Parser/Parser.h index c52f7b50e..c07e2143d 100644 --- a/moses/TranslationModel/Scope3Parser/Parser.h +++ b/moses/TranslationModel/Scope3Parser/Parser.h @@ -58,7 +58,7 @@ public: } void GetChartRuleCollection( - const WordsRange &range, + const InputPath &inputPath, size_t last, ChartParserCallback &outColl); |