code wiki / (root) / nx_supp_claims_test.nx

nx_supp_claims_test.nx source

↩ module page · 137 lines · 8369 B

1// nx_supp_claims_test.nx -- gate for the label-claims classifier, built from 2// the exact sentences this product category actually uses. T4 is the one that 3// matters commercially: the standard way ginkgo is described in libido 4// marketing is a drug claim and cannot go on a label. 5// expect_exit: 0 license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_supp_claims.nx" 8 9func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10func t_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, bb, k); return 0 } 11 12func main() -> i64 { 13 var pass: i64 = 0 14 var total: i64 = 0 15 16 // --- T1 substring matcher is case-insensitive and honest about misses --- 17 total = total + 1 18 let h1: i64 = cl_has("Supports Healthy Libido" as *u8, "supports" as *u8) 19 let h2: i64 = cl_has("supports healthy libido" as *u8, "SUPPORTS" as *u8) 20 let h3: i64 = cl_has("supports healthy libido" as *u8, "treats" as *u8) 21 let h4: i64 = cl_find("abc" as *u8, "abcd" as *u8) 22 t_puts("T1 ci-match=" as *u8); t_putn(h1); t_puts("/" as *u8); t_putn(h2); t_puts(" miss=" as *u8); t_putn(h3); t_puts(" needle-longer=" as *u8); t_putn(h4); t_puts(" want 1/1/0/-1: " as *u8) 23 var ok1: i64 = 1 24 if h1 != 1 { ok1 = 0 } 25 if h2 != 1 { ok1 = 0 } 26 if h3 != 0 { ok1 = 0 } 27 if h4 != 0 - 1 { ok1 = 0 } 28 if ok1 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 29 30 // --- T2 the lawful framings this product would actually use --- 31 total = total + 1 32 let c1: i64 = cl_classify("Supports healthy sexual function" as *u8) 33 let c2: i64 = cl_classify("Helps maintain healthy blood flow" as *u8) 34 let c3: i64 = cl_classify("Promotes a healthy stress response" as *u8) 35 t_puts("T2 lawful S/F claims = " as *u8); t_putn(c1); t_puts("/" as *u8); t_putn(c2); t_puts("/" as *u8); t_putn(c3); t_puts(" want all 1: " as *u8) 36 var ok2: i64 = 1 37 if c1 != CL_STRUCTURE_FUNC { ok2 = 0 } 38 if c2 != CL_STRUCTURE_FUNC { ok2 = 0 } 39 if c3 != CL_STRUCTURE_FUNC { ok2 = 0 } 40 if ok2 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 41 42 // --- T3 disease claims are caught by verb AND by noun --- 43 total = total + 1 44 let d1: i64 = cl_classify("Treats low libido in women" as *u8) 45 let d2: i64 = cl_classify("For female sexual arousal disorder" as *u8) 46 let d3: i64 = cl_classify("Cures erectile problems" as *u8) 47 let d4: i64 = cl_classify("Prevents infertility" as *u8) 48 t_puts("T3 disease claims = " as *u8); t_putn(d1); t_puts("/" as *u8); t_putn(d2); t_puts("/" as *u8); t_putn(d3); t_puts("/" as *u8); t_putn(d4); t_puts(" want all 2: " as *u8) 49 var ok3: i64 = 1 50 if d1 != CL_DISEASE_CLAIM { ok3 = 0 } 51 if d2 != CL_DISEASE_CLAIM { ok3 = 0 } 52 if d3 != CL_DISEASE_CLAIM { ok3 = 0 } 53 if d4 != CL_DISEASE_CLAIM { ok3 = 0 } 54 if ok3 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 55 56 // --- T4 THE COMMERCIALLY IMPORTANT ONE: the standard ginkgo framing in 57 // this category is a DRUG claim and cannot be used --- 58 total = total + 1 59 let g1: i64 = cl_classify("Used to treat antidepressant-induced sexual dysfunction" as *u8) 60 let g2: i64 = cl_classify("A natural alternative to Viagra" as *u8) 61 let g3: i64 = cl_classify("Works alongside your SSRI" as *u8) 62 let g4: i64 = cl_classify("Take instead of a prescription" as *u8) 63 t_puts("T4 ginkgo-style / positioning claims = " as *u8); t_putn(g1); t_puts("/" as *u8); t_putn(g2); t_puts("/" as *u8); t_putn(g3); t_puts("/" as *u8); t_putn(g4); t_puts(" want 3=DRUG_REFERENCE: " as *u8) 64 var ok4: i64 = 1 65 if g1 != CL_DRUG_REFERENCE { ok4 = 0 } 66 if g2 != CL_DRUG_REFERENCE { ok4 = 0 } 67 if g3 != CL_DRUG_REFERENCE { ok4 = 0 } 68 if g4 != CL_DRUG_REFERENCE { ok4 = 0 } 69 if ok4 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 70 71 // --- T5 the near-miss pair FDA itself uses to teach the line --- 72 total = total + 1 73 let ok_chol: i64 = cl_classify("Helps maintain healthy cholesterol levels already within normal range" as *u8) 74 let bad_chol: i64 = cl_classify("Reverses high cholesterol disease" as *u8) 75 t_puts("T5 maintain-healthy=" as *u8); t_putn(ok_chol); t_puts(" vs disease-framing=" as *u8); t_putn(bad_chol); t_puts(" want 1/2: " as *u8) 76 if ok_chol == CL_STRUCTURE_FUNC { if bad_chol == CL_DISEASE_CLAIM { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } } else { t_puts("FAIL\n" as *u8) } 77 78 // --- T6 NATURAL STATES ARE NOT DISEASES --- 79 // A lexicon that flagged menopause would cost real lawful marketing. 80 total = total + 1 81 let m1: i64 = cl_classify("For the relief of hot flashes associated with menopause" as *u8) 82 let m2: i64 = cl_classify("Supports healthy aging" as *u8) 83 let m3: i64 = cl_classify("Treats menopause" as *u8) 84 let m4: i64 = cl_classify("Prevents osteoporosis after menopause" as *u8) 85 t_puts("T6 menopause relief=" as *u8); t_putn(m1); t_puts(" healthy aging=" as *u8); t_putn(m2); t_puts(" treats-menopause=" as *u8); t_putn(m3); t_puts(" osteoporosis=" as *u8); t_putn(m4); t_puts(" want 1/1/0(review)/2: " as *u8) 86 var ok6: i64 = 1 87 if m1 != CL_STRUCTURE_FUNC { ok6 = 0 } 88 if m2 != CL_STRUCTURE_FUNC { ok6 = 0 } 89 if m3 != CL_NEEDS_REVIEW { ok6 = 0 } 90 if m4 != CL_DISEASE_CLAIM { ok6 = 0 } 91 if ok6 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 92 93 // --- T7 FAIL-CLOSED: no trigger and no S/F frame is NOT approval --- 94 total = total + 1 95 let r1: i64 = cl_classify("Ancient Peruvian root, trusted for centuries" as *u8) 96 let r2: i64 = cl_classify("Feel like yourself again" as *u8) 97 let e: i64 = cl_classify("\x00" as *u8) 98 t_puts("T7 vague marketing = " as *u8); t_putn(r1); t_puts("/" as *u8); t_putn(r2); t_puts(" empty=" as *u8); t_putn(e); t_puts(" want 0/0/4 (never 1): " as *u8) 99 var ok7: i64 = 1 100 if r1 != CL_NEEDS_REVIEW { ok7 = 0 } 101 if r2 != CL_NEEDS_REVIEW { ok7 = 0 } 102 if e != CL_EMPTY { ok7 = 0 } 103 if ok7 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 104 105 // --- T8 a lawful claim carries BOTH obligations; an unlawful one 106 // carries neither (there is nothing to disclaim) --- 107 total = total + 1 108 let good: *u8 = "Supports healthy sexual function" as *u8 109 let bad: *u8 = "Treats sexual dysfunction" as *u8 110 let dg: i64 = cl_requires_disclaimer(good) 111 let ng: i64 = cl_notification_days(good) 112 let db: i64 = cl_requires_disclaimer(bad) 113 let nb: i64 = cl_notification_days(bad) 114 let lg: i64 = cl_is_lawful(good) 115 let lb: i64 = cl_is_lawful(bad) 116 t_puts("T8 lawful claim: disclaimer=" as *u8); t_putn(dg); t_puts(" notify-days=" as *u8); t_putn(ng); t_puts(" lawful=" as *u8); t_putn(lg); t_puts(" ; unlawful: " as *u8); t_putn(db); t_puts("/" as *u8); t_putn(nb); t_puts("/" as *u8); t_putn(lb); t_puts(": " as *u8) 117 var ok8: i64 = 1 118 if dg != 1 { ok8 = 0 } 119 if ng != 30 { ok8 = 0 } 120 if lg != 1 { ok8 = 0 } 121 if db != 0 { ok8 = 0 } 122 if nb != 0 { ok8 = 0 } 123 if lb != 0 { ok8 = 0 } 124 if ok8 == 1 { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 125 126 // --- T9 drug reference beats disease wording in precedence --- 127 // "An alternative to Viagra" has no disease noun at all, yet is squarely 128 // a drug claim; checking disease terms first would have let it pass. 129 total = total + 1 130 let p: i64 = cl_classify("A safe alternative to Cialis" as *u8) 131 t_puts("T9 no disease word, pure positioning = " as *u8); t_putn(p); t_puts(" want 3 not 0: " as *u8) 132 if p == CL_DRUG_REFERENCE { pass = pass + 1; t_puts("PASS\n" as *u8) } else { t_puts("FAIL\n" as *u8) } 133 134 t_puts("SUPP-CLAIMS-GATE passed " as *u8); t_putn(pass); t_puts("/" as *u8); t_putn(total) 135 if pass == total { t_puts(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 136 t_puts(" verdict=RED\n" as *u8); sys_exit(1); return 1 137}