code wiki / (root) / nx_didyoumean_gate.nx

nx_didyoumean_gate.nx source

↩ module page · 394 lines · 23152 B

1// nx_didyoumean_gate.nx -- GATE for SEARCH RUNG F4, the did-you-mean line (nx_didyoumean + the seg's contract symbol 2// dss_spell_suggest), judged on the LIVE term dictionary of the public web shard. 3// 4// PRE-DECLARED BEFORE THE FIRST RUN (the rung's own done-rule, 2026-09-18): a planted set of 10 misspellings corrects at 5// least 9 to the intended word, while a control of 10 correctly spelled RARE terms draws no suggestion. 6// - THE PLANTED SET is ten entries of the published common-misspelling lists, chosen to span the four one-edit mechanisms 7// (two swaps, two substitutions, four insertions, two deletions) and for nothing else. 8// - THE CONTROL is the first ten words of a pre-declared, ordered reserve of real English words that the live dictionary 9// HOLDS and rates RARE by the same midpoint the suggester uses -- selected by document frequency alone, never by what 10// the suggester does with them. If fewer than ten qualify, the control is not the population the rule names and the 11// gate says SKIP rather than guess. 12// - TWO PANELS PRINT AND DO NOT VOTE: ten more common misspellings (held out: nothing was tuned on them) and eight short 13// rare words, the class the lib's documented imprecision is about. Their counts ride the values block, so a change in 14// either is visible without being dressed as a verdict. 15// The arithmetic (the majority rule, the midpoint, the lookup envelope) is pinned before the live dictionary judges 16// anything, and every live row prints its document frequencies, its lookups and its microseconds. 17// license_tier: ORIGINAL No hw writes (Rule 26). Read-only on the shard. 18import "nx_docportal_search_seg.nx" 19import "nx_docportal_search_serve.nx" // the served surfaces are judged IN PROCESS: the SERP line and the /api/search field 20import "nx_gate_verdict.nx" 21 22const DG_SP: i64 = 32 23const DG_COLON: i64 = 58 24const DG_PLANTED_BAR: i64 = 9 // the rung's done-rule: at least 9 of the 10 planted misspellings corrected 25const DG_CONTROL_N: i64 = 10 // the rung's done-rule: a control of 10 rare, correctly spelled terms 26const DG_ROOT: i64 = 1000 // the midpoint KAT: a corpus of ROOT*ROOT - 1 documents has an exact midpoint of ROOT 27const DG_SMALL_N: i64 = 3 // the midpoint KAT on a three-document fixture: sqrt(3 + 1) = 2 28const DG_SMALL_MID: i64 = 2 29const DG_MID_TOL: i64 = 2 // the Q10 log truncates, so the found boundary may sit a df or two past the exact root 30const DG_SEVEN: i64 = 7 // the envelope KAT length (recieve) 31const DG_SEVEN_BOUND: i64 = 343 // 6 deletions + 5 swaps + 25x6 substitutions + 26x7 insertions, counted by hand 32const DG_PLANTED: *u8 = "recieve:receive definately:definitely seperate:separate occured:occurred untill:until goverment:government enviroment:environment neccessary:necessary accomodate:accommodate beleive:believe" 33const DG_RESERVE: *u8 = "quokka zeugma petrichor anhedonia apophenia limerence borborygmus kakistocracy defenestration sesquipedalian susurrus apricity hiraeth vellichor lalochezia ultracrepidarian tsundoku psithurism crepuscular gnomon" 34const DG_HELDOUT: *u8 = "acheive:achieve arguement:argument begining:beginning commited:committed existance:existence foriegn:foreign grammer:grammar independant:independent recomend:recommend succesful:successful" 35const DG_SHORT: *u8 = "yurt sumac quoll okapi dhole sonder kelpie jicama" 36const DG_MULTI: *u8 = "recieve definately seperate occured untill goverment enviroment neccessary accomodate beleive" 37const DG_E2E_Q: *u8 = "Recieve the package" 38const DG_E2E_WANT: *u8 = "receive the package" 39const DG_OP_Q: *u8 = "site:reddit.com recieve" 40const DG_OP_WANT: *u8 = "site:reddit.com receive" 41const DG_COMMON_W: *u8 = "receive" 42const DG_FIRST_W: *u8 = "uantum" 43const DG_FIRST_NOT: *u8 = "quantum" 44const DG_TWO_W: *u8 = "zq" 45const DG_SERVE_DOM: *u8 = "nishifamily.com" // the site domain the served handler is asked as; scope=web sends it to the web shard 46const DG_MEMO_Q: *u8 = "RECIEVE the Package" // a case variant of DG_E2E_Q: the memo key folds case, so it must hit 47const DG_MEMO_OTHER: *u8 = "recieve the parcel" // a different query: the key must discriminate, so it must miss 48 49func dg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 50func dg_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64 { 51 if an != bn { return 0 } 52 var i: i64 = 0 53 while i < an { if a[i] != b[i] { return 0 } i = i + 1 } 54 return 1 55} 56func dg_contains(b: *u8, n: i64, pat: *u8) -> i64 { 57 let pl: i64 = dg_len(pat) 58 if pl == 0 { return 1 } 59 if pl > n { return 0 } 60 var i: i64 = 0 61 while i + pl <= n { 62 var k: i64 = 0 63 var ok: i64 = 1 64 while k < pl { if b[i + k] != pat[k] { ok = 0; k = pl } else { k = k + 1 } } 65 if ok == 1 { return 1 } 66 i = i + 1 67 } 68 return 0 69} 70// entry k of a space-separated list, part p (0 = before the ':', 1 = after it; an entry with no ':' answers itself for 71// both), copied NUL-terminated into out. Returns its length, or -1 when the list has no entry k. 72func dg_field(list: *u8, k: i64, p: i64, out: *u8) -> i64 { 73 var i: i64 = 0 74 var e: i64 = 0 75 var at: i64 = 0 - 1 76 var go: i64 = 1 77 while go == 1 { 78 let c: i64 = list[i] as i64 79 if c == 0 { go = 0 } else { 80 if c == DG_SP { i = i + 1 } else { 81 if e == k { at = i; go = 0 } else { 82 var sk: i64 = 1 83 while sk == 1 { 84 let c2: i64 = list[i] as i64 85 if c2 == 0 { sk = 0 } else { if c2 == DG_SP { sk = 0 } else { i = i + 1 } } 86 } 87 e = e + 1 88 } 89 } 90 } 91 } 92 if at < 0 { out[0] = 0 as u8; return 0 - 1 } 93 var end: i64 = at 94 var sk2: i64 = 1 95 while sk2 == 1 { 96 let c3: i64 = list[end] as i64 97 if c3 == 0 { sk2 = 0 } else { if c3 == DG_SP { sk2 = 0 } else { end = end + 1 } } 98 } 99 var colon: i64 = 0 - 1 100 var x: i64 = at 101 while x < end { if (list[x] as i64) == DG_COLON { if colon < 0 { colon = x } } x = x + 1 } 102 var a: i64 = at 103 var b: i64 = end 104 if colon >= 0 { if p == 0 { b = colon } else { a = colon + 1 } } 105 var o: i64 = 0 106 while a < b { out[o] = list[a]; o = o + 1; a = a + 1 } 107 out[o] = 0 as u8 108 return o 109} 110// one live row: the word, its document frequency, what it was offered, and what the answer cost 111func dg_row(panel: *u8, w: *u8, wl: i64, tdf: i64, got: *u8, gl: i64, st: *i64, tag: *u8) -> i64 { 112 gv_puts(" " as *u8); gv_puts(panel); gv_puts(" " as *u8); sys_write(1, w, wl) 113 gv_puts(" df=" as *u8); gv_num(tdf) 114 gv_puts(" -> " as *u8) 115 if gl > 0 { sys_write(1, got, gl) } else { gv_puts("(none)" as *u8) } 116 gv_puts(" neighbour_df=" as *u8); gv_num(st[DYM_ST_CDF]) 117 gv_puts(" lookups=" as *u8); gv_num(st[DYM_ST_LOOKUPS]) 118 gv_puts(" held=" as *u8); gv_num(st[DYM_ST_HELD]) 119 gv_puts(" us=" as *u8); gv_num(st[DYM_ST_US]) 120 gv_puts(" " as *u8); gv_puts(tag); gv_puts("\n" as *u8) 121 return 0 122} 123 124func main(argc: i64, argv: *i64) -> i64 { 125 let ctr: *i64 = gv_ctr() 126 gv_head("nx_didyoumean_gate -- search rung F4: a rare word is offered its common one-edit neighbour, a rare correct word is offered nothing, on the live dictionary" as *u8) 127 128 // ---- the arithmetic, pinned before the live dictionary judges anything ---- 129 gv_check_eq("T1 majority rule: a two-letter word may take no edit" as *u8, dym_edits_allowed(2), 0, ctr) 130 gv_check_eq("T1b majority rule: a three-letter word may take the one edit" as *u8, dym_edits_allowed(3), DYM_EDIT, ctr) 131 gv_check_eq("T1c the lookup envelope of a seven-letter word, counted by hand" as *u8, dym_lookup_bound(DG_SEVEN), DG_SEVEN_BOUND, ctr) 132 gv_check_eq("T1d neg-control-two-letter-envelope-is-empty: a word that may take no edit costs no lookup" as *u8, dym_lookup_bound(2), 0, ctr) 133 let kn: i64 = DG_ROOT * DG_ROOT - 1 134 let kmid: i64 = dym_mid(kn) 135 var t2: i64 = 0 136 if dym_rare(kn, kmid - 1) == 1 { if dym_common(kn, kmid) == 1 { t2 = 1 } } 137 gv_check("T2 the announced midpoint IS the predicate boundary: df mid-1 is rare, df mid is common" as *u8, t2, ctr) 138 gv_check_near("T2b the midpoint of a million-document corpus sits at the square root, within the Q10 log truncation" as *u8, kmid, DG_ROOT, DG_MID_TOL, ctr) 139 gv_check_eq("T2c a three-document fixture: df 1 is rare, df 2 is common" as *u8, dym_mid(DG_SMALL_N), DG_SMALL_MID, ctr) 140 gv_check_eq("T2d neg-control-absent-is-never-common: a df of zero is never offered" as *u8, dym_common(kn, 0), 0, ctr) 141 142 // ---- the live dictionary, from either cwd (the roster forks from the serving root, the builder from buildroot) ---- 143 let anch: i64 = sys_openat_rd("../knowledge/store/dp-web-pub-manifest.txt" as *u8) 144 if anch >= 0 { sys_close(anch); sys_chdir(".." as *u8) } 145 let dom: *u8 = "web" as *u8 146 let prefix: *u8 = sys_mmap(DSC_PREFIXBUF) 147 dss_prefix(dom, prefix) 148 let h: *i64 = dss_open_maybe_cached(prefix) 149 var live: i64 = 0 150 if (h as i64) != 0 { live = 1 } 151 gv_need("T3 the live web shard opens (nothing below means anything if it does not)" as *u8, live, ctr) 152 if live == 0 { 153 let rc0: i64 = gv_verdict("DIDYOUMEAN" as *u8, ctr, "the did-you-mean rule, judged on the live dictionary" as *u8) 154 sys_exit(rc0) 155 return rc0 156 } 157 let bign: i64 = ss_doc_count(h) 158 let mid: i64 = dym_mid(bign) 159 gv_puts(" live shard: docs=" as *u8); gv_num(bign); gv_puts(" segments=" as *u8); gv_num(h[0]) 160 gv_puts(" common_df_at_or_above=" as *u8); gv_num(mid); gv_puts("\n" as *u8) 161 gv_check("T3b the shard holds documents, so the midpoint is drawn from a real corpus" as *u8, (bign > 0) as i64, ctr) 162 163 // every buffer below is sized from the lists it holds 164 let cap: i64 = dg_len(DG_PLANTED) + dg_len(DG_RESERVE) + dg_len(DG_HELDOUT) + dg_len(DG_SHORT) + dg_len(DG_MULTI) + DYM_EDIT + 1 165 let wb: *u8 = sys_mmap(cap) 166 let ib: *u8 = sys_mmap(cap) 167 let got: *u8 = sys_mmap(cap) 168 let st: *i64 = sys_mmap(8 * DYM_ST_SLOTS) as *i64 169 var envelope_ok: i64 = 1 170 var lev_ok: i64 = 1 171 var worst_us: i64 = 0 172 var sum_us: i64 = 0 173 var timed: i64 = 0 174 var worst_lk: i64 = 0 175 176 // ---- DONE-RULE, planted half ---- 177 var pn: i64 = 0 178 var pok: i64 = 0 179 var pfix: i64 = 0 180 var prare: i64 = 0 181 var k: i64 = 0 182 var more: i64 = 1 183 while more == 1 { 184 let wl: i64 = dg_field(DG_PLANTED, k, 0, wb) 185 if wl < 0 { more = 0 } else { 186 let il: i64 = dg_field(DG_PLANTED, k, 1, ib) 187 pn = pn + 1 188 let tdf: i64 = ss_term_dcount(h, wb) 189 let gl: i64 = dym_suggest(h, wb, wl, DSS_MAXTERMS, got, cap, st) 190 let hit: i64 = dg_eq(got, gl, ib, il) 191 pok = pok + hit 192 if gl > 0 { pfix = pfix + 1 } 193 prare = prare + st[DYM_ST_RARE] 194 if st[DYM_ST_LOOKUPS] > dym_lookup_bound(wl) { envelope_ok = 0 } 195 if st[DYM_ST_LOOKUPS] > worst_lk { worst_lk = st[DYM_ST_LOOKUPS] } 196 if st[DYM_ST_US] > worst_us { worst_us = st[DYM_ST_US] } 197 sum_us = sum_us + st[DYM_ST_US] 198 timed = timed + 1 199 if gl > 0 { if ed_bounded(wb, wl, got, gl, 2 * DYM_EDIT) > 2 * DYM_EDIT { lev_ok = 0 } } 200 if hit == 1 { dg_row("planted" as *u8, wb, wl, tdf, got, gl, st, "CORRECTED" as *u8) } else { dg_row("planted" as *u8, wb, wl, tdf, got, gl, st, "MISS" as *u8) } 201 k = k + 1 202 } 203 } 204 205 // ---- DONE-RULE, control half: the population is chosen by document frequency alone ---- 206 var selected: i64 = 0 207 var csug: i64 = 0 208 var r: i64 = 0 209 var rmore: i64 = 1 210 while rmore == 1 { 211 if selected >= DG_CONTROL_N { rmore = 0 } else { 212 let cl: i64 = dg_field(DG_RESERVE, r, 0, wb) 213 if cl < 0 { rmore = 0 } else { 214 let cdf: i64 = ss_term_dcount(h, wb) 215 var pick: i64 = 0 216 if cdf > 0 { if dym_rare(bign, cdf) == 1 { pick = 1 } } 217 if pick == 0 { 218 gv_puts(" reserve " as *u8); sys_write(1, wb, cl); gv_puts(" df=" as *u8); gv_num(cdf); gv_puts(" not-selected (absent or not rare)\n" as *u8) 219 } else { 220 selected = selected + 1 221 let gl2: i64 = dym_suggest(h, wb, cl, DSS_MAXTERMS, got, cap, st) 222 if gl2 > 0 { csug = csug + 1 } 223 if st[DYM_ST_LOOKUPS] > dym_lookup_bound(cl) { envelope_ok = 0 } 224 if st[DYM_ST_LOOKUPS] > worst_lk { worst_lk = st[DYM_ST_LOOKUPS] } 225 if st[DYM_ST_US] > worst_us { worst_us = st[DYM_ST_US] } 226 sum_us = sum_us + st[DYM_ST_US] 227 timed = timed + 1 228 if gl2 > 0 { dg_row("control" as *u8, wb, cl, cdf, got, gl2, st, "SUGGESTED" as *u8) } else { dg_row("control" as *u8, wb, cl, cdf, got, gl2, st, "QUIET" as *u8) } 229 } 230 r = r + 1 231 } 232 } 233 } 234 235 // ---- panels that print and do not vote ---- 236 var hn: i64 = 0 237 var hok: i64 = 0 238 var hk: i64 = 0 239 var hmore: i64 = 1 240 while hmore == 1 { 241 let hl: i64 = dg_field(DG_HELDOUT, hk, 0, wb) 242 if hl < 0 { hmore = 0 } else { 243 let hil: i64 = dg_field(DG_HELDOUT, hk, 1, ib) 244 hn = hn + 1 245 let hdf: i64 = ss_term_dcount(h, wb) 246 let hgl: i64 = dym_suggest(h, wb, hl, DSS_MAXTERMS, got, cap, st) 247 let hhit: i64 = dg_eq(got, hgl, ib, hil) 248 hok = hok + hhit 249 if st[DYM_ST_LOOKUPS] > dym_lookup_bound(hl) { envelope_ok = 0 } 250 if hhit == 1 { dg_row("heldout" as *u8, wb, hl, hdf, got, hgl, st, "CORRECTED" as *u8) } else { dg_row("heldout" as *u8, wb, hl, hdf, got, hgl, st, "MISS" as *u8) } 251 hk = hk + 1 252 } 253 } 254 var sn: i64 = 0 255 var ssug: i64 = 0 256 var sk: i64 = 0 257 var smore: i64 = 1 258 while smore == 1 { 259 let sl: i64 = dg_field(DG_SHORT, sk, 0, wb) 260 if sl < 0 { smore = 0 } else { 261 sn = sn + 1 262 let sdf: i64 = ss_term_dcount(h, wb) 263 let sgl: i64 = dym_suggest(h, wb, sl, DSS_MAXTERMS, got, cap, st) 264 if sgl > 0 { ssug = ssug + 1 } 265 if sgl > 0 { dg_row("short" as *u8, wb, sl, sdf, got, sgl, st, "SUGGESTED" as *u8) } else { dg_row("short" as *u8, wb, sl, sdf, got, sgl, st, "QUIET" as *u8) } 266 sk = sk + 1 267 } 268 } 269 270 // ---- the whole-query path must agree with the per-word path ---- 271 let ml: i64 = dym_suggest(h, DG_MULTI, dg_len(DG_MULTI), DSS_MAXTERMS, got, cap, st) 272 let mfixed: i64 = st[DYM_ST_FIXED] 273 let mus: i64 = st[DYM_ST_US] 274 gv_puts(" multi -> " as *u8) 275 if ml > 0 { sys_write(1, got, ml) } else { gv_puts("(none)" as *u8) } 276 gv_puts(" fixed=" as *u8); gv_num(mfixed); gv_puts(" lookups=" as *u8); gv_num(st[DYM_ST_LOOKUPS]); gv_puts(" us=" as *u8); gv_num(mus); gv_puts("\n" as *u8) 277 278 // arm the shared memo tables the way the daemon's parent does before it forks, so the memo path is judged too 279 let armed_memo: i64 = dsq_init() 280 // ---- the contract symbol, end to end through the seg ---- 281 let eqn: i64 = dg_len(DG_E2E_Q) 282 let el: i64 = dss_spell_suggest(dom, DG_E2E_Q, eqn, got, cap) 283 let sp: *i64 = sys_mmap(8 * DYM_ST_SLOTS) as *i64 284 dss_spell_stats(sp) 285 let e2e_ok: i64 = dg_eq(got, el, DG_E2E_WANT, dg_len(DG_E2E_WANT)) 286 let e2e_us: i64 = sp[DYM_ST_US] 287 gv_puts(" e2e dss_spell_suggest -> " as *u8) 288 if el > 0 { sys_write(1, got, el) } else { gv_puts("(none)" as *u8) } 289 gv_puts(" docs=" as *u8); gv_num(sp[DYM_ST_DOCS]); gv_puts(" us=" as *u8); gv_num(e2e_us); gv_puts("\n" as *u8) 290 let e2e_docs: i64 = sp[DYM_ST_DOCS] 291 let ol: i64 = dss_spell_suggest(dom, DG_OP_Q, dg_len(DG_OP_Q), got, cap) 292 let op_ok: i64 = dg_eq(got, ol, DG_OP_WANT, dg_len(DG_OP_WANT)) 293 gv_puts(" operators dss_spell_suggest -> " as *u8) 294 if ol > 0 { sys_write(1, got, ol) } else { gv_puts("(none)" as *u8) } 295 gv_puts("\n" as *u8) 296 297 // ---- the memo: a case-variant repeat answers from the table, byte-identical; a different query is computed ---- 298 let ml1: i64 = dss_spell_suggest(dom, DG_MEMO_Q, dg_len(DG_MEMO_Q), got, cap) 299 dss_spell_stats(sp) 300 let memo_hit: i64 = sp[DYM_ST_MEMO] 301 let memo_us: i64 = sp[DYM_ST_US] 302 let memo_ok: i64 = dg_eq(got, ml1, DG_E2E_WANT, dg_len(DG_E2E_WANT)) 303 gv_puts(" memo repeat dss_spell_suggest -> " as *u8) 304 if ml1 > 0 { sys_write(1, got, ml1) } else { gv_puts("(none)" as *u8) } 305 gv_puts(" memo=" as *u8); gv_num(memo_hit); gv_puts(" us=" as *u8); gv_num(memo_us); gv_puts("\n" as *u8) 306 let ml2: i64 = dss_spell_suggest(dom, DG_MEMO_OTHER, dg_len(DG_MEMO_OTHER), got, cap) 307 dss_spell_stats(sp) 308 let memo_other: i64 = sp[DYM_ST_MEMO] 309 gv_puts(" memo other dss_spell_suggest -> " as *u8) 310 if ml2 > 0 { sys_write(1, got, ml2) } else { gv_puts("(none)" as *u8) } 311 gv_puts(" memo=" as *u8); gv_num(memo_other); gv_puts("\n" as *u8) 312 var t17: i64 = 0 313 if armed_memo == 1 { if memo_hit == 1 { if memo_ok == 1 { t17 = 1 } } } 314 315 // ---- the served surfaces, in process, against the LIVE web shard: the SERP line and the API field ---- 316 let sout: *u8 = sys_mmap(DSV_OUTCAP) 317 let sreq: *u8 = "GET /search?q=recieve&scope=web HTTP/1.1\r\nHost: x\r\n\r\n" as *u8 318 let sn: i64 = dss_serve(DG_SERVE_DOM, sreq, dg_len(sreq), sout) 319 var t18: i64 = 0 320 if dg_contains(sout, sn, "Did you mean" as *u8) == 1 { if dg_contains(sout, sn, "<b>receive</b>" as *u8) == 1 { t18 = 1 } } 321 gv_puts(" serp /search?q=recieve&scope=web bytes=" as *u8); gv_num(sn); gv_puts(" did-you-mean-line=" as *u8); gv_num(t18); gv_puts("\n" as *u8) 322 let areq: *u8 = "GET /api/search?q=recieve&scope=web HTTP/1.1\r\nHost: x\r\n\r\n" as *u8 323 let an: i64 = dss_api_search(DG_SERVE_DOM, areq, dg_len(areq), sout) 324 var t19: i64 = 0 325 if dg_contains(sout, an, "\"did_you_mean\":\"receive\"" as *u8) == 1 { if dg_contains(sout, an, "\"spell\":{\"source\":\"edit1\"" as *u8) == 1 { t19 = 1 } } 326 gv_puts(" api /api/search?q=recieve&scope=web bytes=" as *u8); gv_num(an); gv_puts(" did_you_mean-plus-spell=" as *u8); gv_num(t19); gv_puts("\n" as *u8) 327 let creq: *u8 = "GET /api/search?q=anhedonia&scope=web HTTP/1.1\r\nHost: x\r\n\r\n" as *u8 328 let cn: i64 = dss_api_search(DG_SERVE_DOM, creq, dg_len(creq), sout) 329 var t20: i64 = 0 330 if dg_contains(sout, cn, "did_you_mean" as *u8) == 0 { if dg_contains(sout, cn, "\"spell\":{\"source\":\"none\"" as *u8) == 1 { t20 = 1 } } 331 gv_puts(" api /api/search?q=anhedonia&scope=web bytes=" as *u8); gv_num(cn); gv_puts(" quiet=" as *u8); gv_num(t20); gv_puts("\n" as *u8) 332 333 // ---- controls that must NOT fire ---- 334 let n1: i64 = dym_suggest(h, DG_COMMON_W, dg_len(DG_COMMON_W), DSS_MAXTERMS, got, cap, st) 335 var t13: i64 = 0 336 if n1 == 0 { if st[DYM_ST_LOOKUPS] == 0 { if st[DYM_ST_WORDS] == 1 { t13 = 1 } } } 337 let n2: i64 = dym_suggest(h, DG_FIRST_W, dg_len(DG_FIRST_W), DSS_MAXTERMS, got, cap, st) 338 var t14: i64 = 1 339 if dg_eq(got, n2, DG_FIRST_NOT, dg_len(DG_FIRST_NOT)) == 1 { t14 = 0 } 340 let n3: i64 = dym_suggest(h, DG_TWO_W, dg_len(DG_TWO_W), DSS_MAXTERMS, got, cap, st) 341 var t15: i64 = 0 342 if n3 == 0 { if st[DYM_ST_LOOKUPS] == 0 { t15 = 1 } } 343 let n4: i64 = dym_suggest(0 as *i64, DG_COMMON_W, dg_len(DG_COMMON_W), DSS_MAXTERMS, got, cap, st) 344 var t16: i64 = 0 345 if n4 == 0 { if st[DYM_ST_ABSTAIN] == 1 { t16 = 1 } } 346 347 gv_check("T4 fixture-reached-condition: the planted misspellings reached the neighbourhood walk (rare in the live dictionary)" as *u8, (prare >= DG_PLANTED_BAR) as i64, ctr) 348 gv_check("T5 DONE-RULE planted misspellings corrected to the intended word, at least 9 of 10" as *u8, (pok >= DG_PLANTED_BAR) as i64, ctr) 349 gv_need("T6 control population: ten reserve words the live dictionary holds and rates rare" as *u8, (selected >= DG_CONTROL_N) as i64, ctr) 350 gv_check_eq("T7 DONE-RULE the control of rare correctly spelled words draws no suggestion" as *u8, csug, 0, ctr) 351 gv_check_eq("T8 the whole-query path replaces exactly the words the single-word calls replaced" as *u8, mfixed, pfix, ctr) 352 gv_check("T9 the contract symbol dss_spell_suggest offers the corrected query on the live shard, every other word kept" as *u8, e2e_ok, ctr) 353 gv_check_eq("T9b the stats dss_spell_stats publishes describe the same corpus the gate measured" as *u8, e2e_docs, bign, ctr) 354 gv_check("T10 operators, hosts and paths are kept verbatim: only the free-text word is offered its neighbour" as *u8, op_ok, ctr) 355 gv_check("T11 no word cost more lookups than its length allows (dym_lookup_bound)" as *u8, envelope_ok, ctr) 356 gv_check("T12 every offered neighbour is within two Levenshtein edits by the incumbent ruler ed_bounded" as *u8, lev_ok, ctr) 357 gv_check("T13 neg-control-common-word-taken-at-its-word: receive draws nothing and costs no neighbourhood" as *u8, t13, ctr) 358 gv_check("T14 neg-control-first-byte-is-kept: uantum is never offered quantum, whose repair edits byte 0" as *u8, t14, ctr) 359 gv_check("T15 neg-control-two-letter-word: a two-letter word costs no lookup and draws nothing" as *u8, t15, ctr) 360 gv_check("T16 neg-control-no-dictionary-abstains: a null handle offers nothing and says it abstained" as *u8, t16, ctr) 361 gv_check("T17 the memo answers a case-variant repeat from the table, byte-identical to the computed answer" as *u8, t17, ctr) 362 gv_check_eq("T17b neg-control-memo-key-discriminates: a different query is computed, never read from the table" as *u8, memo_other, 0, ctr) 363 gv_check("T18 the SERP draws the did-you-mean line on an answer that FOUND results, as text and a link (zero JS)" as *u8, t18, ctr) 364 gv_check("T19 /api/search carries did_you_mean and the spell object naming the one-edit path" as *u8, t19, ctr) 365 gv_check("T20 neg-control-rare-correct-word-on-the-served-api: no did_you_mean and the spell object reads none" as *u8, t20, ctr) 366 367 var mean_us: i64 = 0 368 if timed > 0 { mean_us = sum_us / timed } 369 gv_values_head() 370 gv_kv("docs" as *u8, bign) 371 gv_kv("segments" as *u8, h[0]) 372 gv_kv("common_df_at_or_above" as *u8, mid) 373 gv_kv("planted" as *u8, pn) 374 gv_kv("planted_rare" as *u8, prare) 375 gv_kv("planted_corrected" as *u8, pok) 376 gv_kv("planted_offered_any" as *u8, pfix) 377 gv_kv("control_reserve_read" as *u8, r) 378 gv_kv("control_selected" as *u8, selected) 379 gv_kv("control_suggested" as *u8, csug) 380 gv_kv("heldout" as *u8, hn) 381 gv_kv("heldout_corrected" as *u8, hok) 382 gv_kv("short_rare" as *u8, sn) 383 gv_kv("short_rare_suggested" as *u8, ssug) 384 gv_kv("multi_fixed" as *u8, mfixed) 385 gv_kv("multi_us" as *u8, mus) 386 gv_kv("word_us_worst" as *u8, worst_us) 387 gv_kv("word_us_mean" as *u8, mean_us) 388 gv_kv("word_lookups_worst" as *u8, worst_lk) 389 gv_kv("e2e_us" as *u8, e2e_us) 390 gv_kv("memo_hit_us" as *u8, memo_us) 391 let rc: i64 = gv_verdict("DIDYOUMEAN" as *u8, ctr, "the did-you-mean rule on the live dictionary" as *u8) 392 sys_exit(rc) 393 return rc 394}