diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-27 21:52:59 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-27 21:52:59 -0500 |
commit | 1890eb5d4a496aea5e9114550081ca63bd280f3b (patch) | |
tree | 3733924c6adc7eccc14d8c9b16c1ed19f86f0be9 | |
parent | 47d9ba41accf6410bb9cf26b49a1c76129a49975 (diff) | |
download | rawr-ebooks-1890eb5d4a496aea5e9114550081ca63bd280f3b.tar.gz rawr-ebooks-1890eb5d4a496aea5e9114550081ca63bd280f3b.tar.bz2 rawr-ebooks-1890eb5d4a496aea5e9114550081ca63bd280f3b.zip |
Allow the sentence to end at the end of a corpus
-rw-r--r-- | kgramstats.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/kgramstats.cpp b/kgramstats.cpp index 7ece80f..b0a83dc 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp | |||
@@ -625,6 +625,13 @@ std::string rawr::randomSentence(int maxL) const | |||
625 | // https://twitter.com/starla4444/status/684222271339237376 | 625 | // https://twitter.com/starla4444/status/684222271339237376 |
626 | if (_stats.count(cur) == 0) | 626 | if (_stats.count(cur) == 0) |
627 | { | 627 | { |
628 | // The end of a corpus should probably be treated like a terminator, so | ||
629 | // maybe we should just end here. | ||
630 | if ((result.length() > maxL) || (rand() % 4 == 0)) | ||
631 | { | ||
632 | break; | ||
633 | } | ||
634 | |||
628 | cur = kgram(1, wildcardQuery); | 635 | cur = kgram(1, wildcardQuery); |
629 | } | 636 | } |
630 | 637 | ||