- Remove legacy tracked hyperdope-ci-build/* files (moved to sibling repo /workspace/hyperdope-ci-build). - Remove duplicate root news dossiers (25, 46) and duplicate archive PDF compendium per Archive File Hygiene Rule. - Add evaluate_aq.mjs, generate_aq_tier_list.py, build_wire_report_pdf.py, pdf_create.py, and pdf_read.py to ingglish-aq-archive/scripts/. - Synchronize all 8 scripts and 8 creative Ingglish AQ skills into packaging/bundle/ and rebuild .tar.gz / .tar.xz bundles. - Update reconstruct_option4_curve.py and option-4-curve-migration-manifest.json paths to /workspace/ingglish-hyperdope-gematria/. - Add 47-eval-news-2026-11-02-bidirectional (.md + .pdf) and update master 17-dossier tier list (.md, .pdf, .png). - Track Series I-V repeat lecture transcripts, genealogy compendium, repdigit compendium, and wire report artifacts.
362 lines
11 KiB
JavaScript
Executable File
362 lines
11 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
||
/**
|
||
* evaluate_aq.mjs
|
||
* Deterministic Bidirectional English / Ingglish Alphanumeric Qabbala (AQ) Evaluator.
|
||
* Supports:
|
||
* Mode A (AND): --eng "<phrase>" --ing "<phrase>"
|
||
* Mode B (XOR Eng): --eng "<phrase>" (generates Ingglish via CMUdict + archive lexicon)
|
||
* Mode C (XOR Ing): --ing "<phrase>" (reconstructs English via archive lexicon + reverseTranslate + homophone forks)
|
||
*/
|
||
|
||
import fs from "node:fs";
|
||
import path from "node:path";
|
||
import { pathToFileURL } from "node:url";
|
||
|
||
async function loadIngglishModule() {
|
||
const candidates = [
|
||
"/workspace/ingglish-hyperdope-gematria/node_modules/ingglish/dist/index.js",
|
||
"/workspace/node_modules/ingglish/dist/index.js",
|
||
"/opt/ingglish-exegesis/node_modules/ingglish/dist/index.js",
|
||
];
|
||
for (const p of candidates) {
|
||
if (fs.existsSync(p)) {
|
||
return await import(pathToFileURL(p).href);
|
||
}
|
||
}
|
||
return await import("ingglish");
|
||
}
|
||
|
||
function computeAQ(text) {
|
||
let total = 0;
|
||
for (const ch of String(text).toLowerCase()) {
|
||
const code = ch.charCodeAt(0);
|
||
if (code >= 48 && code <= 57) {
|
||
total += code - 48;
|
||
} else if (code >= 97 && code <= 122) {
|
||
total += code - 97 + 10;
|
||
}
|
||
}
|
||
return total;
|
||
}
|
||
|
||
function buildPrimes(limit = 20000) {
|
||
const sieve = new Uint8Array(limit + 1);
|
||
sieve.fill(1);
|
||
sieve[0] = 0;
|
||
sieve[1] = 0;
|
||
for (let i = 2; i * i <= limit; i++) {
|
||
if (sieve[i]) {
|
||
for (let j = i * i; j <= limit; j += i) sieve[j] = 0;
|
||
}
|
||
}
|
||
const primeRank = new Map();
|
||
let rank = 0;
|
||
for (let n = 2; n <= limit; n++) {
|
||
if (sieve[n]) {
|
||
rank += 1;
|
||
primeRank.set(n, rank);
|
||
}
|
||
}
|
||
return primeRank;
|
||
}
|
||
|
||
const PRIME_RANK = buildPrimes(20000);
|
||
|
||
function factorize(n) {
|
||
if (n < 2) return String(n);
|
||
if (PRIME_RANK.has(n)) {
|
||
return `${n} [PRIME #${PRIME_RANK.get(n)}]`;
|
||
}
|
||
let temp = n;
|
||
const factors = [];
|
||
for (let d = 2; d * d <= temp; d += d === 2 ? 1 : 2) {
|
||
let count = 0;
|
||
while (temp % d === 0) {
|
||
count += 1;
|
||
temp = Math.floor(temp / d);
|
||
}
|
||
if (count > 0) {
|
||
factors.push(count === 1 ? `${d}` : `${d}^${count}`);
|
||
}
|
||
}
|
||
if (temp > 1) factors.push(`${temp}`);
|
||
return `${n} (${factors.join(" × ")})`;
|
||
}
|
||
|
||
const HOMOPHONE_FORKS = new Map([
|
||
["ai", ["I", "eye", "AI"]],
|
||
["nait", ["night", "knight"]],
|
||
["rait", ["write", "right", "rite"]],
|
||
["raits", ["writes", "rights", "rites"]],
|
||
["see", ["sea", "see"]],
|
||
["too", ["to", "too", "two"]],
|
||
["suhn", ["sun", "son"]],
|
||
["noo", ["new", "knew"]],
|
||
["hart", ["heart", "hart"]],
|
||
["seer", ["seer", "sear"]],
|
||
["werd", ["word", "whirred"]],
|
||
]);
|
||
|
||
const PROPER_NOUN_OVERRIDES_ENG_TO_ING = new Map([
|
||
["typhon", "taifan"],
|
||
["apophis", "apawfis"],
|
||
["joshua", "joshooa"],
|
||
["ramey", "raymee"],
|
||
["outpost", "outpohst"],
|
||
["childs", "chaildz"],
|
||
["macready", "makreedee"],
|
||
]);
|
||
|
||
function loadArchiveLexicon() {
|
||
const engToIng = new Map(PROPER_NOUN_OVERRIDES_ENG_TO_ING);
|
||
const ingToEng = new Map([
|
||
["dha", "the"],
|
||
["uhv", "of"],
|
||
["spairal", "spiral"],
|
||
["flaymethroher", "flamethrower"],
|
||
["outpohst", "outpost"],
|
||
["chaildz", "childs"],
|
||
["ayleean", "alien"],
|
||
["wiskee", "whiskey"],
|
||
["aiern", "iron"],
|
||
["deeman", "demon"],
|
||
["gohst", "ghost"],
|
||
["gohsts", "ghosts"],
|
||
["spaider", "spider"],
|
||
["hed", "head"],
|
||
["taifan", "typhon"],
|
||
["apawfis", "apophis"],
|
||
["joshooa", "joshua"],
|
||
["raymee", "ramey"],
|
||
]);
|
||
|
||
const lexPaths = [
|
||
"/workspace/ingglish-hyperdope-gematria/ingglish-aq-archive/01-ingglish-aq-lexicon.md",
|
||
"/workspace/ingglish-aq-archive/01-ingglish-aq-lexicon.md",
|
||
];
|
||
for (const lp of lexPaths) {
|
||
if (!fs.existsSync(lp)) continue;
|
||
const text = fs.readFileSync(lp, "utf8");
|
||
const bulletRe = /^-\s*`([^`]+)`\s*\("([^"]+)"\)\s*=\s*(\d+)/gm;
|
||
let m;
|
||
while ((m = bulletRe.exec(text)) !== null) {
|
||
const ing = m[1].trim().toLowerCase();
|
||
const eng = m[2].trim().toLowerCase();
|
||
if (!ingToEng.has(ing)) ingToEng.set(ing, eng);
|
||
if (!engToIng.has(eng)) engToIng.set(eng, ing);
|
||
}
|
||
break;
|
||
}
|
||
return { engToIng, ingToEng };
|
||
}
|
||
|
||
function classifyIsometry(engWord, ingWord, engAq, ingAq) {
|
||
if (engAq !== ingAq) return null;
|
||
const eClean = engWord.toLowerCase().replace(/[^a-z0-9]/g, "");
|
||
const iClean = ingWord.toLowerCase().replace(/[^a-z0-9]/g, "");
|
||
if (eClean === iClean) return "Type I (Invariant)";
|
||
const eSorted = eClean.split("").sort().join("");
|
||
const iSorted = iClean.split("").sort().join("");
|
||
if (eSorted === iSorted) return "Type II (Anagram)";
|
||
return "Type III (Compensatory Split)";
|
||
}
|
||
|
||
function parseArgs(argv) {
|
||
const args = { eng: null, ing: null, jsonOnly: false };
|
||
for (let i = 2; i < argv.length; i++) {
|
||
const a = argv[i];
|
||
if (a === "--eng" && i + 1 < argv.length) {
|
||
args.eng = argv[++i];
|
||
} else if (a === "--ing" && i + 1 < argv.length) {
|
||
args.ing = argv[++i];
|
||
} else if (a === "--json") {
|
||
args.jsonOnly = true;
|
||
} else if (a === "-h" || a === "--help") {
|
||
console.log(
|
||
"Usage: node evaluate_aq.mjs [--eng \"<english phrase>\"] [--ing \"<ingglish phrase>\"] [--json]"
|
||
);
|
||
process.exit(0);
|
||
}
|
||
}
|
||
if (!args.eng && !args.ing) {
|
||
console.error("Error: supply --eng, --ing, or both.");
|
||
process.exit(1);
|
||
}
|
||
return args;
|
||
}
|
||
|
||
async function main() {
|
||
const args = parseArgs(process.argv);
|
||
const ingglish = await loadIngglishModule();
|
||
const { engToIng, ingToEng } = loadArchiveLexicon();
|
||
|
||
let mode = "AND (Bidirectional Present)";
|
||
let engPhrase = args.eng ? args.eng.trim() : "";
|
||
let ingPhrase = args.ing ? args.ing.trim() : "";
|
||
|
||
if (engPhrase && !ingPhrase) {
|
||
mode = "XOR (English -> Ingglish)";
|
||
const rawTokens = engPhrase.split(/\s+/);
|
||
const outTokens = [];
|
||
for (const tok of rawTokens) {
|
||
const clean = tok.toLowerCase().replace(/[^a-z0-9'-]/g, "");
|
||
if (PROPER_NOUN_OVERRIDES_ENG_TO_ING.has(clean)) {
|
||
outTokens.push(PROPER_NOUN_OVERRIDES_ENG_TO_ING.get(clean));
|
||
} else {
|
||
const tr = await ingglish.translate(tok);
|
||
outTokens.push(tr.toLowerCase());
|
||
}
|
||
}
|
||
ingPhrase = outTokens.join(" ");
|
||
} else if (!engPhrase && ingPhrase) {
|
||
mode = "XOR (Ingglish -> English)";
|
||
const rawTokens = ingPhrase.split(/\s+/);
|
||
const outTokens = [];
|
||
for (const tok of rawTokens) {
|
||
const clean = tok.toLowerCase().replace(/[^a-z0-9'-]/g, "");
|
||
if (ingToEng.has(clean)) {
|
||
outTokens.push(ingToEng.get(clean));
|
||
} else if (typeof ingglish.reverseTranslate === "function") {
|
||
const rev = await ingglish.reverseTranslate(clean);
|
||
outTokens.push((rev || clean).toLowerCase());
|
||
} else {
|
||
outTokens.push(clean);
|
||
}
|
||
}
|
||
engPhrase = outTokens.join(" ");
|
||
}
|
||
|
||
const engWords = engPhrase.split(/\s+/).filter(Boolean);
|
||
const ingWords = ingPhrase.split(/\s+/).filter(Boolean);
|
||
|
||
const engAq = computeAQ(engPhrase);
|
||
const ingAq = computeAQ(ingPhrase);
|
||
const netDelta = ingAq - engAq;
|
||
|
||
const tokenComparison = [];
|
||
const homophoneForksFound = [];
|
||
let isoWordCount = 0;
|
||
let primeIngWordCount = 0;
|
||
let paddingWordCount = 0;
|
||
|
||
const maxLen = Math.max(engWords.length, ingWords.length);
|
||
for (let i = 0; i < maxLen; i++) {
|
||
const ew = engWords[i] || "";
|
||
const iw = ingWords[i] || "";
|
||
const eVal = computeAQ(ew);
|
||
const iVal = computeAQ(iw);
|
||
const dVal = iVal - eVal;
|
||
const isoType = ew && iw ? classifyIsometry(ew, iw, eVal, iVal) : null;
|
||
if (isoType) isoWordCount += 1;
|
||
if (PRIME_RANK.has(iVal)) primeIngWordCount += 1;
|
||
const iwClean = iw.toLowerCase().replace(/[^a-z0-9]/g, "");
|
||
if (iwClean === "seekrat" || iwClean === "hidan") paddingWordCount += 1;
|
||
if (HOMOPHONE_FORKS.has(iwClean)) {
|
||
const branches = HOMOPHONE_FORKS.get(iwClean).map((b) => ({
|
||
eng: b,
|
||
eng_aq: computeAQ(b),
|
||
eng_prime_rank: PRIME_RANK.get(computeAQ(b)) || null,
|
||
}));
|
||
homophoneForksFound.push({ ing: iwClean, ing_aq: iVal, branches });
|
||
}
|
||
tokenComparison.push({
|
||
eng_token: ew,
|
||
eng_aq: eVal,
|
||
eng_prime_rank: PRIME_RANK.get(eVal) || null,
|
||
ing_token: iw,
|
||
ing_aq: iVal,
|
||
ing_prime_rank: PRIME_RANK.get(iVal) || null,
|
||
delta: dVal,
|
||
isometry: isoType,
|
||
});
|
||
}
|
||
|
||
const isoRatePct = Number(((100 * isoWordCount) / Math.max(1, maxLen)).toFixed(1));
|
||
const primeIngRatePct = Number(((100 * primeIngWordCount) / Math.max(1, maxLen)).toFixed(1));
|
||
const paddingRatePct = Number(((100 * paddingWordCount) / Math.max(1, maxLen)).toFixed(1));
|
||
|
||
// Compute 5-dimension rubric score
|
||
const absDelta = Math.abs(netDelta);
|
||
let d1 = absDelta === 0 ? 20 : absDelta <= 35 ? 19 : absDelta <= 50 ? 18 : 17;
|
||
if (isoWordCount > 0 && d1 < 20) d1 = Math.min(20, d1 + 1);
|
||
|
||
const repdigits = new Set([111, 222, 333, 444, 555, 666, 777, 888, 999]);
|
||
const syzygies = new Set([81, 108, 216, 495]);
|
||
const twinPrimeClause = PRIME_RANK.has(engAq) && PRIME_RANK.has(ingAq);
|
||
const exact37Step = absDelta > 0 && absDelta % 37 === 0;
|
||
|
||
let d2 = homophoneForksFound.length > 0 || isoWordCount >= 2 ? 19 : 18;
|
||
let d3 = 17;
|
||
if (repdigits.has(ingAq) || repdigits.has(engAq)) d3 += 2;
|
||
if (twinPrimeClause || exact37Step || syzygies.has(ingAq)) d3 += 1;
|
||
if (primeIngRatePct >= 18) d3 += 1;
|
||
d3 = Math.min(20, d3);
|
||
|
||
let d4 = 18 + (homophoneForksFound.length > 0 || ingWords.includes("dha") ? 1 : 0);
|
||
d4 = Math.min(20, d4);
|
||
|
||
let d5 = paddingRatePct === 0 ? 19 : paddingRatePct < 15 ? 18 : paddingRatePct <= 30 ? 16 : 14;
|
||
if (netDelta === 0 && repdigits.has(ingAq)) d5 = 20;
|
||
|
||
const totalScore = d1 + d2 + d3 + d4 + d5;
|
||
const tier =
|
||
totalScore >= 95
|
||
? "Class S+ (Apex Lock)"
|
||
: totalScore >= 90
|
||
? "Class S (Canonical Lock)"
|
||
: totalScore >= 81
|
||
? "Class A (Structural Entry)"
|
||
: totalScore >= 72
|
||
? "Class B (Modular Entry)"
|
||
: "Class C/D/F";
|
||
|
||
const payload = {
|
||
mode,
|
||
english: {
|
||
phrase: engPhrase,
|
||
aq: engAq,
|
||
factorization: factorize(engAq),
|
||
is_prime: PRIME_RANK.has(engAq),
|
||
prime_rank: PRIME_RANK.get(engAq) || null,
|
||
breakdown: tokenComparison.map((t) => `${t.eng_token} (${t.eng_aq})`).join(" + ") + ` = ${engAq}`,
|
||
},
|
||
ingglish: {
|
||
phrase: ingPhrase,
|
||
aq: ingAq,
|
||
factorization: factorize(ingAq),
|
||
is_prime: PRIME_RANK.has(ingAq),
|
||
prime_rank: PRIME_RANK.get(ingAq) || null,
|
||
breakdown: tokenComparison.map((t) => `${t.ing_token} (${t.ing_aq})`).join(" + ") + ` = ${ingAq}`,
|
||
},
|
||
drift: {
|
||
net_delta: netDelta,
|
||
abs_delta: absDelta,
|
||
quantized_37_step: exact37Step,
|
||
full_clause_isometry: netDelta === 0,
|
||
twin_prime_clause: twinPrimeClause,
|
||
isometric_word_count: isoWordCount,
|
||
isometric_word_rate_pct: isoRatePct,
|
||
prime_ing_word_rate_pct: primeIngRatePct,
|
||
padding_rate_pct: paddingRatePct,
|
||
},
|
||
tokens: tokenComparison,
|
||
homophone_forks: homophoneForksFound,
|
||
rubric: {
|
||
D1_determinism_and_drift: d1,
|
||
D2_collision_density: d2,
|
||
D3_repdigit_and_prime_arch: d3,
|
||
D4_epistemological_fit: d4,
|
||
D5_syntactic_anti_padding: d5,
|
||
composite_score: totalScore,
|
||
classification: tier,
|
||
},
|
||
};
|
||
|
||
console.log(JSON.stringify(payload, null, 2));
|
||
}
|
||
|
||
main().catch((err) => {
|
||
console.error(err);
|
||
process.exit(1);
|
||
});
|