diff options
-rw-r--r-- | contrib/server/mosesserver.cpp | 2 | ||||
-rw-r--r-- | mira/Decoder.cpp | 2 | ||||
-rw-r--r-- | moses-cmd/LatticeMBRGrid.cpp | 2 | ||||
-rw-r--r-- | moses/Manager.cpp | 7 | ||||
-rw-r--r-- | moses/Manager.h | 2 | ||||
-rw-r--r-- | moses/MockHypothesis.cpp | 2 | ||||
-rw-r--r-- | moses/TranslationTask.cpp | 35 |
7 files changed, 29 insertions, 23 deletions
diff --git a/contrib/server/mosesserver.cpp b/contrib/server/mosesserver.cpp index 93236fb44..6819cbeaa 100644 --- a/contrib/server/mosesserver.cpp +++ b/contrib/server/mosesserver.cpp @@ -301,7 +301,7 @@ public: inputFactorOrder = staticData.GetInputFactorOrder(); stringstream in(source + "\n"); sentence.Read(in,inputFactorOrder); - Manager manager(sentence, staticData.GetSearchAlgorithm()); + Manager manager(sentence); manager.Decode(); const Hypothesis* hypo = manager.GetBestHypothesis(); diff --git a/mira/Decoder.cpp b/mira/Decoder.cpp index 64b6a2e5f..d87b62abf 100644 --- a/mira/Decoder.cpp +++ b/mira/Decoder.cpp @@ -143,7 +143,7 @@ vector< vector<const Word*> > MosesDecoder::runDecoder(const std::string& source string filename) { // run the decoder - m_manager = new Moses::Manager(*m_sentence, search); + m_manager = new Moses::Manager(*m_sentence); m_manager->Decode(); TrellisPathList nBestList; m_manager->CalcNBest(nBestSize, nBestList, distinct); diff --git a/moses-cmd/LatticeMBRGrid.cpp b/moses-cmd/LatticeMBRGrid.cpp index 17596cbdb..d35b921e2 100644 --- a/moses-cmd/LatticeMBRGrid.cpp +++ b/moses-cmd/LatticeMBRGrid.cpp @@ -181,7 +181,7 @@ int main(int argc, char* argv[]) ++lineCount; source->SetTranslationId(lineCount); - Manager manager(*source, staticData.GetSearchAlgorithm()); + Manager manager(*source); manager.Decode(); TrellisPathList nBestList; manager.CalcNBest(nBestSize, nBestList,true); diff --git a/moses/Manager.cpp b/moses/Manager.cpp index 737783b55..90d120920 100644 --- a/moses/Manager.cpp +++ b/moses/Manager.cpp @@ -59,13 +59,16 @@ using namespace std; namespace Moses { -Manager::Manager(InputType const& source, SearchAlgorithm searchAlgorithm) +Manager::Manager(InputType const& source) :BaseManager(source) ,m_transOptColl(source.CreateTranslationOptionCollection()) - ,m_search(Search::CreateSearch(*this, source, searchAlgorithm, *m_transOptColl)) ,interrupted_flag(0) ,m_hypoId(0) { + const StaticData &staticData = StaticData::Instance(); + SearchAlgorithm searchAlgorithm = staticData.GetSearchAlgorithm(); + m_search = Search::CreateSearch(*this, source, searchAlgorithm, *m_transOptColl); + StaticData::Instance().InitializeForInput(m_source); } diff --git a/moses/Manager.h b/moses/Manager.h index 8dacea593..8c4c1e6f4 100644 --- a/moses/Manager.h +++ b/moses/Manager.h @@ -151,7 +151,7 @@ protected: void OutputAlignment(std::ostringstream &out, const TrellisPath &path) const; public: - Manager(InputType const& source, SearchAlgorithm searchAlgorithm); + Manager(InputType const& source); ~Manager(); const TranslationOptionCollection* getSntTranslationOptions(); diff --git a/moses/MockHypothesis.cpp b/moses/MockHypothesis.cpp index c18b58a5e..e25fe4e52 100644 --- a/moses/MockHypothesis.cpp +++ b/moses/MockHypothesis.cpp @@ -41,7 +41,7 @@ MockHypothesisGuard::MockHypothesisGuard( m_wp("WordPenalty"), m_uwp("UnknownWordPenalty"), m_dist("Distortion"), - m_manager(m_sentence,Normal) + m_manager(m_sentence) { BOOST_CHECK_EQUAL(alignments.size(), targetSegments.size()); diff --git a/moses/TranslationTask.cpp b/moses/TranslationTask.cpp index 6d29e3fab..ac12b9a29 100644 --- a/moses/TranslationTask.cpp +++ b/moses/TranslationTask.cpp @@ -50,6 +50,7 @@ void TranslationTask::RunPb() { // shorthand for "global data" const StaticData &staticData = StaticData::Instance(); + const size_t translationId = m_source->GetTranslationId(); // input sentence Sentence sentence; @@ -60,7 +61,7 @@ void TranslationTask::RunPb() // report thread number #if defined(WITH_THREADS) && defined(BOOST_HAS_PTHREADS) - TRACE_ERR("Translating line " << m_source->GetTranslationId() << " in thread id " << pthread_self() << endl); + TRACE_ERR("Translating line " << translationId << " in thread id " << pthread_self() << endl); #endif @@ -69,50 +70,52 @@ void TranslationTask::RunPb() // we still need to apply the decision rule (MAP, MBR, ...) Timer initTime; initTime.start(); - Manager manager(*m_source,staticData.GetSearchAlgorithm()); - VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Initialize search took " << initTime << " seconds total" << endl); - manager.Decode(); + Manager *manager = new Manager(*m_source); + VERBOSE(1, "Line " << translationId << ": Initialize search took " << initTime << " seconds total" << endl); + manager->Decode(); // we are done with search, let's look what we got Timer additionalReportingTime; additionalReportingTime.start(); - manager.OutputBest(m_ioWrapper.GetSingleBestOutputCollector()); + manager->OutputBest(m_ioWrapper.GetSingleBestOutputCollector()); // output word graph - manager.OutputWordGraph(m_ioWrapper.GetWordGraphCollector()); + manager->OutputWordGraph(m_ioWrapper.GetWordGraphCollector()); // output search graph - manager.OutputSearchGraph(m_ioWrapper.GetSearchGraphOutputCollector()); + manager->OutputSearchGraph(m_ioWrapper.GetSearchGraphOutputCollector()); - manager.OutputSearchGraphSLF(); + manager->OutputSearchGraphSLF(); // Output search graph in hypergraph format for Kenneth Heafield's lazy hypergraph decoder - manager.OutputSearchGraphHypergraph(); + manager->OutputSearchGraphHypergraph(); additionalReportingTime.stop(); additionalReportingTime.start(); // output n-best list - manager.OutputNBest(m_ioWrapper.GetNBestOutputCollector()); + manager->OutputNBest(m_ioWrapper.GetNBestOutputCollector()); //lattice samples - manager.OutputLatticeSamples(m_ioWrapper.GetLatticeSamplesCollector()); + manager->OutputLatticeSamples(m_ioWrapper.GetLatticeSamplesCollector()); // detailed translation reporting - manager.OutputDetailedTranslationReport(m_ioWrapper.GetDetailedTranslationCollector()); + manager->OutputDetailedTranslationReport(m_ioWrapper.GetDetailedTranslationCollector()); //list of unknown words - manager.OutputUnknowns(m_ioWrapper.GetUnknownsCollector()); + manager->OutputUnknowns(m_ioWrapper.GetUnknownsCollector()); // report additional statistics - manager.CalcDecoderStatistics(); - VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Additional reporting took " << additionalReportingTime << " seconds total" << endl); - VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Translation took " << translationTime << " seconds total" << endl); + manager->CalcDecoderStatistics(); + VERBOSE(1, "Line " << translationId << ": Additional reporting took " << additionalReportingTime << " seconds total" << endl); + VERBOSE(1, "Line " << translationId << ": Translation took " << translationTime << " seconds total" << endl); IFVERBOSE(2) { PrintUserTime("Sentence Decoding Time:"); } + + delete manager; } |