mosesdecoder/moses/TrainingTask.h

82 lines
2.0 KiB
C
Raw Normal View History

//-*- c++ -*-
2015-01-08 16:54:47 +03:00
#pragma once
#include <boost/smart_ptr/shared_ptr.hpp>
#include "moses/ThreadPool.h"
#include "moses/TranslationOptionCollection.h"
#include "moses/IOWrapper.h"
#include "moses/TranslationTask.h"
2015-01-08 16:54:47 +03:00
namespace Moses
{
class InputType;
class OutputCollector;
class TrainingTask : public Moses::TranslationTask
2015-01-08 16:54:47 +03:00
{
protected:
TrainingTask(boost::shared_ptr<Moses::InputType> const source,
2015-05-02 13:45:24 +03:00
boost::shared_ptr<Moses::IOWrapper> const ioWrapper)
: TranslationTask(source, ioWrapper)
{ }
2015-01-08 16:54:47 +03:00
public:
// factory function
static boost::shared_ptr<TrainingTask>
2015-05-02 13:45:24 +03:00
create(boost::shared_ptr<InputType> const& source) {
boost::shared_ptr<IOWrapper> nix;
boost::shared_ptr<TrainingTask> ret(new TrainingTask(source, nix));
ret->m_self = ret;
return ret;
2015-01-14 14:07:42 +03:00
}
2015-01-08 16:54:47 +03:00
// factory function
static boost::shared_ptr<TrainingTask>
create(boost::shared_ptr<InputType> const& source,
2015-05-02 13:45:24 +03:00
boost::shared_ptr<IOWrapper> const& ioWrapper) {
boost::shared_ptr<TrainingTask> ret(new TrainingTask(source, ioWrapper));
ret->m_self = ret;
2016-06-16 16:22:58 +03:00
ret->m_scope.reset(new ContextScope);
return ret;
}
// factory function
static boost::shared_ptr<TrainingTask>
create(boost::shared_ptr<InputType> const& source,
boost::shared_ptr<IOWrapper> const& ioWrapper,
2017-03-05 03:00:41 +03:00
boost::shared_ptr<ContextScope> const& scope) {
2016-06-16 16:22:58 +03:00
boost::shared_ptr<TrainingTask> ret(new TrainingTask(source, ioWrapper));
ret->m_self = ret;
ret->m_scope = scope;
return ret;
2015-01-14 14:07:42 +03:00
}
2015-01-08 16:54:47 +03:00
~TrainingTask()
{ }
2015-01-14 14:07:42 +03:00
void Run() {
StaticData::Instance().InitializeForInput(this->self());
2015-01-14 14:07:42 +03:00
2015-01-09 14:12:40 +03:00
std::cerr << *m_source << std::endl;
2015-01-14 14:07:42 +03:00
TranslationOptionCollection *transOptColl
2015-05-02 13:45:24 +03:00
= m_source->CreateTranslationOptionCollection(this->self());
2015-01-08 16:54:47 +03:00
transOptColl->CreateTranslationOptions();
delete transOptColl;
2015-01-14 14:07:42 +03:00
StaticData::Instance().CleanUpAfterSentenceProcessing(this->self());
2015-01-08 16:54:47 +03:00
}
private:
// Moses::InputType* m_source;
// Moses::IOWrapper &m_ioWrapper;
2015-01-08 16:54:47 +03:00
};
} //namespace