diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-03-26 21:25:54 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-03-26 21:25:54 +0300 |
commit | 9dc75bfd8ad3092f08f7a6d2a6492323b7803e56 (patch) | |
tree | f13405e11bce5001e6718ae0089fdcf85d961c98 /moses/TrainingTask.h | |
parent | 4410e9225a5bd495fc6d097b206290beb59f4839 (diff) |
Managers and feature functions now have access to the entire TranslationTask, not just the InputType.
Diffstat (limited to 'moses/TrainingTask.h')
-rw-r--r-- | moses/TrainingTask.h | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/moses/TrainingTask.h b/moses/TrainingTask.h index 885e8fd16..e4d792430 100644 --- a/moses/TrainingTask.h +++ b/moses/TrainingTask.h @@ -1,9 +1,11 @@ +//-*- c++ -*- #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" namespace Moses { @@ -11,35 +13,57 @@ class InputType; class OutputCollector; -class TrainingTask : public Moses::Task +class TrainingTask : public Moses::TranslationTask { +protected: + TrainingTask(boost::shared_ptr<Moses::InputType> const source, + boost::shared_ptr<Moses::IOWrapper> const ioWrapper) + : TranslationTask(source, ioWrapper) + { } + public: - TrainingTask(Moses::InputType* source, Moses::IOWrapper &ioWrapper) - : m_source(source) - , m_ioWrapper(ioWrapper) { + // factory function + static boost::shared_ptr<TrainingTask> + 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; } - ~TrainingTask() { + // factory function + static boost::shared_ptr<TrainingTask> + create(boost::shared_ptr<InputType> const& source, + boost::shared_ptr<IOWrapper> const& ioWrapper) + { + boost::shared_ptr<TrainingTask> ret(new TrainingTask(source, ioWrapper)); + ret->m_self = ret; + return ret; } + ~TrainingTask() + { } + void Run() { - StaticData::Instance().InitializeForInput(*m_source); + StaticData::Instance().InitializeForInput(this->self()); std::cerr << *m_source << std::endl; - TranslationOptionCollection *transOptColl = m_source->CreateTranslationOptionCollection(); + TranslationOptionCollection *transOptColl + = m_source->CreateTranslationOptionCollection(); transOptColl->CreateTranslationOptions(); delete transOptColl; - StaticData::Instance().CleanUpAfterSentenceProcessing(*m_source); + StaticData::Instance().CleanUpAfterSentenceProcessing(this->self()); } private: - Moses::InputType* m_source; - Moses::IOWrapper &m_ioWrapper; + // Moses::InputType* m_source; + // Moses::IOWrapper &m_ioWrapper; }; |