Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markov_text_model.make_sentence_with_start KeyError #161

Open
asigalov61 opened this issue Apr 21, 2021 · 1 comment
Open

markov_text_model.make_sentence_with_start KeyError #161

asigalov61 opened this issue Apr 21, 2021 · 1 comment

Comments

@asigalov61
Copy link


KeyError Traceback (most recent call last)
in ()
25 out = markov_text_model.make_sentence_with_start(' '.join(TXT[10:12]), strict=True, min_chars=minimum_number_of_characters_to_generate,
26 tries=number_of_cycles_to_try_to_generate_desired_result,
---> 27 max_overlap_ratio=overlap_ratio)
28 else:
29 out = markov_text_model.make_sentence()

4 frames
/content/tegridy-tools/tegridy-tools/markovify.py in make_sentence_with_start(self, beginning, strict, **kwargs)
516
517 for init_state in init_states:
--> 518 output = self.make_sentence(init_state, **kwargs)
519 if output is not None:
520 return output

/content/tegridy-tools/tegridy-tools/markovify.py in make_sentence(self, init_state, **kwargs)
460
461 for _ in range(tries):
--> 462 words = prefix + self.chain.walk(init_state)
463 if (max_words != None and len(words) > max_words) or (min_words != None and len(words) < min_words):
464 continue # pragma: no cover # see nedbat/coveragepy#198

/content/tegridy-tools/tegridy-tools/markovify.py in walk(self, init_state)
166 (as a tuple).
167 """
--> 168 return list(self.gen(init_state))
169
170 def to_json(self):

/content/tegridy-tools/tegridy-tools/markovify.py in gen(self, init_state)
155 state = init_state or (BEGIN,) * self.state_size
156 while True:
--> 157 next_word = self.move(state)
158 if next_word == END: break
159 yield next_word

/content/tegridy-tools/tegridy-tools/markovify.py in move(self, state)
135 """
136 if self.compiled:
--> 137 choices, cumdist = self.model[state]
138 elif state == tuple([ BEGIN ] * self.state_size):
139 choices = self.begin_choices

KeyError: ('_BEGIN', '田疭畩', '疭疭畩'

@asigalov61
Copy link
Author

Its works great with strict=False but if you set it to True you get the above debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant