Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-08-06 02:51:02 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-08-06 23:11:43 +0300
commit524109e2cabe5bd3ac693d3187e439885484a8c7 (patch)
treeed0bf9862bc6a50c327dd235efe3a038d2b0b2e2 /moses/Search.cpp
parentfc10ad4afb812200d7529256797a10438cfaf1f3 (diff)
Reorganisation of options.
The purpose of this effort is to have options local to the individual translation task, so that they can be changed in the running system in a multi-threaded system.
Diffstat (limited to 'moses/Search.cpp')
-rw-r--r--moses/Search.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/moses/Search.cpp b/moses/Search.cpp
index 8f947f622..7412d996b 100644
--- a/moses/Search.cpp
+++ b/moses/Search.cpp
@@ -9,15 +9,20 @@ namespace Moses
Search::Search(Manager& manager)
: m_manager(manager)
- ,m_inputPath()
- ,m_initialTransOpt()
+ , m_inputPath()
+ , m_initialTransOpt()
+ , m_options(manager.options())
+ , interrupted_flag(0)
{
m_initialTransOpt.SetInputPath(m_inputPath);
}
-Search *Search::CreateSearch(Manager& manager, const InputType &source,
- SearchAlgorithm searchAlgorithm, const TranslationOptionCollection &transOptColl)
+Search *
+Search::
+CreateSearch(Manager& manager, const InputType &source,
+ SearchAlgorithm searchAlgorithm,
+ const TranslationOptionCollection &transOptColl)
{
switch(searchAlgorithm) {
case Normal:
@@ -32,4 +37,18 @@ Search *Search::CreateSearch(Manager& manager, const InputType &source,
}
}
+bool
+Search::
+out_of_time()
+{
+ int const& timelimit = m_options.search.timeout;
+ if (!timelimit) return false;
+ double elapsed_time = GetUserTime();
+ if (elapsed_time <= timelimit) return false;
+ VERBOSE(1,"Decoding is out of time (" << elapsed_time << ","
+ << timelimit << ")" << std::endl);
+ interrupted_flag = 1;
+ return true;
+}
+
}