feat(zoology): integrate hyperstitionstud_io.* offline phonetics fallback, full 11-function local-config sources.py shim, and v1.2.0 common library

This commit is contained in:
Hermes Agent committed 2026-11-29 21:06:48 +00:00
1 parent 83c9069f23
commit 1f2c4f4a7e
7 files changed
+332 -606

No files matched your search

+30 -9
View File
@@ -30,11 +30,25 @@ import argparse
import json
import math
import subprocess
import sys
from pathlib import Path
from typing import Any
_CORE_SRC = Path("/workspace/hyperstitionstudio-core/src")
if _CORE_SRC.is_dir() and str(_CORE_SRC) not in sys.path:
sys.path.insert(0, str(_CORE_SRC))
try:
from hyperstitionstud_io.ciphers import compute_aq as _hs_compute_aq
from hyperstitionstud_io.phonetics import translate_batch as _hs_translate_batch
except ImportError:
_hs_compute_aq = None
_hs_translate_batch = None
def compute_aq(text: str) -> int:
if _hs_compute_aq is not None:
return _hs_compute_aq(text, quant_mode="digit")
total = 0
for ch in text.lower():
if "0" <= ch <= "9":
@@ -163,6 +177,8 @@ PREP_POOL = [
def batch_translate(terms: list[str], workdir: str = "/workspace/ingglish-hyperdope-gematria") -> dict[str, str]:
if not terms:
return {}
if _hs_translate_batch is not None and not (Path(workdir) / "node_modules" / "ingglish").is_dir():
return _hs_translate_batch(terms, workdir=workdir)
node_script = """
import { translate } from 'ingglish';
import fs from 'fs';
@@ -174,15 +190,20 @@ for (const t of items) {
}
process.stdout.write(JSON.stringify(out));
"""
proc = subprocess.run(
["node", "--input-type=module", "-e", node_script],
input=json.dumps(terms),
text=True,
cwd=workdir,
capture_output=True,
check=True,
)
return json.loads(proc.stdout)
try:
proc = subprocess.run(
["node", "--input-type=module", "-e", node_script],
input=json.dumps(terms),
text=True,
cwd=workdir,
capture_output=True,
check=True,
)
return json.loads(proc.stdout)
except Exception:
if _hs_translate_batch is not None:
return _hs_translate_batch(terms, workdir=workdir)
raise
def classify_term(eng: str, ing: str, eng_aq: int, ing_aq: int) -> list[str]: