mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-17 14:17:13 +03:00
consistent constructor for all managers
This commit is contained in:
parent
1ff52ebb0e
commit
0552a79b1e
@ -301,7 +301,7 @@ public:
|
|||||||
inputFactorOrder = staticData.GetInputFactorOrder();
|
inputFactorOrder = staticData.GetInputFactorOrder();
|
||||||
stringstream in(source + "\n");
|
stringstream in(source + "\n");
|
||||||
sentence.Read(in,inputFactorOrder);
|
sentence.Read(in,inputFactorOrder);
|
||||||
Manager manager(sentence, staticData.GetSearchAlgorithm());
|
Manager manager(sentence);
|
||||||
manager.Decode();
|
manager.Decode();
|
||||||
const Hypothesis* hypo = manager.GetBestHypothesis();
|
const Hypothesis* hypo = manager.GetBestHypothesis();
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ vector< vector<const Word*> > MosesDecoder::runDecoder(const std::string& source
|
|||||||
string filename)
|
string filename)
|
||||||
{
|
{
|
||||||
// run the decoder
|
// run the decoder
|
||||||
m_manager = new Moses::Manager(*m_sentence, search);
|
m_manager = new Moses::Manager(*m_sentence);
|
||||||
m_manager->Decode();
|
m_manager->Decode();
|
||||||
TrellisPathList nBestList;
|
TrellisPathList nBestList;
|
||||||
m_manager->CalcNBest(nBestSize, nBestList, distinct);
|
m_manager->CalcNBest(nBestSize, nBestList, distinct);
|
||||||
|
@ -181,7 +181,7 @@ int main(int argc, char* argv[])
|
|||||||
++lineCount;
|
++lineCount;
|
||||||
source->SetTranslationId(lineCount);
|
source->SetTranslationId(lineCount);
|
||||||
|
|
||||||
Manager manager(*source, staticData.GetSearchAlgorithm());
|
Manager manager(*source);
|
||||||
manager.Decode();
|
manager.Decode();
|
||||||
TrellisPathList nBestList;
|
TrellisPathList nBestList;
|
||||||
manager.CalcNBest(nBestSize, nBestList,true);
|
manager.CalcNBest(nBestSize, nBestList,true);
|
||||||
|
@ -59,13 +59,16 @@ using namespace std;
|
|||||||
|
|
||||||
namespace Moses
|
namespace Moses
|
||||||
{
|
{
|
||||||
Manager::Manager(InputType const& source, SearchAlgorithm searchAlgorithm)
|
Manager::Manager(InputType const& source)
|
||||||
:BaseManager(source)
|
:BaseManager(source)
|
||||||
,m_transOptColl(source.CreateTranslationOptionCollection())
|
,m_transOptColl(source.CreateTranslationOptionCollection())
|
||||||
,m_search(Search::CreateSearch(*this, source, searchAlgorithm, *m_transOptColl))
|
|
||||||
,interrupted_flag(0)
|
,interrupted_flag(0)
|
||||||
,m_hypoId(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);
|
StaticData::Instance().InitializeForInput(m_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ protected:
|
|||||||
void OutputAlignment(std::ostringstream &out, const TrellisPath &path) const;
|
void OutputAlignment(std::ostringstream &out, const TrellisPath &path) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Manager(InputType const& source, SearchAlgorithm searchAlgorithm);
|
Manager(InputType const& source);
|
||||||
~Manager();
|
~Manager();
|
||||||
const TranslationOptionCollection* getSntTranslationOptions();
|
const TranslationOptionCollection* getSntTranslationOptions();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ MockHypothesisGuard::MockHypothesisGuard(
|
|||||||
m_wp("WordPenalty"),
|
m_wp("WordPenalty"),
|
||||||
m_uwp("UnknownWordPenalty"),
|
m_uwp("UnknownWordPenalty"),
|
||||||
m_dist("Distortion"),
|
m_dist("Distortion"),
|
||||||
m_manager(m_sentence,Normal)
|
m_manager(m_sentence)
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(alignments.size(), targetSegments.size());
|
BOOST_CHECK_EQUAL(alignments.size(), targetSegments.size());
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ void TranslationTask::RunPb()
|
|||||||
{
|
{
|
||||||
// shorthand for "global data"
|
// shorthand for "global data"
|
||||||
const StaticData &staticData = StaticData::Instance();
|
const StaticData &staticData = StaticData::Instance();
|
||||||
|
const size_t translationId = m_source->GetTranslationId();
|
||||||
|
|
||||||
// input sentence
|
// input sentence
|
||||||
Sentence sentence;
|
Sentence sentence;
|
||||||
@ -60,7 +61,7 @@ void TranslationTask::RunPb()
|
|||||||
|
|
||||||
// report thread number
|
// report thread number
|
||||||
#if defined(WITH_THREADS) && defined(BOOST_HAS_PTHREADS)
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -69,50 +70,52 @@ void TranslationTask::RunPb()
|
|||||||
// we still need to apply the decision rule (MAP, MBR, ...)
|
// we still need to apply the decision rule (MAP, MBR, ...)
|
||||||
Timer initTime;
|
Timer initTime;
|
||||||
initTime.start();
|
initTime.start();
|
||||||
Manager manager(*m_source,staticData.GetSearchAlgorithm());
|
Manager *manager = new Manager(*m_source);
|
||||||
VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Initialize search took " << initTime << " seconds total" << endl);
|
VERBOSE(1, "Line " << translationId << ": Initialize search took " << initTime << " seconds total" << endl);
|
||||||
manager.Decode();
|
manager->Decode();
|
||||||
|
|
||||||
// we are done with search, let's look what we got
|
// we are done with search, let's look what we got
|
||||||
Timer additionalReportingTime;
|
Timer additionalReportingTime;
|
||||||
additionalReportingTime.start();
|
additionalReportingTime.start();
|
||||||
|
|
||||||
manager.OutputBest(m_ioWrapper.GetSingleBestOutputCollector());
|
manager->OutputBest(m_ioWrapper.GetSingleBestOutputCollector());
|
||||||
|
|
||||||
// output word graph
|
// output word graph
|
||||||
manager.OutputWordGraph(m_ioWrapper.GetWordGraphCollector());
|
manager->OutputWordGraph(m_ioWrapper.GetWordGraphCollector());
|
||||||
|
|
||||||
// output search graph
|
// 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
|
// Output search graph in hypergraph format for Kenneth Heafield's lazy hypergraph decoder
|
||||||
manager.OutputSearchGraphHypergraph();
|
manager->OutputSearchGraphHypergraph();
|
||||||
|
|
||||||
additionalReportingTime.stop();
|
additionalReportingTime.stop();
|
||||||
|
|
||||||
additionalReportingTime.start();
|
additionalReportingTime.start();
|
||||||
|
|
||||||
// output n-best list
|
// output n-best list
|
||||||
manager.OutputNBest(m_ioWrapper.GetNBestOutputCollector());
|
manager->OutputNBest(m_ioWrapper.GetNBestOutputCollector());
|
||||||
|
|
||||||
//lattice samples
|
//lattice samples
|
||||||
manager.OutputLatticeSamples(m_ioWrapper.GetLatticeSamplesCollector());
|
manager->OutputLatticeSamples(m_ioWrapper.GetLatticeSamplesCollector());
|
||||||
|
|
||||||
// detailed translation reporting
|
// detailed translation reporting
|
||||||
manager.OutputDetailedTranslationReport(m_ioWrapper.GetDetailedTranslationCollector());
|
manager->OutputDetailedTranslationReport(m_ioWrapper.GetDetailedTranslationCollector());
|
||||||
|
|
||||||
//list of unknown words
|
//list of unknown words
|
||||||
manager.OutputUnknowns(m_ioWrapper.GetUnknownsCollector());
|
manager->OutputUnknowns(m_ioWrapper.GetUnknownsCollector());
|
||||||
|
|
||||||
// report additional statistics
|
// report additional statistics
|
||||||
manager.CalcDecoderStatistics();
|
manager->CalcDecoderStatistics();
|
||||||
VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Additional reporting took " << additionalReportingTime << " seconds total" << endl);
|
VERBOSE(1, "Line " << translationId << ": Additional reporting took " << additionalReportingTime << " seconds total" << endl);
|
||||||
VERBOSE(1, "Line " << m_source->GetTranslationId() << ": Translation took " << translationTime << " seconds total" << endl);
|
VERBOSE(1, "Line " << translationId << ": Translation took " << translationTime << " seconds total" << endl);
|
||||||
IFVERBOSE(2) {
|
IFVERBOSE(2) {
|
||||||
PrintUserTime("Sentence Decoding Time:");
|
PrintUserTime("Sentence Decoding Time:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user