"""Strict numeric check: OpenThink question with EXACTLY the ArithMark item's numbers (same multiset), the same gold answer, ranked by content-word overlap (Jaccard) between the two questions. Prints the closest pairs for inspection.""" import json, re AM = [json.loads(l) for l in open("/media/joseph/Media/Boris-2-0920/ability_audit/arithmark-3_official.jsonl")] OT = [json.loads(l) for l in open("/home/joseph/openthink/openthink_clean.jsonl")] STOP = set("a an the of to in and is was were had has have each for on at all with into then how many much did does do what more".split()) nums = lambda s: sorted(re.findall(r"\d+(?:\.\d+)?", s.replace(",", ""))) words = lambda s: {w for w in re.findall(r"[a-z]+", s.lower()) if w not in STOP and len(w) > 2} H = json.load(open("hits.json"))["numsig"] rows = [] for i, j in H: a, o = AM[i], OT[j] if nums(a["ctx"]) != nums(o["question"]): continue wa, wo = words(a["ctx"]), words(o["question"]); jac = len(wa & wo) / max(1, len(wa | wo)) rows.append((jac, i, j)) rows.sort(reverse=True) print(f"pairs with identical number set + same answer: {len(rows)} (of {len(H)} loose matches)") print("Jaccard distribution:", {t: sum(r[0] >= t for r in rows) for t in (0.1, 0.2, 0.3, 0.5)}) for jac, i, j in rows[:12]: print(f"\n[{jac:.2f}] AM: {AM[i]['ctx']!r} -> {AM[i]['metadata']['answer']}\n OT: {OT[j]['question']!r} -> {OT[j]['answer']!r}")