Markov: clarify what's going on in _get_suitable_word_from_choices
This commit is contained in:
parent
f15238a37e
commit
9ca37c3990
@ -419,6 +419,9 @@ class Markov(Module):
|
||||
def _get_suitable_word_from_choices(self, key_hits, gen_words, min_size):
|
||||
"""Given an existing set of words, and key hits, pick one."""
|
||||
|
||||
# first, if we're not yet at min_size, pick a non-stop word if it exists
|
||||
# else, if there were no results, append stop
|
||||
# otherwise, pick a random result
|
||||
if len(gen_words) < min_size + 2 and len(filter(lambda a: a != self.stop, key_hits)) > 0:
|
||||
found_word = random.choice(filter(lambda a: a != self.stop, key_hits))
|
||||
self.log.debug("added '{0:s}' to gen_words".format(found_word))
|
||||
|
Loading…
Reference in New Issue
Block a user