From 5913a95165621cfb19417bc643942d30da8b4539 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Thu, 17 Mar 2011 17:24:11 -0500 Subject: [PATCH] Markov: append a stop if we have nothing to append from a chain somehow a chain led us down a path where there are no values for the keys in the chain. if that happens, just abort. i'm not quite sure how this could happen --- modules/Markov.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/Markov.py b/modules/Markov.py index 0a681b0..22ac1cc 100644 --- a/modules/Markov.py +++ b/modules/Markov.py @@ -284,6 +284,8 @@ class Markov(Module): else: if len(gen_words) < min_size and len(filter(lambda a: a != self.stop, key_hits)) > 0: gen_words.append(random.choice(filter(lambda a: a != self.stop, key_hits))) + elif len(key_hits) <= 0: + gen_words.append(self.stop) else: gen_words.append(random.choice(key_hits))