Skip to content

Commit

Permalink
Merge 01f7539 into a36a41a
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylv-Lej authored Jun 18, 2020
2 parents a36a41a + 01f7539 commit a720633
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions markovify/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +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

return None
err_msg = "`make_sentence_with_start` can't find sentence beginning with {0}".format(beginning)
raise ParamError(err_msg)

@classmethod
def from_chain(cls, chain_json, corpus=None, parsed_sentences=None):
Expand Down
8 changes: 5 additions & 3 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,8 +102,10 @@ def test_make_sentence_with_start_three_words(self):
assert(False)
except markovify.text.ParamError:
assert(True)

with self.assertRaises(Exception) as context:
text_model.make_sentence_with_start(start_str)
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)

Expand Down

0 comments on commit a720633

Please sign in to comment.