diff options
| author | Kenneth Heafield <github@kheafield.com> | 2012-10-22 11:35:31 -0400 | 
|---|---|---|
| committer | Kenneth Heafield <github@kheafield.com> | 2012-10-22 11:36:10 -0400 | 
| commit | 7278218f4581ed8da3dacbff9c7ff3834c292dab (patch) | |
| tree | f343175050c24ba50cc8316d210f3fff52ff8323 /decoder/decoder.cc | |
| parent | 310e06dea1f4fd1eb1d3a8a80ee3ad57358188e1 (diff) | |
Remove global variable, have decoder hold a pointer
Diffstat (limited to 'decoder/decoder.cc')
| -rw-r--r-- | decoder/decoder.cc | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/decoder/decoder.cc b/decoder/decoder.cc index fe812011..b5f4b9b6 100644 --- a/decoder/decoder.cc +++ b/decoder/decoder.cc @@ -4,6 +4,7 @@  #include <boost/program_options.hpp>  #include <boost/program_options/variables_map.hpp>  #include <boost/make_shared.hpp> +#include <boost/scoped_ptr.hpp>  #include "program_options.h"  #include "stringlib.h" @@ -325,6 +326,8 @@ struct DecoderImpl {    bool feature_expectations; // TODO Observer    bool output_training_vector; // TODO Observer    bool remove_intersected_rule_annotations; +  boost::scoped_ptr<IncrementalBase> incremental; +    static void ConvertSV(const SparseVector<prob_t>& src, SparseVector<double>* trg) {      for (SparseVector<prob_t>::const_iterator it = src.begin(); it != src.end(); ++it) @@ -727,6 +730,10 @@ DecoderImpl::DecoderImpl(po::variables_map& conf, int argc, char** argv, istream    sent_id = -1;    acc_obj = 0; // accumulate objective    g_count = 0;    // number of gradient pieces computed + +  if (conf.count("incremental_search")) { +    incremental.reset(IncrementalBase::Load(conf["incremental_search"].as<string>().c_str(), CurrentWeightVector())); +  }  }  Decoder::Decoder(istream* cfg) { pimpl_.reset(new DecoderImpl(conf,0,0,cfg)); } @@ -829,7 +836,7 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) {      HypergraphIO::WriteTarget(conf["show_target_graph"].as<string>(), sent_id, forest);    if (conf.count("incremental_search")) { -    PassToIncremental(conf["incremental_search"].as<string>().c_str(), CurrentWeightVector(), pop_limit, forest); +    incremental->Search(pop_limit, forest);      o->NotifyDecodingComplete(smeta);      return true;    } | 
