markov: be smarter with appending punctuation

don't append commas ever (it looks weird), ignore other situations
where the chain already ends with punctation so we don't need more
This commit is contained in:
Brian S. Stephan 2016-06-30 22:46:47 -05:00
parent db3e2a27a0
commit ccfc5e7484
1 changed files with 2 additions and 2 deletions

View File

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