Computes the lexical distance between strings A and B.
The "distance" between two strings is given by counting the minimum number of edits needed to transform string A into string B. An edit can be an insertion, deletion, or substitution of a single character, or a swap of two adjacent characters.
Includes a custom alteration from Damerau-Levenshtein to treat case changes as a single edit which helps identify mis-cased values with an edit distance of 1.
This distance can be useful for detecting typos in input or sorting
Unlike the native levenshtein() function that always returns int, LexicalDistance::measure() returns int|null. It takes into account the threshold and returns null if the measured distance is bigger.
No Hooks.
Usage
$LexicalDistance = new LexicalDistance();
// use class methods