summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-06-06 21:06:02 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-06-06 21:06:02 -0400
commit925d74ce8a92ec6e73f41a4f0685bf3ca7b865d1 (patch)
tree42b913743e23527dd36b5b5e2f165ef2dea8a405 /decoder
parent7b39f6f36d737b6de0f551a9f814e303fc0cbd34 (diff)
parent31da1c7bd7ebc0636d1323df6ceb2fc5ee581f72 (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'decoder')
-rw-r--r--decoder/ff_klm.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/decoder/ff_klm.cc b/decoder/ff_klm.cc
index 35b35d36..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("<unk>")) ,
add_sos_eos_(!explicit_markers) {
- if (true) {
- boost::scoped_ptr<lm::ngram::EnumerateVocab> 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();
@@ -385,7 +384,12 @@ KLanguageModel<Model>::KLanguageModel(const string& param) {
if (!ParseLMArgs(param, &filename, &mapfile, &explicit_markers, &featname)) {
abort();
}
- pimpl_ = new KLanguageModelImpl<Model>(filename, mapfile, explicit_markers);
+ try {
+ pimpl_ = new KLanguageModelImpl<Model>(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;