mosesdecoder/contrib/moses2/TranslationTask.cpp

53 lines
1.0 KiB
C++
Raw Normal View History

2015-11-10 14:28:17 +03:00
#include "TranslationTask.h"
2016-02-26 14:52:35 +03:00
#include "System.h"
#include "InputType.h"
2016-02-26 18:19:20 +03:00
#include "PhraseBased/Manager.h"
2016-03-01 02:28:24 +03:00
#include "SCFG/Manager.h"
2015-11-10 14:28:17 +03:00
using namespace std;
2015-12-10 23:49:30 +03:00
namespace Moses2
{
TranslationTask::TranslationTask(System &system,
const std::string &line,
long translationId)
2015-11-10 14:28:17 +03:00
{
if (system.isPb) {
m_mgr = new Manager(system, *this, line, translationId);
}
else {
m_mgr = new SCFG::Manager(system, *this, line, translationId);
}
2015-11-10 14:28:17 +03:00
}
TranslationTask::~TranslationTask()
{
}
void TranslationTask::Run()
{
2016-04-12 13:24:04 +03:00
m_mgr->Decode();
2016-04-12 13:24:04 +03:00
string out;
2016-04-12 13:00:16 +03:00
out = m_mgr->OutputBest() + "\n";
m_mgr->system.bestCollector->Write(m_mgr->GetTranslationId(), out);
2016-04-12 13:24:04 +03:00
if (m_mgr->system.options.nbest.nbest_size) {
out = m_mgr->OutputNBest();
m_mgr->system.nbestCollector->Write(m_mgr->GetTranslationId(), out);
2016-04-12 13:00:16 +03:00
}
2016-08-15 15:21:29 +03:00
if (!m_mgr->system.options.output.detailed_transrep_filepath.empty()) {
out = m_mgr->OutputTransOpt();
m_mgr->system.detailedTranslationCollector->Write(m_mgr->GetTranslationId(), out);
}
delete m_mgr;
2015-11-10 14:28:17 +03:00
}
2015-12-10 23:49:30 +03:00
}