From 122b417694ce6211142d1e245e9c8dcb5b78c6ce Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 6 Feb 2018 13:34:09 -0500 Subject: Made cuts algorithm more aggressive --- kgramstats.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'kgramstats.cpp') 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 cur.pop_front(); } - if ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0)) + do { - cur.pop_front(); - cuts /= 2; - } + if ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0)) + { + cur.pop_front(); + cuts--; + } else { + break; + } + } while ((cur.size() > 2) && (cuts > 0) && ((rand() % cuts) > 0)); // Gotta circumvent the last line of the input corpus // https://twitter.com/starla4444/status/684222271339237376 @@ -711,7 +716,7 @@ std::string rawr::randomSentence(int maxL) const cuts++; } else if (cuts > 0) { // Otherwise, decrease cut chance - cuts--; + cuts /= 2; } if (next.corpora.size() == 1) -- cgit 1.4.1