code wiki / _hdl_build / nx_reader_xray.nx

nx_reader_xray.nx

buildroot/runtime/_hdl_build/nx_reader_xray.nx

19868 B436 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic reader
docsdependenciesstructsconstsfunctions

about

nx_reader_xray.nx -- SOVEREIGN, ZERO-DEPENDENCY, book-INTRINSIC X-Ray. Operator law: attack the BEHIND "aids ecosystem" axis of nx_reader_exceed_gate with a REAL capability, not a sovereignty restatement. Kindle's X-Ray is PROVISIONED-ONLY (exists only where Amazon pre-built the data, so most books show "X-Ray: Not available"). This organ DERIVES an X-Ray from the book's OWN text -- works on ANY book, offline, deterministic, auditable. Algorithm (deterministic, no random, no external data): - per chapter, skip the leading duplicate-title lines exactly as nx_reader_render does (index PROSE not headings) - tokenize into maximal A-Za-z runs; track for each token: capitalized? sentence-initial? space-joined-to-prev? - a NAME = a maximal run of consecutive capitalized tokens joined ONLY by spaces (so "White Rabbit" is one entity, but "Alice. Rabbit" is two). A multi-token run always qualifies (proper-noun phrase). A single capitalized token qualifies only if it is MID-sentence (not sentence-initial) AND not a stopword -- this is what separates "thought Alice" (entity) from "But when" / "There was" (sentence openers, not entities). - count occurrences per distinct name + remember the first chapter it appears in (for jump-to-first-mention) - keep names with count >= MINOCC; sort by count desc, then name asc (fully deterministic) Emits knowledge/staging/media/reader/<slug>/xray.json + prints a raw scorecard. Reads OUR own book.json + chap<N>.txt (emitted by nx_epub_book). expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_reader_xray.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close p w sys_write slen sys_exit jfrom slen ↻ jint jstr process_chapter skip_title line_eq is_alpha is_upper sys_mmap ↻ is_stopword streq tt_register streq ↻ strlt sys_openat_wr w ↻ wesc_json w ↻ sys_write ↻ wn sys_write ↻ sys_mmap ↻ sys_close ↻

structs

none

consts

18const K_MAGIC_1000000: i64 = 1000000
19const K_MAGIC_1024: i64 = 1024
21const MAXTERMS: i64 = 512
22const NAMELEN: i64 = 64
23const MAXTOK: i64 = 8192
24const MINOCC: i64 = 2 // a term must recur >=2x to be "notable" (filters one-off caps). TODO: promote to reader svc-config.
25const MAXCHAP: i64 = 256 // per-chapter occurrence-distribution cap (concordance); books rarely exceed, distribution truncates beyond

functions

27func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 3: wjfromjval_str
28func w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, slen(s)); return 0 }
called by 3: pwesc_jsonmain calls 2: sys_writeslen
29func wn(fd: i64, v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(fd,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48 as u8;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(fd,o,k); return 0 }
called by 1: main calls 2: sys_writesys_mmap
30func p(s: *u8) -> i64 { w(1, s); return 0 }
called by 1: main calls 1: w
33func jfrom(hay: *u8, hl: i64, start: i64, needle: *u8) -> i64
called by 2: jval_strmain calls 1: slen
39func jint(hay: *u8, hl: i64, pos: i64) -> i64
called by 1: main
49func jstr(hay: *u8, hl: i64, pos: i64, out: *u8, cap: i64) -> i64
called by 2: jval_strmain
62func jval_str(hay: *u8, hl: i64, key: *u8, out: *u8, cap: i64) -> i64
calls 3: jfromjstrslen
69func is_upper(c: i64) -> i64 { if c>=65 { if c<=90 { return 1 } } return 0 }
called by 1: process_chapter
70func is_alpha(c: i64) -> i64 { if c>=65 { if c<=90 { return 1 } } if c>=97 { if c<=122 { return 1 } } return 0 }
called by 1: process_chapter
71func streq(a: *u8, b: *u8) -> i64
82func strlt(a: *u8, b: *u8) -> i64
called by 1: main
93func wesc_json(fd: i64, s: *u8) -> i64
called by 1: main calls 2: wsys_write
109func is_stopword(s: *u8) -> i64
called by 1: process_chapter calls 1: streq
176func line_eq(txt: *u8, s: i64, e: i64, title: *u8) -> i64
called by 1: skip_title
185func skip_title(txt: *u8, n: i64, title: *u8) -> i64
called by 1: process_chapter calls 1: line_eq
202func tt_register(ctx: *i64, nm: *u8, cidx: i64) -> i64
called by 1: process_chapter calls 1: streq
234func process_chapter(txt: *u8, n: i64, title: *u8, cidx: i64, ctx: *i64) -> i64
301func main(argc: i64, argv: *i64) -> i64