Spaces:
Running
Running
Download scripts/20_coverage_all.py from lilyjeongwon/math-tutor: direct link, hf CLI and curl.
- Browser
- Download file 3.33 kB
-
https://huggingface.co/spaces/lilyjeongwon/math-tutor/resolve/main/scripts/20_coverage_all.py
- Command line
-
hf download hf://spaces/lilyjeongwon/math-tutor/scripts/20_coverage_all.py
-
curl -L -o 20_coverage_all.py https://huggingface.co/spaces/lilyjeongwon/math-tutor/resolve/main/scripts/20_coverage_all.py
3.33 kB
| """EBSi(h1ยทh2ยทh3) + AI Hub ๋จ์๋ณ ๋ฌธํญ ์๋ฅผ ํฉ์น ํ๋ฅผ ๋ง๋ ๋ค. | |
| python scripts\\20_coverage_all.py | |
| ์ ๋ ฅ | |
| data/aihub_normalized/coverage_after.csv AI Hub (unit_id, unit_name, A_low, A_mid, A_high, usable_low, usable_mid, usable_high) | |
| data/ebsi/coverage_ebsi_h1.csv / _h2 / _h3 EBSi ํ๋ ๋ณ (๊ฐ์ ์ด) โ scripts/16_ebsi_units.py build ๊ฒฐ๊ณผ | |
| ์ถ๋ ฅ | |
| data/coverage_all.csv | |
| unit_id, unit_name, | |
| aihub_A, ebsi_h1_A, ebsi_h2_A, ebsi_h3_A, (์ถ์ฒ๋ณ A ํฉ) | |
| aihub_usable, ebsi_h1_usable, ebsi_h2_usable, ebsi_h3_usable, (์ถ์ฒ๋ณ usable ํฉ = low+mid+high) | |
| A_low, A_mid, A_high, usable_low, usable_mid, usable_high, (์ ์ฒด ํฉ) | |
| usable_total | |
| A = ๊ธ์๋ก ์๋น, usable = A + B (๊ทธ๋ฆผยท์์ยท์ด๋ฏธ์ง ํจ๊ป ํ์). C(์๋ ๊ฒฝ๊ณ )๋ ๋น ์ง. | |
| ๋น์ฉยท์ธ๋ถ ์ฐ๊ธฐ ์์. | |
| """ | |
| import csv | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| SOURCES = [ | |
| ("aihub", ROOT / "data/aihub_normalized/coverage_after.csv"), | |
| ("ebsi_h1", ROOT / "data/ebsi/coverage_ebsi_h1.csv"), | |
| ("ebsi_h2", ROOT / "data/ebsi/coverage_ebsi_h2.csv"), | |
| ("ebsi_h3", ROOT / "data/ebsi/coverage_ebsi_h3.csv"), | |
| ] | |
| COLS = ["A_low", "A_mid", "A_high", "usable_low", "usable_mid", "usable_high"] | |
| OUT = ROOT / "data/coverage_all.csv" | |
| def read(p): | |
| with open(p, encoding="utf-8-sig", newline="") as f: | |
| return [r for r in csv.DictReader(f) if r.get("unit_id")] | |
| def main(): | |
| order, names, tot, per, perA = [], {}, {}, {}, {} | |
| for src, p in SOURCES: | |
| if not p.exists(): | |
| raise SystemExit(f"์์: {p}") | |
| for r in read(p): | |
| u = r["unit_id"] | |
| if u not in names: | |
| order.append(u) | |
| names[u] = r["unit_name"] | |
| tot[u] = {c: 0 for c in COLS} | |
| for c in COLS: | |
| tot[u][c] += int(r[c] or 0) | |
| per[(src, u)] = sum(int(r[c] or 0) for c in ("usable_low", "usable_mid", "usable_high")) | |
| perA[(src, u)] = sum(int(r[c] or 0) for c in ("A_low", "A_mid", "A_high")) | |
| head = (["unit_id", "unit_name"] + [f"{s}_A" for s, _ in SOURCES] + [f"{s}_usable" for s, _ in SOURCES] | |
| + COLS + ["usable_total"]) | |
| with open(OUT, "w", encoding="utf-8-sig", newline="") as f: | |
| w = csv.writer(f) | |
| w.writerow(head) | |
| for u in order: | |
| t = tot[u] | |
| w.writerow([u, names[u]] + [perA.get((s, u), 0) for s, _ in SOURCES] + [per.get((s, u), 0) for s, _ in SOURCES] | |
| + [t[c] for c in COLS] + [t["usable_low"] + t["usable_mid"] + t["usable_high"]]) | |
| srcsum = {s: sum(per.get((s, u), 0) for u in order) for s, _ in SOURCES} | |
| srcA = {s: sum(perA.get((s, u), 0) for u in order) for s, _ in SOURCES} | |
| print(f"๋จ์ {len(order)}๊ฐ -> {OUT}") | |
| print("์ถ์ฒ๋ณ A:", srcA, "| ํฉ", sum(srcA.values())) | |
| print("์ถ์ฒ๋ณ usable(A+B):", srcsum, "| ํฉ", sum(srcsum.values())) | |
| print("์ฐธ๊ณ : AI Hub ๋ DB ์ A ๋ง ์ ์ฌ๋จ(B ๋ฏธ์ ์ฌ). EBSi ๋ A+B ๋ชจ๋ ์ ์ฌ(B ๋ ๋ฌธํญ ์ด๋ฏธ์ง ํจ๊ป ํ์).") | |
| empty = [u for u in order if tot[u]["usable_low"] + tot[u]["usable_mid"] + tot[u]["usable_high"] == 0] | |
| print(f"๋ฌธํญ 0๊ฐ ๋จ์ {len(empty)}๊ฐ:", " ".join(empty)) | |
| if __name__ == "__main__": | |
| main() | |