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
This commit is contained in:
parent
2b8f0d2843
commit
5913a95165
|
@ -284,6 +284,8 @@ class Markov(Module):
|
||||||
else:
|
else:
|
||||||
if len(gen_words) < min_size and len(filter(lambda a: a != self.stop, key_hits)) > 0:
|
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)))
|
gen_words.append(random.choice(filter(lambda a: a != self.stop, key_hits)))
|
||||||
|
elif len(key_hits) <= 0:
|
||||||
|
gen_words.append(self.stop)
|
||||||
else:
|
else:
|
||||||
gen_words.append(random.choice(key_hits))
|
gen_words.append(random.choice(key_hits))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue