summaryrefslogtreecommitdiff
path: root/klm/lm/search_trie.cc
diff options
context:
space:
mode:
authorKenneth Heafield <kenlm@kheafield.com>2011-10-11 14:58:52 -0400
committerKenneth Heafield <kenlm@kheafield.com>2011-10-11 14:58:52 -0400
commit0e1ffb6c1528e44f63ae8bac466bd5163e973974 (patch)
treeb7e87170f91d691b57616917a9cb6e58f5b4c2cc /klm/lm/search_trie.cc
parent0af7d663194beddcde420349bbd91430e0b2e423 (diff)
Trie fixes for SRI
Diffstat (limited to 'klm/lm/search_trie.cc')
-rw-r--r--klm/lm/search_trie.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/klm/lm/search_trie.cc b/klm/lm/search_trie.cc
index 6479813b..5d8c70db 100644
--- a/klm/lm/search_trie.cc
+++ b/klm/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();
}
@@ -525,7 +530,7 @@ template <class Quant, class Bhiksha> void BuildTrie(const std::string &file_pre
const RecordReader &context = contexts[order - 2];
if (context) {
FormatLoadException e;
- e << "An " << static_cast<unsigned int>(order) << "-gram has context";
+ e << "A " << static_cast<unsigned int>(order) << "-gram has context";
const WordIndex *ctx = reinterpret_cast<const WordIndex*>(context.Data());
for (const WordIndex *i = ctx; i != ctx + order - 1; ++i) {
e << ' ' << *i;