Markov: abort new chain tack-on if even that's giving us __stop

This commit is contained in:
Brian S. Stephan 2012-07-28 14:01:05 -05:00
parent a6f4827a41
commit f15238a37e
1 changed files with 6 additions and 3 deletions

View File

@ -400,9 +400,12 @@ class Markov(Module):
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))
# new word 2
key_hits = self._retrieve_chains_for_key(self.start2, found_word, context_id)
gen_words.append(self._get_suitable_word_from_choices(key_hits, gen_words, min_size))
if gen_words[-1] == self.stop:
break
else:
# new word 2
key_hits = self._retrieve_chains_for_key(self.start2, gen_words[-1], context_id)
gen_words.append(self._get_suitable_word_from_choices(key_hits, gen_words, min_size))
# chop off the seed data at the start
gen_words = gen_words[2:]