From ab46925fccf86a361426a5363cf644c0a6b03057 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 9 Feb 2016 23:24:57 -0500 Subject: Tweaked kgram cut rate again --- kgramstats.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'kgramstats.cpp') diff --git a/kgramstats.cpp b/kgramstats.cpp index e6048d9..ac694f3 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp @@ -437,9 +437,9 @@ std::string kgramstats::randomSentence(int n) { if (rand() % (maxK - cur.size() + 1) == 0) { - while (cur.size() > 2) + while ((cur.size() > 2) && (cuts > 0)) { - if ((rand() % (n)) < cuts) + if ((rand() % cuts) > 2) { cur.pop_front(); cuts--; @@ -448,8 +448,6 @@ std::string kgramstats::randomSentence(int n) } } } - - cuts++; } // Gotta circumvent the last line of the input corpus @@ -556,6 +554,12 @@ std::string kgramstats::randomSentence(int n) { nextToken.append(","); } + + // If this pick was guaranteed, increase cut chance + if (next.all == max) + { + cuts++; + } /* DEBUG */ printKgram(cur); -- cgit 1.4.1