Skip to content

Commit

Permalink
Only parse sentences in constructor if chain argument not given
Browse files Browse the repository at this point in the history
Otherwise, cannot construct from json when saved with retain_original=False
  • Loading branch information
MatthewScholefield committed Sep 11, 2017
1 parent 3d86fbd commit dcafe08
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion markovify/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def __init__(self, input_text, state_size=2, chain=None, parsed_sentences=None,
self.rejoined_text = self.sentence_join(map(self.word_join, self.parsed_sentences))
self.chain = chain or Chain(self.parsed_sentences, state_size)
else:
parsed = parsed_sentences or self.generate_corpus(input_text)
if not chain:
parsed = parsed_sentences or self.generate_corpus(input_text)
self.chain = chain or Chain(parsed, state_size)

def to_dict(self):
Expand Down

0 comments on commit dcafe08

Please sign in to comment.