Expand description
Conservative nearest-match selection for “did you mean” diagnostics.
Several passes answer the same question: the user wrote an identifier
that matches nothing — is one known name a plausible near-miss worth
offering as a fix? This module owns the shared edit-distance metric, the
selection rule, and the MOS0015 unknown-key diagnostic builder; callers
supply their own candidate sets (reference labels, citation keys, #set
targets, directive keyword arguments).
Functions§
- edit_
distance 🔒 - Byte-level edit distance counting an adjacent transposition as one edit (optimal string alignment, the restricted Damerau-Levenshtein variant).
- nearest_
match 🔒 - The single candidate that is a reasonable near-miss for
unknown, if any. - unknown_
key_ 🔒diagnostic - Build the
MOS0015unknown-keyword-argument diagnostic shared by#set,#image,#figure, and#bibliography, attaching a fix replacing exactly the key token when one known key is a conservative near-miss.