move OutputAlignment() to Manager class

This commit is contained in:
Hieu Hoang 2014-12-30 20:36:59 +05:30
parent e92c2c0e0c
commit c9d49f22a5
5 changed files with 20 additions and 19 deletions

View File

@ -391,21 +391,6 @@ void IOWrapper::WriteApplicationContext(std::ostream &out,
}
}
void IOWrapper::OutputAlignment(OutputCollector* collector, size_t lineNo , const vector<const Hypothesis *> &edges)
{
ostringstream out;
Hypothesis::OutputAlignment(out, edges);
collector->Write(lineNo,out.str());
}
void IOWrapper::OutputAlignment(OutputCollector* collector, size_t lineNo , const TrellisPath &path)
{
if (collector) {
OutputAlignment(collector,lineNo, path.GetEdges());
}
}
void IOWrapper::Backtrack(const Hypothesis *hypo)
{

View File

@ -166,8 +166,6 @@ public:
// CHART
// phrase-based
void OutputAlignment(Moses::OutputCollector* collector, size_t lineNo, const Moses::TrellisPath &path);
void OutputAlignment(OutputCollector* collector, size_t lineNo , const std::vector<const Hypothesis *> &edges);
// post editing
std::ifstream *spe_src, *spe_trg, *spe_aln;

View File

@ -1875,4 +1875,19 @@ void Manager::OutputBestHypo(const Moses::TrellisPath &path, long /*translationI
out << endl;
}
void Manager::OutputAlignment(OutputCollector* collector, size_t lineNo , const vector<const Hypothesis *> &edges)
{
ostringstream out;
Hypothesis::OutputAlignment(out, edges);
collector->Write(lineNo,out.str());
}
void Manager::OutputAlignment(OutputCollector* collector, size_t lineNo , const TrellisPath &path)
{
if (collector) {
OutputAlignment(collector,lineNo, path.GetEdges());
}
}
} // namespace

View File

@ -167,6 +167,9 @@ public:
char reportSegmentation, bool reportAllFactors, std::ostream& out) const;
void OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/,char reportSegmentation, bool reportAllFactors, std::ostream &out) const;
void OutputAlignment(Moses::OutputCollector* collector, size_t lineNo, const Moses::TrellisPath &path);
void OutputAlignment(OutputCollector* collector, size_t lineNo , const std::vector<const Hypothesis *> &edges);
#ifdef HAVE_PROTOBUF
void SerializeSearchGraphPB(long translationId, std::ostream& outputStream) const;
#endif

View File

@ -193,7 +193,7 @@ void TranslationTask::RunPb()
manager.OutputBestHypo(conBestHypo, m_source->GetTranslationId(),
staticData.GetReportSegmentation(),
staticData.GetReportAllFactors(),out);
m_ioWrapper.OutputAlignment(m_ioWrapper.GetAlignmentInfoCollector(), m_source->GetTranslationId(), conBestHypo);
manager.OutputAlignment(m_ioWrapper.GetAlignmentInfoCollector(), m_source->GetTranslationId(), conBestHypo);
IFVERBOSE(2) {
PrintUserTime("finished Consensus decoding");
}
@ -205,7 +205,7 @@ void TranslationTask::RunPb()
manager.OutputBestHypo(mbrBestHypo, m_source->GetTranslationId(),
staticData.GetReportSegmentation(),
staticData.GetReportAllFactors(),out);
m_ioWrapper.OutputAlignment(m_ioWrapper.GetAlignmentInfoCollector(), m_source->GetTranslationId(), mbrBestHypo);
manager.OutputAlignment(m_ioWrapper.GetAlignmentInfoCollector(), m_source->GetTranslationId(), mbrBestHypo);
IFVERBOSE(2) {
PrintUserTime("finished MBR decoding");
}