From 14392acc8f41e3ed9e834573cfab433a54d4b68b Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Sun, 4 Nov 2012 15:36:42 -0500 Subject: KenLM 36b746 including -w mmap offset fix --- lm/model.cc | 2 +- lm/vocab.cc | 7 +++++-- lm/vocab.hh | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'lm') diff --git a/lm/model.cc b/lm/model.cc index 2fd204815..d045954e8 100644 --- a/lm/model.cc +++ b/lm/model.cc @@ -87,7 +87,7 @@ template void GenericModel(copied), str.size()); } ++end_; // This is 1 + the offset where it was inserted to make room for unk. @@ -126,7 +128,7 @@ WordIndex SortedVocabulary::Insert(const StringPiece &str) { void SortedVocabulary::FinishedLoading(ProbBackoff *reorder_vocab) { if (enumerate_) { if (!strings_to_enumerate_.empty()) { - util::PairedIterator values(reorder_vocab + 1, &*strings_to_enumerate_.begin()); + util::PairedIterator values(reorder_vocab + 1, &*strings_to_enumerate_.begin()); util::JointSort(begin_, end_, values); } for (WordIndex i = 0; i < static_cast(end_ - begin_); ++i) { @@ -134,6 +136,7 @@ void SortedVocabulary::FinishedLoading(ProbBackoff *reorder_vocab) { enumerate_->Add(i + 1, strings_to_enumerate_[i]); } strings_to_enumerate_.clear(); + string_backing_.FreeAll(); } else { util::JointSort(begin_, end_, reorder_vocab + 1); } diff --git a/lm/vocab.hh b/lm/vocab.hh index de54eb064..3902f1174 100644 --- a/lm/vocab.hh +++ b/lm/vocab.hh @@ -4,6 +4,7 @@ #include "lm/enumerate_vocab.hh" #include "lm/lm_exception.hh" #include "lm/virtual_interface.hh" +#include "util/pool.hh" #include "util/probing_hash_table.hh" #include "util/sorted_uniform.hh" #include "util/string_piece.hh" @@ -96,7 +97,9 @@ class SortedVocabulary : public base::Vocabulary { EnumerateVocab *enumerate_; // Actual strings. Used only when loading from ARPA and enumerate_ != NULL - std::vector strings_to_enumerate_; + util::Pool string_backing_; + + std::vector strings_to_enumerate_; }; #pragma pack(push) -- cgit v1.2.3