code wiki / (root) / nx_fuzzy_match_test.nx

nx_fuzzy_match_test.nx source

↩ module page · 39 lines · 1700 B

1// nx_fuzzy_match_test.nx -- KAT gate for nx_fuzzy_match. 2// Proves the SAFE matcher (1) FIXES case/separator morphology and (2) HONESTLY 3// REFUSES to fake suffix-stemming + synonyms (no-false-green both directions). 4// expect_exit: 0 license_tier: ORIGINAL 5 6import "nx_syscalls.nx" 7import "nx_fuzzy_match.nx" 8 9func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 10 11func main() -> i64 { 12 // (1) case + hyphen morphology IS matched 13 let t1: *u8 = "It supports Live TV and DVR recording.\x00" 14 if fuzzy_has(t1, slen(t1), "live-tv" as *u8) != 1 { return 1 } 15 16 // (2) plural substring IS matched (free under containment) 17 let t2: *u8 = "external subtitles are supported\x00" 18 if fuzzy_has(t2, slen(t2), "subtitle" as *u8) != 1 { return 2 } 19 20 // (3) exact acronym still matches (case-insensitive) 21 let t3: *u8 = "casts via chromecast and dlna\x00" 22 if fuzzy_has(t3, slen(t3), "Chromecast" as *u8) != 1 { return 3 } 23 24 // (4) HONEST NEG: synonym is NOT faked (media-browser != "media server") 25 let t4: *u8 = "a free media server application\x00" 26 if fuzzy_has(t4, slen(t4), "media-browser" as *u8) != 0 { return 4 } 27 28 // (5) HONEST NEG: suffix stemming is NOT faked (transcode !c transcoding here) 29 let t5: *u8 = "performs video transcoding on the fly\x00" 30 if fuzzy_has(t5, slen(t5), "transcode" as *u8) != 0 { return 5 } 31 32 // (6) unrelated text -> no match 33 let t6: *u8 = "nothing of interest here\x00" 34 if fuzzy_has(t6, slen(t6), "transcode" as *u8) != 0 { return 6 } 35 36 let ok: *u8 = "FUZZY-KAT-PASS (case/hyphen fixed; synonyms+stems honestly refused)\n\x00" 37 sys_write(1, ok, slen(ok)) 38 return 0 39}