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-07-28 22:14:46 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-07-28 22:15:14 +0300
commit6ab2d4d3eb1bcf4e1c76be6a89e69cc288af4c4d (patch)
treeb2ed62a2338de05cdba58a1a0bfbba36d4e8317b
parent451016891e6e3757c743d329377ac797316da1ec (diff)
Removed ranking stuff prior to merge with master.mmt-mvp-v0.12.0
-rw-r--r--moses/TranslationModel/UG/mm/ug_bitext_sampler.h3
-rw-r--r--moses/TranslationModel/UG/mm/ug_prime_sampling1.h18
-rw-r--r--moses/TranslationModel/UG/mmsapt.cpp60
-rw-r--r--moses/TranslationModel/UG/mmsapt.h5
4 files changed, 7 insertions, 79 deletions
diff --git a/moses/TranslationModel/UG/mm/ug_bitext_sampler.h b/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
index a069ef008..ffb389129 100644
--- a/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
+++ b/moses/TranslationModel/UG/mm/ug_bitext_sampler.h
@@ -243,8 +243,7 @@ perform_ranked_sampling()
return m_ctr;
}
-// Ranked sampling sorts all samples by score and then considers the top-ranked
-// candidates for phrase extraction.
+// Uniform sampling
template<typename Token>
size_t
BitextSampler<Token>::
diff --git a/moses/TranslationModel/UG/mm/ug_prime_sampling1.h b/moses/TranslationModel/UG/mm/ug_prime_sampling1.h
deleted file mode 100644
index 661530cd4..000000000
--- a/moses/TranslationModel/UG/mm/ug_prime_sampling1.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; -*-
-// Functions for "priming" sample selection for sampling phrase tables.
-// Author: Ulrich Germann
-#pragma once
-#include "ug_bitext.h"
-#include "ug_sampling_bias.h"
-#include <vector>
-// #ifndef NO_MOSES
-namespace Moses {
-// #endif
-namespace bitext
-{
-
-} // end of namespace bitext
-// #ifndef NO_MOSES
-} // end of namespace Moses
-// #endif
-
diff --git a/moses/TranslationModel/UG/mmsapt.cpp b/moses/TranslationModel/UG/mmsapt.cpp
index a058d76dc..fb2dc147b 100644
--- a/moses/TranslationModel/UG/mmsapt.cpp
+++ b/moses/TranslationModel/UG/mmsapt.cpp
@@ -69,7 +69,7 @@ namespace Moses
, m_bias_log(NULL)
, m_bias_loglevel(0)
, m_lr_func(NULL)
- , m_sampling_method(ranked_sampling)
+ , m_sampling_method(random_sampling)
, bias_key(((char*)this)+3)
, cache_key(((char*)this)+2)
, context_key(((char*)this)+1)
@@ -236,9 +236,7 @@ namespace Moses
if ((m = param.find("method")) != param.end())
{
- if (m->second == "rank" || m->second == "ranked")
- m_sampling_method = ranked_sampling;
- else if (m->second == "random")
+ if (m->second == "random")
m_sampling_method = random_sampling;
else if (m->second == "full")
m_sampling_method = full_coverage;
@@ -823,65 +821,13 @@ namespace Moses
void
Mmsapt::
- set_bias_for_ranking(ttasksptr const& ttask, iptr<Bitext<Token> const> bt)
- { // thinking ahead: shard-specific set-up, for multi-shard Mmsapts
-
- sptr<ContextScope> const& scope = ttask->GetScope();
- if (!scope) return;
-
- sptr<vector<string> const> input = ttask->GetContextWindow();
- if (!input) return;
-
- sptr<ContextForQuery> context = scope->get<ContextForQuery>(bt.get(), true);
- boost::unique_lock<boost::shared_mutex> lock(context->lock);
- if (context->bias) return;
-
- if (!context->cache1) context->cache1.reset(new pstats::cache_t);
- if (!context->cache2) context->cache2.reset(new pstats::cache_t);
-
- // sptr<IOWrapper const> iowrapper = ttask->GetIOWrapper();
- // vector<string> input;
- // input.reserve(iowrapper->GetPastInput().size() +
- // iowrapper->GetFutureInput().size());
- // BOOST_FOREACH(sptr<InputType> const& s, iowrapper->GetPastInput())
- // input.push_back(s->ToString());
- // BOOST_FOREACH(sptr<InputType> const& s, iowrapper->GetFutureInput())
- // input.push_back(s->ToString());
-
- size_t N = 10 * m_default_sample_size;
- VERBOSE(1,"Priming bias for ranking. [" << HERE << "]" << endl);
-
- double t = util::WallTime();
- context->bias = prime_sampling1(*bt->V1, *bt->I1, *input, N);
- VERBOSE(1,"Priming took " << util::WallTime() - t << " sec. (wall) "
- << "[" << HERE << "]" << endl);
-
- }
-
- // void
- // Mmsapt::
- // set_bias_via_ranking(ttasksptr const& ttask)
- // {
- // sptr<ContextScope> const& scope = ttask->GetScope();
- // if (!scope) return;
- // sptr<SentenceBias> bias = scope->get<SentenceBias>(bias_key);
- // // For the time being, let's assume that ranking is always primed
- // // on the entire document and leave local priming for another day.
- // if (bias) return;
- // //
- // }
-
- void
- Mmsapt::
InitializeForInput(ttasksptr const& ttask)
{
sptr<ContextScope> const& scope = ttask->GetScope();
sptr<ContextForQuery> context = scope->get<ContextForQuery>(btfix.get(), true);
// set sampling bias, depending on sampling method specified
- if (m_sampling_method == ranked_sampling)
- set_bias_for_ranking(ttask, this->btfix);
- else if (m_sampling_method == random_sampling)
+ if (m_sampling_method == random_sampling)
set_bias_via_server(ttask);
else UTIL_THROW2("Unknown sampling method: " << m_sampling_method);
diff --git a/moses/TranslationModel/UG/mmsapt.h b/moses/TranslationModel/UG/mmsapt.h
index bea1bcfc2..827722865 100644
--- a/moses/TranslationModel/UG/mmsapt.h
+++ b/moses/TranslationModel/UG/mmsapt.h
@@ -2,6 +2,7 @@
// Sampling phrase table implementation based on memory-mapped suffix arrays.
// Design and code by Ulrich Germann.
#pragma once
+#define PROVIDES_RANKED_SAMPLING 0
#include <boost/thread.hpp>
#include <boost/scoped_ptr.hpp>
@@ -20,7 +21,6 @@
#include "moses/TranslationModel/UG/mm/ug_typedefs.h"
#include "moses/TranslationModel/UG/mm/tpt_pickler.h"
#include "moses/TranslationModel/UG/mm/ug_bitext.h"
-#include "moses/TranslationModel/UG/mm/ug_prime_sampling1.h"
#include "moses/TranslationModel/UG/mm/ug_bitext_sampler.h"
#include "moses/TranslationModel/UG/mm/ug_lexical_phrase_scorer2.h"
@@ -148,9 +148,10 @@ namespace Moses
void setup_local_feature_functions();
void set_bias_via_server(ttasksptr const& ttask);
+#if PROVIDES_RANKED_SAMPLING
void
set_bias_for_ranking(ttasksptr const& ttask, iptr<Bitext<Token> const> bt);
-
+#endif
private:
void read_config_file(std::string fname, std::map<std::string,std::string>& param);