diff options
author | Kenneth Heafield <kheafiel@cluster10.lti.ece.cmu.local> | 2011-03-09 13:40:23 -0500 |
---|---|---|
committer | Kenneth Heafield <kheafiel@cluster10.lti.ece.cmu.local> | 2011-03-09 13:40:23 -0500 |
commit | 6c923d45f2aaf960806429d36ca58a41b3a39740 (patch) | |
tree | 9d8c5bf26189e9e8e6c12c199a5925c5ca6046a9 /klm/lm/model.cc | |
parent | 95ea293005f74a627fdd2aae318d5746fa8c4e6c (diff) |
kenlm sync
Diffstat (limited to 'klm/lm/model.cc')
-rw-r--r-- | klm/lm/model.cc | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/klm/lm/model.cc b/klm/lm/model.cc index 146fe07b..14949e97 100644 --- a/klm/lm/model.cc +++ b/klm/lm/model.cc @@ -82,25 +82,13 @@ template <class Search, class VocabularyT> void GenericModel<Search, VocabularyT search_.InitializeFromARPA(file, f, counts, config, vocab_, backing_); } - // TODO: fail faster? if (!vocab_.SawUnk()) { - switch(config.unknown_missing) { - case Config::THROW_UP: - { - SpecialWordMissingException e("<unk>"); - e << " and configuration was set to throw if unknown is missing"; - throw e; - } - case Config::COMPLAIN: - if (config.messages) *config.messages << "Language model is missing <unk>. Substituting probability " << config.unknown_missing_prob << "." << std::endl; - // There's no break;. This is by design. - case Config::SILENT: - // Default probabilities for unknown. - search_.unigram.Unknown().backoff = 0.0; - search_.unigram.Unknown().prob = config.unknown_missing_prob; - break; - } + assert(config.unknown_missing != Config::THROW_UP); + // Default probabilities for unknown. + search_.unigram.Unknown().backoff = 0.0; + search_.unigram.Unknown().prob = config.unknown_missing_prob; } + FinishFile(config, kModelType, counts, backing_); } template <class Search, class VocabularyT> FullScoreReturn GenericModel<Search, VocabularyT>::FullScore(const State &in_state, const WordIndex new_word, State &out_state) const { |