markov_text_model.make_sentence_with_start KeyError
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 348
- PR merge metrics
- No merged PRs in 30d
Description
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 https://github.com/nedbat/coveragepy/issues/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', '田疭畩', '疭疭畩'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in markovify.py around move(), gen(), make_sentence(), and make_sentence_with_start(), then reproduce the shown KeyError with the Unicode input and compiled model. Trace why the generated state is absent from the model; done means the reported call no longer raises KeyError and the behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100