diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-08-15 19:08:08 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-08-15 19:08:08 +0400 |
commit | 6efb6c0ffe7b7345b4b2349b1bd1b8f33dc6c7fd (patch) | |
tree | 967b456fadd97e2331f752a2d9624863ed2debb0 /lm/model.cc | |
parent | 701fa7dd6c4ea35b4d0e6e3dc4b7a2f81443a0d9 (diff) |
Throw exception for binary files with too large order / Ondrej Bojar
Diffstat (limited to 'lm/model.cc')
-rw-r--r-- | lm/model.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lm/model.cc b/lm/model.cc index 6547ba03d..aace40df9 100644 --- a/lm/model.cc +++ b/lm/model.cc @@ -48,6 +48,7 @@ template <class Search, class VocabularyT> GenericModel<Search, VocabularyT>::Ge } template <class Search, class VocabularyT> void GenericModel<Search, VocabularyT>::InitializeFromBinary(void *start, const Parameters ¶ms, const Config &config, int fd) { + UTIL_THROW_IF(params.counts.size() > KENLM_MAX_ORDER, FormatLoadException, "This model has order " << params.counts.size() << ". Re-compile (use -a), passing a number at least this large to bjam's --max-kenlm-order flag."); SetupMemory(start, params.counts, config); vocab_.LoadedBinary(params.fixed.has_vocabulary, fd, config.enumerate_vocab); search_.LoadedBinary(); @@ -61,7 +62,7 @@ template <class Search, class VocabularyT> void GenericModel<Search, VocabularyT // File counts do not include pruned trigrams that extend to quadgrams etc. These will be fixed by search_. ReadARPACounts(f, counts); - if (counts.size() > KENLM_MAX_ORDER) UTIL_THROW(FormatLoadException, "This model has order " << counts.size() << ". Re-compile, passing a number at least this large to bjam's --max-kenlm-order flag."); + UTIL_THROW_IF(counts.size() > KENLM_MAX_ORDER, FormatLoadException, "This model has order " << counts.size() << ". Re-compile (use -a), passing a number at least this large to bjam's --max-kenlm-order flag."); if (counts.size() < 2) UTIL_THROW(FormatLoadException, "This ngram implementation assumes at least a bigram model."); if (config.probing_multiplier <= 1.0) UTIL_THROW(ConfigException, "probing multiplier must be > 1.0"); |