diff --git a/modules/Markov.py b/modules/Markov.py index 5b5f42b..ffb15ae 100644 --- a/modules/Markov.py +++ b/modules/Markov.py @@ -406,6 +406,14 @@ class Markov(Module): if gen_words[-1] == self.stop: gen_words = gen_words[:-1] + # monkey with the end word to make it more like an actual sentence end + sentence_end = gen_words[-1] + eos_punctuation = ['!', '?', ',', '.'] + if sentence_end[-1] not in eos_punctuation: + random.shuffle(eos_punctuation) + gen_words[-1] = sentence_end + eos_punctuation.pop() + self.log.debug("monkeyed with end of sentence, it's now: {0:s}".format(gen_words[:-1])) + # new word 1 key_hits = self._retrieve_chains_for_key(self.start1, self.start2, context_id) gen_words.append(self._get_suitable_word_from_choices(key_hits, gen_words, min_size))