Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_make_sentence_with_start_three_words(self):
start_str = "Sherlock Holmes was"
text_model = self.sherlock_model
try:
text_model.make_sentence_with_start(start_str)
assert(False)
except markovify.text.ParamError:
assert(True)
text_model = self.sherlock_model_ss3
text_model.make_sentence_with_start(start_str)
sent = text_model.make_sentence_with_start("Sherlock")
assert(markovify.chain.BEGIN not in sent)
if word_count == self.state_size:
init_states = [ split ]
elif word_count > 0 and word_count < self.state_size:
if strict:
init_states = [ (BEGIN,) * (self.state_size - word_count) + split ]
else:
init_states = [ key for key in self.chain.model.keys()
# check for starting with begin as well ordered lists
if tuple(filter(lambda x: x != BEGIN, key))[:word_count] == split ]
random.shuffle(init_states)
else:
err_msg = "`make_sentence_with_start` for this model requires a string containing 1 to {0} words. Yours has {1}: {2}".format(self.state_size, word_count, str(split))
raise ParamError(err_msg)
for init_state in init_states:
output = self.make_sentence(init_state, **kwargs)
if output is not None:
return output
return None