about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--kgramstats.cpp6
-rw-r--r--kgramstats.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/kgramstats.cpp b/kgramstats.cpp index 426603f..17c3c2d 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
diff --git a/kgramstats.h b/kgramstats.h index d939ade..2ee0e35 100644 --- a/kgramstats.h +++ b/kgramstats.h
@@ -18,7 +18,7 @@ class rawr {
18 18
19 void setTransformCallback(transform_callback _arg); 19 void setTransformCallback(transform_callback _arg);
20 void setMinCorpora(int _arg); 20 void setMinCorpora(int _arg);
21 std::string randomSentence(int maxL); 21 std::string randomSentence(int maxL) const;
22 22
23 private: 23 private:
24 struct terminator { 24 struct terminator {