Expand description
Spelling suggestions for unknown words.
This module provides fuzzy matching to suggest corrections for misspelled words in the input. It uses Levenshtein distance to find similar words from a known vocabulary list.
When the parser encounters an unknown word, this module can suggest “Did you mean X?” alternatives based on edit distance.
Constants§
Functions§
- did_
you_ mean - The candidate an author most likely meant by
word— the nearest by edit distance, compared case-insensitively, when it is within a third of the word’s length (at least one edit). The first of equally near candidates wins, so a caller that lists candidates in a stable order gets a stable answer.worditself never counts as a suggestion for itself. - find_
similar - levenshtein
- Compute the Levenshtein edit distance between two strings.
- typo_
distance - Edit distance where swapping two adjacent characters is one edit (the optimal string alignment
distance) — the typo a fast typist makes most (
doenfordone), which plain Levenshtein counts as two.