Spaces:
Running
Running
File size: 2,672 Bytes
b146445 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | """ํ์ต ์์ง ์๋ฎฌ๋ ์ด์
: ์ค์ ๋ฌธํญ ํ์ผ(aihub_A.jsonl)๋ก ๊ฐ์ ํ์์ด ํ ์ธ์
์ ํธ๋ ๊ณผ์ ์ ์ถ๋ ฅํฉ๋๋ค.
DBยทํค ์์ด PC ์์ ๋ฐ๋ก ๋๋ ค ๋ณผ ์ ์์ต๋๋ค.
python scripts\\sim_session.py --file data\\aihub_normalized\\aihub_A.jsonl --unit U12 --level low --acc 0.7 0.5 0.3
--acc : ํ/์ค/์ ๋์ด๋๋ณ ๊ฐ์ ํ์์ ์ ๋ต๋ฅ (๊ธฐ๋ณธ 0.8 0.6 0.4)
"""
import argparse
import json
import random
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from app.engine import LEVEL_KO, LEVELS, Pool, Rules, next_question, record_answer, start_session, summary # noqa: E402
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def wrong_answer(q):
return "9" if q["qtype"] == "multiple_choice" else "__์ค๋ต__"
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--file", type=Path, required=True)
ap.add_argument("--unit", required=True)
ap.add_argument("--level", default="low", choices=LEVELS)
ap.add_argument("--acc", type=float, nargs=3, default=[0.8, 0.6, 0.4])
ap.add_argument("--seed", type=int, default=1)
a = ap.parse_args()
rows = [json.loads(l) for l in a.file.open(encoding="utf-8") if l.strip()]
for r in rows:
r["id"] = r["source_ref"]
pool = Pool(rows)
c = pool.counts(a.unit)
print(f"{a.unit} ๋ฌธํญ ์ ํ {c['low']} / ์ค {c['mid']} / ์ {c['high']} (ํ ์นธ์ด {Rules().min_pool}๊ฐ ๋ฏธ๋ง์ด๋ฉด ์์ ์นธ)")
rng = random.Random(a.seed)
s = start_session(pool, a.unit, a.level)
if s.finished:
print("์ด ๋จ์์ ์ฌ์ฉํ ์ ์๋ ๋์ด๋๊ฐ ์์ต๋๋ค:", sorted(s.flags))
return
acc = dict(zip(LEVELS, a.acc))
while True:
nq = next_question(s, pool, rng=rng)
if nq is None:
break
q, phase = nq
ok = rng.random() < acc[q["difficulty"]]
resp = q["answer"] if ok else wrong_answer(q)
r = record_answer(s, pool, resp)
print(f" {len(s.log)}๋ฒ์งธ [{('์ฌ๋์ ' if phase == 'retry' else '์ฌ๋ค๋ฆฌ')}] ๋์ด๋ {LEVEL_KO[r['level_before']]} "
f"{q['id']:<20} {'์ ๋ต' if r['correct'] else '์ค๋ต'} -> ๋ค์ ๋์ด๋ {LEVEL_KO[r['level_after']]}")
if r["done"]:
break
sm = summary(s)
print(f"๋: {sm['answered']}๋ฌธ์ ์ค {sm['correct']}๋ฌธ์ ์ ๋ต | ์ต์ข
๋์ด๋ {LEVEL_KO[sm['final_level']]} | "
f"์ฌ๋์ ํด๊ฒฐ {len(sm['recovered'])} | ๋ฐ๋ณต ์ค๋ต {len(sm['stuck'])} | ํ์ {sm['flags'] or '์์'}")
if __name__ == "__main__":
main()
|