# -*- coding: utf-8 -*- """Offline check of 換數字: how many dataset questions get a valid variant (new reference answer from the brain), and a few examples. python -B tools/test_variant.py""" import json import random import sys from collections import Counter from pathlib import Path ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) import pipeline # noqa: E402 d = json.load(open(ROOT / "data" / "problems.json", encoding="utf-8")) rng = random.Random(1) cnt, ex = Counter(), [] for t in d["types"]: for x in t["items"]: v = pipeline.variant(x["question"], x["deepseek_v7_lines"], rng) cnt["ok" if v["question"] else v["why"]] += 1 cnt[f"tries{v['tries']}"] += bool(v["question"]) if v["question"] and len(ex) < 3: ex.append((x["question"], x["gold"], v["question"], v["gold"])) print(dict(cnt)) for e in ex: print(*e, sep="\n ") kira = ("Three train stations are 2 hours apart from one another. Kira travels from the first station to the third, " "taking a 30 minutes break at the second station. What's the total time, in minutes, that Kira takes to travel " "between the first and third station?") print(pipeline.change_numbers(kira, rng)) print(pipeline.change_numbers("He paid $1,200 and 2.5 hours on the 3rd day at 3:30, 20% off, twice 4.", rng))