diff --git a/markov/views.py b/markov/views.py index a5a5690..7a45f43 100644 --- a/markov/views.py +++ b/markov/views.py @@ -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: