Markov: only add sentence punctuation if necessary

This commit is contained in:
Brian S. Stephan 2014-05-03 20:54:12 -05:00
parent 676d109f57
commit dbc3d16f65
1 changed files with 2 additions and 1 deletions

View File

@ -158,7 +158,8 @@ def _generate_line(context, topics=None, min_words=15, max_words=30):
if len(line) >= min_words:
return line
else:
line[-1] += random.choice([',', '.', '!'])
if line[-1][-1] not in [',', '.', '!']:
line[-1] += random.choice([',', '.', '!'])
tries += 1