Markov: indicate # sentences we want in a line

before we were just adding words until we hit the min/max, now let's
also count the number of sentences and have a cutoff there, if we don't
want the whole appending thing no matter what
This commit is contained in:
Brian S. Stephan 2014-05-03 20:56:33 -05:00
parent dbc3d16f65
commit 2917ea9626
1 changed files with 5 additions and 1 deletions

View File

@ -148,13 +148,17 @@ def _generate_longish_sentence(context, topics=None, min_words=4, max_words=30):
return _generate_sentence(context)
def _generate_line(context, topics=None, min_words=15, max_words=30):
def _generate_line(context, topics=None, min_words=15, max_words=30, max_sentences=3):
"""String multiple sentences together into a coherent sentence."""
tries = 0
sentences = 0
line = []
while tries < 5:
line += _generate_longish_sentence(context, topics=topics, max_words=max_words)
sentences += 1
if sentences >= max_sentences:
return line
if len(line) >= min_words:
return line
else: