code wiki / _hdl_build / nx_research_live_landscape.nx
nx_research_live_landscape.nx source
↩ module page · 53 lines · 2452 B
1// nx_research_live_landscape.nx -- R5: the LIVE corroborated landscape. Reads the
2// real multi-source text (/tmp/src0..2.txt from nx_multi_fetch), harvests claims
3// from each with its source id, and renders the corroborated competitive landscape
4// (Gartner-grade, exceeding it). Research-organ tree only. expect_exit: 0.
5
6import "nx_syscalls.nx"
7import "nx_research_extract.nx"
8import "nx_research_landscape.nx"
9const K_MAGIC_1024: i64 = 1024
10const K_MAGIC_1048576: i64 = 1048576
11
12func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
13func wn(v: i64) -> i64 {
14 let b: *u8 = sys_mmap(28); var m: i64 = v
15 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) }
16 let t: *u8 = sys_mmap(28); var k: i64 = 0
17 if m == 0 { t[0] = 48 as u8; k = 1 }
18 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
19 var i: i64 = 0; while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
20 sys_write(1, b, k); return 0
21}
22
23func load_harvest(path: *u8, src: i64, subjs: *i64, rels: *i64, objs: *i64, srcs: *i64, np: *i64, cap: i64) -> i64 {
24 let len: *i64 = (sys_mmap(8)) as *i64
25 let txt: *u8 = sys_read_file(path, len)
26 if len[0] <= 0 { w(" (skip " as *u8); w(path); w(" -- not found)\n" as *u8); return 0 }
27 nx_rel_harvest(txt, len[0], src, subjs, rels, objs, srcs, np, cap)
28 w(" " as *u8); w(path); w(": text=" as *u8); wn(len[0]); w(" claims_total=" as *u8); wn(np[0]); w("\n" as *u8)
29 return 0
30}
31
32func main() -> i64 {
33 let cap: i64 = K_MAGIC_1024
34 let subjs: *i64 = (sys_mmap(cap * 8)) as *i64
35 let rels: *i64 = (sys_mmap(cap * 8)) as *i64
36 let objs: *i64 = (sys_mmap(cap * 8)) as *i64
37 let srcs: *i64 = (sys_mmap(cap * 8)) as *i64
38 let np: *i64 = (sys_mmap(8)) as *i64
39 np[0] = 0
40
41 w("=== R5: LIVE corroborated landscape from real multi-source fetch ===\n" as *u8)
42 load_harvest("/tmp/src0.txt" as *u8, 0, subjs, rels, objs, srcs, np, cap)
43 load_harvest("/tmp/src1.txt" as *u8, 1, subjs, rels, objs, srcs, np, cap)
44 load_harvest("/tmp/src2.txt" as *u8, 2, subjs, rels, objs, srcs, np, cap)
45 if np[0] <= 0 { w("NO CLAIMS (run nx_multi_fetch first)\n" as *u8); return 1 }
46
47 let out: *u8 = sys_mmap(K_MAGIC_1048576)
48 let opt: i64 = ls_render(subjs, rels, objs, srcs, np[0], out)
49 w("\n" as *u8)
50 w(out)
51 w("\n(total options=" as *u8); wn(opt); w(", total claims=" as *u8); wn(np[0]); w(")\n" as *u8)
52 return 0
53}