From b9d7da0413403805f035479a0a426c27102032f6 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Fri, 3 Jun 2011 20:49:52 -0400 Subject: Add exception catcher around constructor --- decoder/ff_klm.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'decoder') diff --git a/decoder/ff_klm.cc b/decoder/ff_klm.cc index 35b35d36..71ba9f30 100644 --- a/decoder/ff_klm.cc +++ b/decoder/ff_klm.cc @@ -385,7 +385,12 @@ KLanguageModel::KLanguageModel(const string& param) { if (!ParseLMArgs(param, &filename, &mapfile, &explicit_markers, &featname)) { abort(); } - pimpl_ = new KLanguageModelImpl(filename, mapfile, explicit_markers); + try { + pimpl_ = new KLanguageModelImpl(filename, mapfile, explicit_markers); + } catch (std::exception &e) { + std::cerr << e.what() << std::endl; + abort(); + } fid_ = FD::Convert(featname); oov_fid_ = FD::Convert(featname+"_OOV"); cerr << "FID: " << oov_fid_ << endl; -- cgit v1.2.3 From dcf4447590277887d65b0bdec7e6818081869a9a Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Fri, 3 Jun 2011 20:56:37 -0400 Subject: Code cleanup for vocabulary mapping --- decoder/ff_klm.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'decoder') diff --git a/decoder/ff_klm.cc b/decoder/ff_klm.cc index 71ba9f30..a3bd0c5f 100644 --- a/decoder/ff_klm.cc +++ b/decoder/ff_klm.cc @@ -282,11 +282,10 @@ class KLanguageModelImpl { KLanguageModelImpl(const string& filename, const string& mapfile, bool explicit_markers) : kCDEC_UNK(TD::Convert("")) , add_sos_eos_(!explicit_markers) { - if (true) { - boost::scoped_ptr vm; - vm.reset(new VMapper(&cdec2klm_map_)); + { + VMapper vm(&cdec2klm_map_); lm::ngram::Config conf; - conf.enumerate_vocab = vm.get(); + conf.enumerate_vocab = &vm; ngram_ = new Model(filename.c_str(), conf); } order_ = ngram_->Order(); -- cgit v1.2.3