mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#include "TranslationTask.h"
|
|
#include "System.h"
|
|
#include "InputType.h"
|
|
#include "PhraseBased/Manager.h"
|
|
#include "SCFG/Manager.h"
|
|
|
|
using namespace std;
|
|
|
|
namespace Moses2
|
|
{
|
|
|
|
TranslationTask::TranslationTask(System &system,
|
|
const std::string &line,
|
|
long translationId)
|
|
{
|
|
if (system.isPb) {
|
|
m_mgr = new Manager(system, *this, line, translationId);
|
|
} else {
|
|
m_mgr = new SCFG::Manager(system, *this, line, translationId);
|
|
}
|
|
}
|
|
|
|
TranslationTask::~TranslationTask()
|
|
{
|
|
}
|
|
|
|
std::string TranslationTask::ReturnTranslation(bool nbest) const
|
|
{
|
|
m_mgr->Decode();
|
|
string out;
|
|
if (nbest) {
|
|
out = m_mgr->OutputNBest() + "\n";
|
|
}
|
|
else {
|
|
out = m_mgr->OutputBest() + "\n";
|
|
}
|
|
delete m_mgr;
|
|
return out;
|
|
}
|
|
|
|
void TranslationTask::Run()
|
|
{
|
|
|
|
m_mgr->Decode();
|
|
|
|
string out;
|
|
|
|
out = m_mgr->OutputBest() + "\n";
|
|
m_mgr->system.bestCollector->Write(m_mgr->GetTranslationId(), out);
|
|
|
|
if (m_mgr->system.options.nbest.nbest_size) {
|
|
out = m_mgr->OutputNBest();
|
|
m_mgr->system.nbestCollector->Write(m_mgr->GetTranslationId(), out);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
|