about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-02-27 21:52:59 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-02-27 21:52:59 -0500
commit1890eb5d4a496aea5e9114550081ca63bd280f3b (patch)
tree3733924c6adc7eccc14d8c9b16c1ed19f86f0be9
parent47d9ba41accf6410bb9cf26b49a1c76129a49975 (diff)
downloadrawr-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.cpp7
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
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291