about summary refs log tree commit diff stats
path: root/kgramstats.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-02-06 13:34:09 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-02-06 13:34:09 -0500
commit122b417694ce6211142d1e245e9c8dcb5b78c6ce (patch)
tree75d91b5f82f451a2cb3ad4f25967d184c572cb1b /kgramstats.cpp
parent247ee4de24eab5ecd030542724db9f69aaa1ed1a (diff)
downloadrawr-ebooks-122b417694ce6211142d1e245e9c8dcb5b78c6ce.tar.gz
rawr-ebooks-122b417694ce6211142d1e245e9c8dcb5b78c6ce.tar.bz2
rawr-ebooks-122b417694ce6211142d1e245e9c8dcb5b78c6ce.zip
Made cuts algorithm more aggressive
Diffstat (limited to 'kgramstats.cpp')
-rw-r--r--kgramstats.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/kgramstats.cpp b/kgramstats.cpp index 4a7eb9d..c674e80 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp
@@ -578,11 +578,16 @@ std::string rawr::randomSentence(int maxL) const
578 cur.pop_front(); 578 cur.pop_front();
579 } 579 }
580 580
581 if ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0)) 581 do
582 { 582 {
583 cur.pop_front(); 583 if ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0))
584 cuts /= 2; 584 {
585 } 585 cur.pop_front();
586 cuts--;
587 } else {
588 break;
589 }
590 } while ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0));
586 591
587 // Gotta circumvent the last line of the input corpus 592 // Gotta circumvent the last line of the input corpus
588 // https://twitter.com/starla4444/status/684222271339237376 593 // https://twitter.com/starla4444/status/684222271339237376
@@ -711,7 +716,7 @@ std::string rawr::randomSentence(int maxL) const
711 cuts++; 716 cuts++;
712 } else if (cuts > 0) { 717 } else if (cuts > 0) {
713 // Otherwise, decrease cut chance 718 // Otherwise, decrease cut chance
714 cuts--; 719 cuts /= 2;
715 } 720 }
716 721
717 if (next.corpora.size() == 1) 722 if (next.corpora.size() == 1)