From aeee9782b8331c93e4665663e9e759188197074e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 20 Aug 2016 14:06:12 -0400 Subject: Marked rawr::randomSentence const --- kgramstats.cpp | 6 +++--- kgramstats.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kgramstats.cpp b/kgramstats.cpp index cb63db6..f171be9 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp @@ -553,7 +553,7 @@ void rawr::setMinCorpora(int _arg) } // runs in O(n log t) time where n is the input number of sentences and t is the number of tokens in the input corpus -std::string rawr::randomSentence(int maxL) +std::string rawr::randomSentence(int maxL) const { if (!_compiled) { @@ -597,10 +597,10 @@ std::string rawr::randomSentence(int maxL) cur = kgram(1, wildcardQuery); } - auto& distribution = _stats[cur]; + auto& distribution = _stats.at(cur); int max = distribution.rbegin()->first; int r = rand() % max; - token_data& next = distribution.upper_bound(r)->second; + const token_data& next = distribution.upper_bound(r)->second; std::string nextToken = next.tok.w.forms.next(); // Apply user-specified transforms diff --git a/kgramstats.h b/kgramstats.h index d939ade..2ee0e35 100644 --- a/kgramstats.h +++ b/kgramstats.h @@ -18,7 +18,7 @@ class rawr { void setTransformCallback(transform_callback _arg); void setMinCorpora(int _arg); - std::string randomSentence(int maxL); + std::string randomSentence(int maxL) const; private: struct terminator { -- cgit 1.4.1