code wiki / _hdl_build / nx_book_search.nx
nx_book_search.nx
buildroot/runtime/_hdl_build/nx_book_search.nx
about
nx_book_search.nx -- SC20: sovereign RANKED search over the NAS book library (idx_book.wsl, 5761 books).
REUSE not reinvent: composes the team's production BM25 ranker (nx_bm25: bm_idf_micro / bm_sat_milli /
bm_token_count / bm_df) + nx_research_extract (re_count/re_has). The existing nx_library_search is wired for
the researcher's [doc]-index corpus and caps at 256 docs; this drives the SAME BM25 math over the 5761-book
library index. TWO fixes for scale + real-world data:
(1) case-insensitive: the index paths are mixed-case, so we rank over a LOWERCASED copy of the index.
(2) O(N*nq) not O(N^2): bm_best recomputes df per-doc (fine for 256 docs, not 5761); we PRECOMPUTE idf
once per query term, then score each doc -> a true library-scale ranker.
Self-gated by KATs over the REAL index (dragonlance/byers/tolkien/witcher must rank a doc that contains the
term; "sanderson" has 0 matches -> must return NO result = negative control; dragonlance != byers = discrim).
Standalone (no server/reader edit -> no collision with the ark-beat loop). license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_research_extract.nxnx_itoa_lib.nxnx_bm25.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const BS_MAGIC_2000000: i64 = 2000000 |
| 19 | const BS_IDX: *u8 = "knowledge/staging/media/idx_book.wsl" |
| 20 | const BS_LOG: *u8 = "knowledge/status/book_search.log" |
| 21 | const BS_CAPDOCS: i64 = 8192 // > 5761 |
functions
| 23 | func bs_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 28 | func bs_n(v: i64) -> i64 { nxi_out(v); return 0 } |
| 29 | func bs_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 34 | func bs_fn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 35 | func bs_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: main |
| 37 | func bs_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 47 | func bs_best1(ptrs: *i64, lens: *i64, dls: *i64, ndocs: i64, avgdl: i64, term: *u8) -> i64 |
| 62 | func main() -> i64 |