Seoryxa / research /export_hf_tables.py
PureOne's picture
Release Seoryxa research and verification data
10d1f61 verified
Raw History Blame Contribute Delete
1.77 kB
"""Rebuild the Hugging Face JSONL tables from the original results and fixtures."""
import json
from pathlib import Path
from exact_ranks import NINE, SOLIDS
ROOT = Path(__file__).resolve().parents[1]
DATA = ROOT / "data"
def coordinates():
clouds = {name: [(point, 0) for point in points]
for name, (points, _) in SOLIDS.items()}
clouds["nine_unmarked"] = [(point, 0) for point in NINE]
axes = [tuple(int(j == i) for j in range(3)) for i in range(3)]
clouds["six_two_colors"] = ([(point, 1) for point in axes]
+ [(tuple(-v for v in point), 0) for point in axes])
for name, records in clouds.items():
for i, ((x, y, z), label) in enumerate(records):
yield dict(cloud=name, point_index=i, x=x, y=y, z=z, node_label=label)
def main():
DATA.mkdir(exist_ok=True)
results = json.loads((ROOT / "research" / "results.json").read_text(encoding="utf-8"))
tables = {
"regular_shapes": [dict(shape=shape, **row)
for shape, rows in results["regular_shapes"].items() for row in rows],
"nine_point": results["nine_point_exact"],
"frame_checks": results["frame_checks"],
"smooth_kernel": results["smooth_kernel_checks"],
"point_clouds": list(coordinates()),
"orbit_benchmark": [results["orbit_benchmark"]],
}
for name, rows in tables.items():
with (DATA / f"{name}.jsonl").open("w", encoding="utf-8", newline="\n") as file:
for row in rows:
file.write(json.dumps(row, ensure_ascii=False, allow_nan=False,
separators=(",", ":")) + "\n")
print(f"{name}: {len(rows)} rows")
if __name__ == "__main__":
main()