Skip to content

Commit

Permalink
Merge 79bbbed into a36a41a
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylv-Lej committed Jun 17, 2020
2 parents a36a41a + 79bbbed commit 9be0560
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions markovify/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def make_sentence_with_start(self, beginning, strict=True, **kwargs):
output = self.make_sentence(init_state, **kwargs)
if output is not None:
return output
err_msg = "`make_sentence_with_start` can't find sentence beginning with {0}".format(beginning)
raise ParamError(err_msg)

return None

Expand Down
5 changes: 3 additions & 2 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_make_sentence_with_words_not_at_start_of_sentence(self):
def test_make_sentence_with_words_not_at_start_of_sentence_miss(self):
text_model = self.sherlock_model_ss3
start_str = "was werewolf"
sent = text_model.make_sentence_with_start(start_str, strict=False, tries=50)
assert(sent == None)
with self.assertRaises(markovify.text.ParamError):
sent = text_model.make_sentence_with_start(start_str, strict=False, tries=50)

def test_make_sentence_with_words_not_at_start_of_sentence_of_state_size(self):
text_model = self.sherlock_model_ss2
Expand All @@ -102,6 +102,7 @@ def test_make_sentence_with_start_three_words(self):
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")
Expand Down

0 comments on commit 9be0560

Please sign in to comment.