summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-09-13 07:53:16 -0700
committerKenneth Heafield <github@kheafield.com>2012-09-13 07:53:16 -0700
commitc32c03c1e0bb1e0407c90032cd3bf41f8bd61251 (patch)
treee20360c7bf8950dfcfc15579acf67decf0cefb16
parentb901df059531aad2f7d11b1e1ce13f9a9cb1c8ef (diff)
Steal cubepruning_pop_limit command line argument
-rw-r--r--decoder/decoder.cc2
-rw-r--r--decoder/lazy.cc19
-rw-r--r--decoder/lazy.h2
3 files changed, 12 insertions, 11 deletions
diff --git a/decoder/decoder.cc b/decoder/decoder.cc
index 525c6ba6..83077a68 100644
--- a/decoder/decoder.cc
+++ b/decoder/decoder.cc
@@ -835,7 +835,7 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) {
HypergraphIO::WriteTarget(conf["show_target_graph"].as<string>(), sent_id, forest);
if (conf.count("lazy_search"))
- PassToLazy(conf["lazy_search"].as<string>().c_str(), CurrentWeightVector(), forest);
+ PassToLazy(conf["lazy_search"].as<string>().c_str(), CurrentWeightVector(), pop_limit, forest);
for (int pass = 0; pass < rescoring_passes.size(); ++pass) {
const RescoringPass& rp = rescoring_passes[pass];
diff --git a/decoder/lazy.cc b/decoder/lazy.cc
index 9d69dac6..0f12a1ff 100644
--- a/decoder/lazy.cc
+++ b/decoder/lazy.cc
@@ -44,13 +44,13 @@ class LazyBase {
public:
LazyBase(const std::vector<weight_t> &weights) :
cdec_weights_(weights),
- config_(search::Weights(weights[FD::Convert("KLanguageModel")], weights[FD::Convert("KLanguageModel_OOV")], weights[FD::Convert("WordPenalty")]), 1000) {
- std::cerr << "Weights KLanguageModel " << config_.GetWeights().LM() << " KLanguageModel_OOV " << config_.GetWeights().OOV() << " WordPenalty " << config_.GetWeights().WordPenalty() << std::endl;
+ weights_(weights[FD::Convert("KLanguageModel")], weights[FD::Convert("KLanguageModel_OOV")], weights[FD::Convert("WordPenalty")]) {
+ std::cerr << "Weights KLanguageModel " << weights_.LM() << " KLanguageModel_OOV " << weights_.OOV() << " WordPenalty " << weights_.WordPenalty() << std::endl;
}
virtual ~LazyBase() {}
- virtual void Search(const Hypergraph &hg) const = 0;
+ virtual void Search(unsigned int pop_limit, const Hypergraph &hg) const = 0;
static LazyBase *Load(const char *model_file, const std::vector<weight_t> &weights);
@@ -65,14 +65,14 @@ class LazyBase {
const std::vector<weight_t> &cdec_weights_;
- const search::Config config_;
+ const search::Weights weights_;
};
template <class Model> class Lazy : public LazyBase {
public:
Lazy(const char *model_file, const std::vector<weight_t> &weights) : LazyBase(weights), m_(model_file, GetConfig()) {}
- void Search(const Hypergraph &hg) const;
+ void Search(unsigned int pop_limit, const Hypergraph &hg) const;
private:
void ConvertEdge(const search::Context<Model> &context, bool final, search::Vertex *vertices, const Hypergraph::Edge &in, search::Edge &out) const;
@@ -105,10 +105,11 @@ void PrintFinal(const Hypergraph &hg, const search::Edge *edge_base, const searc
}
}
-template <class Model> void Lazy<Model>::Search(const Hypergraph &hg) const {
+template <class Model> void Lazy<Model>::Search(unsigned int pop_limit, const Hypergraph &hg) const {
boost::scoped_array<search::Vertex> out_vertices(new search::Vertex[hg.nodes_.size()]);
boost::scoped_array<search::Edge> out_edges(new search::Edge[hg.edges_.size()]);
- search::Context<Model> context(config_, m_);
+ search::Config config(weights_, pop_limit);
+ search::Context<Model> context(config, m_);
for (unsigned int i = 0; i < hg.nodes_.size(); ++i) {
search::Vertex &out_vertex = out_vertices[i];
@@ -165,9 +166,9 @@ boost::scoped_ptr<LazyBase> AwfulGlobalLazy;
} // namespace
-void PassToLazy(const char *model_file, const std::vector<weight_t> &weights, const Hypergraph &hg) {
+void PassToLazy(const char *model_file, const std::vector<weight_t> &weights, unsigned int pop_limit, const Hypergraph &hg) {
if (!AwfulGlobalLazy.get()) {
AwfulGlobalLazy.reset(LazyBase::Load(model_file, weights));
}
- AwfulGlobalLazy->Search(hg);
+ AwfulGlobalLazy->Search(pop_limit, hg);
}
diff --git a/decoder/lazy.h b/decoder/lazy.h
index d1f030d1..94895b19 100644
--- a/decoder/lazy.h
+++ b/decoder/lazy.h
@@ -6,6 +6,6 @@
class Hypergraph;
-void PassToLazy(const char *model_file, const std::vector<weight_t> &weights, const Hypergraph &hg);
+void PassToLazy(const char *model_file, const std::vector<weight_t> &weights, unsigned int pop_limit, const Hypergraph &hg);
#endif // _LAZY_H_