fuzzy
Package fuzzy adds approximate-string-matching SQL scalar functions — edit distances, the Jaro / Jaro-Winkler similarity, and the Soundex phonetic code:
levenshtein(a, b) -- edit distance (insert/delete/substitute)damerau_levenshtein(a, b) -- + adjacent transposition (OSA variant)hamming(a, b) -- positions that differ; errors if lengths differjaro(a, b) -- Jaro similarity in [0, 1]jaro_winkler(a, b) -- Jaro with a common-prefix bonussoundex(s) -- 4-character American Soundex codecaverphone(s) -- 10-character Caverphone 2.0 phonetic codeDistances/similarities are rune-aware (Unicode-correct); Soundex and Caverphone operate on ASCII letters as those algorithms are defined. The cousin to ext/spellfix1 (a vtab-based fuzzy vocabulary): these are stateless scalars over two strings. Ported in spirit from the sqlean fuzzy module.
import ( sqlite "gosqlite.org" "gosqlite.org/ext/fuzzy")
fuzzy.Register(conn) // or blank-import ".../ext/fuzzy/auto" for pool-widedb.QueryRow(`SELECT levenshtein('kitten', 'sitting')`) // 3Full API: pkg.go.dev/gosqlite.org/ext/fuzzy