Skip to main content

Function: withinOneEdit()

withinOneEdit(a, b): boolean

Defined in: packages/agentos/src/cognition/rag/search/FuzzyIndex.ts:149

True when two words are at most one edit apart, letter by letter (a letter is a code point): the same, or one letter added, dropped or changed, or two letters side by side swapped. That is a Damerau-Levenshtein distance of 1 or less (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance), read in one pass instead of a table. The words are compared as they are given: fold both first for a comparison that ignores case.

Parameters​

a​

string

b​

string

Returns​

boolean