mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
move lattice sample collector from Main to IOWrapper
This commit is contained in:
parent
62fe00b1a5
commit
65bd64ca6a
@ -134,30 +134,6 @@ int main(int argc, char** argv)
|
||||
hypergraphOutput.reset(new HypergraphOutput<Manager>(PRECISION));
|
||||
}
|
||||
|
||||
|
||||
// initialize output streams
|
||||
// note: we can't just write to STDOUT or files
|
||||
// because multithreading may return sentences in shuffled order
|
||||
auto_ptr<OutputCollector> latticeSamplesCollector; //for lattice samples
|
||||
auto_ptr<ofstream> latticeSamplesOut;
|
||||
bool output1best = true;
|
||||
|
||||
size_t latticeSamplesSize = staticData.GetLatticeSamplesSize();
|
||||
string latticeSamplesFile = staticData.GetLatticeSamplesFilePath();
|
||||
if (latticeSamplesSize) {
|
||||
if (latticeSamplesFile == "-" || latticeSamplesFile == "/dev/stdout") {
|
||||
latticeSamplesCollector.reset(new OutputCollector());
|
||||
output1best = false;
|
||||
} else {
|
||||
latticeSamplesOut.reset(new ofstream(latticeSamplesFile.c_str()));
|
||||
if (!latticeSamplesOut->good()) {
|
||||
TRACE_ERR("ERROR: Failed to open " << latticeSamplesFile << " for lattice samples" << endl);
|
||||
exit(1);
|
||||
}
|
||||
latticeSamplesCollector.reset(new OutputCollector(latticeSamplesOut.get()));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_THREADS
|
||||
ThreadPool pool(staticData.ThreadCount());
|
||||
#endif
|
||||
|
@ -73,6 +73,7 @@ IOWrapper::IOWrapper(const std::vector<FactorType> &inputFactorOrder
|
||||
,m_detailedTranslationReportingStream(NULL)
|
||||
,m_unknownsStream(NULL)
|
||||
,m_alignmentInfoStream(NULL)
|
||||
,m_latticeSamplesStream(NULL)
|
||||
|
||||
,m_singleBestOutputCollector(NULL)
|
||||
,m_nBestOutputCollector(NULL)
|
||||
@ -162,6 +163,22 @@ IOWrapper::IOWrapper(const std::vector<FactorType> &inputFactorOrder
|
||||
m_wordGraphCollector = new OutputCollector(m_outputWordGraphStream);
|
||||
}
|
||||
|
||||
size_t latticeSamplesSize = staticData.GetLatticeSamplesSize();
|
||||
string latticeSamplesFile = staticData.GetLatticeSamplesFilePath();
|
||||
if (latticeSamplesSize) {
|
||||
if (latticeSamplesFile == "-" || latticeSamplesFile == "/dev/stdout") {
|
||||
m_latticeSamplesCollector = new OutputCollector();
|
||||
m_surpressSingleBestOutput = true;
|
||||
} else {
|
||||
m_latticeSamplesStream = new ofstream(latticeSamplesFile.c_str());
|
||||
if (!m_latticeSamplesStream->good()) {
|
||||
TRACE_ERR("ERROR: Failed to open " << latticeSamplesFile << " for lattice samples" << endl);
|
||||
exit(1);
|
||||
}
|
||||
m_latticeSamplesCollector = new OutputCollector(m_latticeSamplesStream);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_surpressSingleBestOutput) {
|
||||
m_singleBestOutputCollector = new Moses::OutputCollector(&std::cout);
|
||||
}
|
||||
@ -182,6 +199,7 @@ IOWrapper::~IOWrapper()
|
||||
delete m_unknownsStream;
|
||||
delete m_outputSearchGraphStream;
|
||||
delete m_outputWordGraphStream;
|
||||
delete m_latticeSamplesStream;
|
||||
|
||||
delete m_singleBestOutputCollector;
|
||||
delete m_nBestOutputCollector;
|
||||
|
@ -81,6 +81,7 @@ protected:
|
||||
std::ofstream *m_alignmentInfoStream;
|
||||
std::ostream *m_unknownsStream;
|
||||
std::ostream *m_outputSearchGraphStream;
|
||||
std::ofstream *m_latticeSamplesStream;
|
||||
|
||||
bool m_surpressSingleBestOutput;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user