diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-03-30 01:51:22 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-03-30 01:51:22 +0300 |
commit | 18d254749729396885d10c9ce9dec12d7c2c84bd (patch) | |
tree | 9241b78e6c4573b88c8bfc62b764897580a57a31 | |
parent | 1525f1ea621f7232ec6b23ef5de98a0b0da4d0ba (diff) |
Added member for storing annotations by feature functions.
-rw-r--r-- | moses/TranslationTask.cpp | 2 | ||||
-rw-r--r-- | moses/TranslationTask.h | 23 |
2 files changed, 20 insertions, 5 deletions
diff --git a/moses/TranslationTask.cpp b/moses/TranslationTask.cpp index 9100cd3ed..92bf12156 100644 --- a/moses/TranslationTask.cpp +++ b/moses/TranslationTask.cpp @@ -30,6 +30,7 @@ TranslationTask boost::shared_ptr<IOWrapper> nix; boost::shared_ptr<TranslationTask> ret(new TranslationTask(source, nix)); ret->m_self = ret; + ret->m_scope.reset(new ContextScope); return ret; } @@ -40,6 +41,7 @@ TranslationTask { boost::shared_ptr<TranslationTask> ret(new TranslationTask(source, ioWrapper)); ret->m_self = ret; + ret->m_scope.reset(new ContextScope); return ret; } diff --git a/moses/TranslationTask.h b/moses/TranslationTask.h index 0c800d1f2..c51750bdd 100644 --- a/moses/TranslationTask.h +++ b/moses/TranslationTask.h @@ -8,6 +8,7 @@ #include "moses/IOWrapper.h" #include "moses/Manager.h" #include "moses/ChartManager.h" +#include "moses/ContextScope.h" #include "moses/Syntax/F2S/Manager.h" #include "moses/Syntax/S2T/Manager.h" @@ -17,6 +18,11 @@ #include <boost/weak_ptr.hpp> #include <boost/make_shared.hpp> +#ifdef WITH_THREADS +#include <boost/thread/shared_mutex.hpp> +#include <boost/thread/locks.hpp> +#endif + namespace Moses { class InputType; @@ -38,7 +44,8 @@ class TranslationTask : public Moses::Task protected: boost::weak_ptr<TranslationTask> m_self; // weak ptr to myself - + boost::shared_ptr<ContextScope> m_scope; // sores local info + // pointer to ContextScope, which stores context-specific information TranslationTask() { } ; TranslationTask(boost::shared_ptr<Moses::InputType> const& source, boost::shared_ptr<Moses::IOWrapper> const& ioWrapper); @@ -56,10 +63,9 @@ protected: // function can determine (via a check on the weak pointer) if the // task is still live or not, or maintain a shared_ptr to ensure the // task stays alive till it's done with it. - + public: - - virtual + boost::shared_ptr<TranslationTask> self() { return m_self.lock(); } @@ -90,7 +96,14 @@ public: boost::shared_ptr<BaseManager> SetupManager(SearchAlgorithm algo = DefaultSearchAlgorithm); - + + boost::shared_ptr<ContextScope> const& + GetScope() const + { + UTIL_THROW_IF2(m_scope == NULL, "No context scope!"); + return m_scope; + } + protected: boost::shared_ptr<Moses::InputType> m_source; boost::shared_ptr<Moses::IOWrapper> m_ioWrapper; |