diff options
Diffstat (limited to 'kgramstats.cpp')
-rw-r--r-- | kgramstats.cpp | 6 |
1 files changed, 3 insertions, 3 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 |
556 | std::string rawr::randomSentence(int maxL) | 556 | std::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 |