code wiki / (root) / levenshtein.nx

levenshtein.nx

buildroot/runtime/levenshtein.nx

2926 B84 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

levenshtein.nx -- Levenshtein edit distance. Computes the minimum number of single-character edits (insertions, deletions, substitutions) needed to transform string A into string B. Used for: typo correction, fuzzy search, near-duplicate detection, "did you mean" suggestions. Wagner-Fischer dynamic programming (1974). O(m * n) time, O(min(m, n)) space using the two-row optimisation. Invariants: LV1 Symmetric: distance(a, b) == distance(b, a) LV2 distance(a, "") == len(a); identity-distance is 0 LV3 Triangle inequality holds: distance(a, c) <= distance(a, b) + distance(b, c) LV4 Byte-level (not codepoint-level). ASCII text behaves as expected; multi-byte UTF-8 counts each byte as a distinct symbol -- callers wanting codepoint distances decode to int sequences first.

dependencies 1 imports · 0 importers

syscalls.nx levenshtein.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main levenshtein lv_min3

structs

none

consts

none

functions

24func lv_min3(a: i64, b: i64, c: i64) -> i64 {
called by 1: levenshtein
32func levenshtein(a: *u8, a_len: i64, b: *u8, b_len: i64) -> i64 {
called by 1: main calls 1: lv_min3
73func main() -> i64 {
calls 1: levenshtein