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:
parent
dbc3d16f65
commit
2917ea9626
|
@ -148,13 +148,17 @@ def _generate_longish_sentence(context, topics=None, min_words=4, max_words=30):
|
||||||
return _generate_sentence(context)
|
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."""
|
"""String multiple sentences together into a coherent sentence."""
|
||||||
|
|
||||||
tries = 0
|
tries = 0
|
||||||
|
sentences = 0
|
||||||
line = []
|
line = []
|
||||||
while tries < 5:
|
while tries < 5:
|
||||||
line += _generate_longish_sentence(context, topics=topics, max_words=max_words)
|
line += _generate_longish_sentence(context, topics=topics, max_words=max_words)
|
||||||
|
sentences += 1
|
||||||
|
if sentences >= max_sentences:
|
||||||
|
return line
|
||||||
if len(line) >= min_words:
|
if len(line) >= min_words:
|
||||||
return line
|
return line
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue