about summary refs log tree commit diff stats
path: root/kgramstats.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-08-20 14:06:12 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-08-20 14:06:12 -0400
commitaeee9782b8331c93e4665663e9e759188197074e (patch)
treeee050993e1a572c9453813b0122918e9c430ef66 /kgramstats.cpp
parentc132dc01c600349ffe5c8ec8622b5393451b3db8 (diff)
downloadrawr-ebooks-aeee9782b8331c93e4665663e9e759188197074e.tar.gz
rawr-ebooks-aeee9782b8331c93e4665663e9e759188197074e.tar.bz2
rawr-ebooks-aeee9782b8331c93e4665663e9e759188197074e.zip
Marked rawr::randomSentence const
Diffstat (limited to 'kgramstats.cpp')
-rw-r--r--kgramstats.cpp6
1 files changed, 3 insertions, 3 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)
553} 553}
554 554
555// 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 555// 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
556std::string rawr::randomSentence(int maxL) 556std::string rawr::randomSentence(int maxL) const
557{ 557{
558 if (!_compiled) 558 if (!_compiled)
559 { 559 {
@@ -597,10 +597,10 @@ std::string rawr::randomSentence(int maxL)
597 cur = kgram(1, wildcardQuery); 597 cur = kgram(1, wildcardQuery);
598 } 598 }
599 599
600 auto& distribution = _stats[cur]; 600 auto& distribution = _stats.at(cur);
601 int max = distribution.rbegin()->first; 601 int max = distribution.rbegin()->first;
602 int r = rand() % max; 602 int r = rand() % max;
603 token_data& next = distribution.upper_bound(r)->second; 603 const token_data& next = distribution.upper_bound(r)->second;
604 std::string nextToken = next.tok.w.forms.next(); 604 std::string nextToken = next.tok.w.forms.next();
605 605
606 // Apply user-specified transforms 606 // Apply user-specified transforms