Skip to content

Commit

Permalink
No suggestions, if there is nothing to suggest
Browse files Browse the repository at this point in the history
  • Loading branch information
xfenix committed Jun 14, 2022
1 parent 267e373 commit 7a32afd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions whole_app/spell.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ def _make_one_correction_and_append_to_output(self, index: int, one_word_buf: li
if self._spellcheck_engine.check(ready_word):
return
possible_candidates: list[str] = self._spellcheck_engine.suggest(ready_word)
self._user_corrections.append(
models.OneCorrection(
first_position=index - len(one_word_buf),
last_position=index - 1,
word=ready_word,
suggestions=possible_candidates[: SETTINGS.max_suggestions]
if SETTINGS.max_suggestions
else possible_candidates,
if len(possible_candidates) > 0:
self._user_corrections.append(
models.OneCorrection(
first_position=index - len(one_word_buf),
last_position=index - 1,
word=ready_word,
suggestions=possible_candidates[: SETTINGS.max_suggestions]
if SETTINGS.max_suggestions
else possible_candidates,
)
)
)

def run_check(self, input_text: str) -> list[models.OneCorrection]:
"""Main spellcheck procedure."""
Expand Down

0 comments on commit 7a32afd

Please sign in to comment.