about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--kgramstats.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/kgramstats.cpp b/kgramstats.cpp index 07f41f6..d94ae06 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp
@@ -477,21 +477,17 @@ std::string kgramstats::randomSentence(int n)
477 477
478 if (cur.size() > 0) 478 if (cur.size() > 0)
479 { 479 {
480 while ((cur.size() > 1) && (cuts > 0)) 480 if (rand() % (maxK - cur.size() + 1) == 0)
481 { 481 {
482 int under = maxK - cur.size(); 482 while ((cur.size() > 2) && (cuts > 0))
483 int tunder = i - 1;
484 for (int j = 0; j < under; j++)
485 { 483 {
486 tunder /= 2; 484 if ((rand() % cuts) > 2)
487 } 485 {
488 486 cur.pop_front();
489 if ((rand() % cuts) < tunder) 487 cuts--;
490 { 488 } else {
491 cur.pop_front(); 489 break;
492 cuts -= under; 490 }
493 } else {
494 break;
495 } 491 }
496 } 492 }
497 } 493 }