diff options
author | heafield <heafield@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-10-11 22:27:36 +0400 |
---|---|---|
committer | heafield <heafield@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-10-11 22:27:36 +0400 |
commit | 86f1d3ec71fa5a4ea9b831ba134e17e3b1e13120 (patch) | |
tree | 6317d93e4cb5c6c70ff4c3a1241dc4817db8b84c /kenlm | |
parent | ba41862d37b7d294bdde4ea44af1d91397c61f9f (diff) |
Fix trie for ARPAs from SRILM.
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4331 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'kenlm')
-rw-r--r-- | kenlm/lm/search_trie.cc | 5 | ||||
-rw-r--r-- | kenlm/lm/search_trie.hh | 2 | ||||
-rw-r--r-- | kenlm/util/scoped.hh | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/kenlm/lm/search_trie.cc b/kenlm/lm/search_trie.cc index b53aa8437..5d8c70db1 100644 --- a/kenlm/lm/search_trie.cc +++ b/kenlm/lm/search_trie.cc @@ -151,6 +151,11 @@ class BackoffMessages { private: void FinishedAdding() { Resize(current_ - (uint8_t*)backing_.get()); + // Sort requests in same order as files. + std::sort( + util::SizedIterator(util::SizedProxy(backing_.get(), entry_size_)), + util::SizedIterator(util::SizedProxy(current_, entry_size_)), + util::SizedCompare<EntryCompare>(EntryCompare((entry_size_ - sizeof(ProbPointer)) / sizeof(WordIndex)))); current_ = (uint8_t*)backing_.get(); } diff --git a/kenlm/lm/search_trie.hh b/kenlm/lm/search_trie.hh index c3e02a98c..33ae8cff5 100644 --- a/kenlm/lm/search_trie.hh +++ b/kenlm/lm/search_trie.hh @@ -36,7 +36,7 @@ template <class Quant, class Bhiksha> class TrieSearch { static const ModelType kModelType = static_cast<ModelType>(TRIE_SORTED + Quant::kModelTypeAdd + Bhiksha::kModelTypeAdd); - static const unsigned int kVersion = 0; + static const unsigned int kVersion = 1; static void UpdateConfigFromBinary(int fd, const std::vector<uint64_t> &counts, Config &config) { Quant::UpdateConfigFromBinary(fd, counts, config); diff --git a/kenlm/util/scoped.hh b/kenlm/util/scoped.hh index 12e6652b8..93e2e8176 100644 --- a/kenlm/util/scoped.hh +++ b/kenlm/util/scoped.hh @@ -50,7 +50,7 @@ class scoped_malloc { void call_realloc(std::size_t to) { void *ret; - UTIL_THROW_IF(!(ret = std::realloc(p_, to)), util::ErrnoException, "realloc to " << to << " bytes failed."); + UTIL_THROW_IF(!(ret = std::realloc(p_, to)) && to, util::ErrnoException, "realloc to " << to << " bytes failed."); p_ = ret; } |