Spaces:
Running
Running
| """ | |
| menu_descriptions.jsonl에서 SCR_ 형식 항목만 남기고 구형 항목(DOM_/OVS_/FUT_/AST_/INF_/SET_ 등) 제거. | |
| 배경: | |
| - 기존 JSONL에는 구형 샘플 101개(DOM_/SET_ 등) + 신형 901개(SCR_)가 혼재 | |
| - 구형 항목의 category 메타데이터가 "주문화면" 등 잘못된 값 → ChromaDB 검색 오류 유발 | |
| - 이 스크립트로 SCR_ 형식만 남기고 02_build_vectordb.py --reset 재실행 | |
| 실행: | |
| python scripts/00b_clean_jsonl.py | |
| 결과: | |
| data/generated/menu_descriptions.jsonl → SCR_ 901개만 유지 | |
| """ | |
| import jsonlines | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from config import GENERATED_DIR | |
| path = GENERATED_DIR / "menu_descriptions.jsonl" | |
| if not path.exists(): | |
| print(f"[오류] 파일이 없습니다: {path}") | |
| sys.exit(1) | |
| items = list(jsonlines.open(path)) | |
| before = len(items) | |
| scr_items = [m for m in items if m.get("menu_id", "").startswith("SCR_")] | |
| removed = before - len(scr_items) | |
| with jsonlines.open(path, mode="w") as writer: | |
| for item in scr_items: | |
| writer.write(item) | |
| print(f"정리 완료: {before}개 → {len(scr_items)}개 (SCR_ 형식만 유지)") | |
| print(f" 제거된 구형 항목: {removed}개 (DOM_/OVS_/FUT_/AST_/INF_/SET_ 등)") | |
| print(f" 남은 SCR_ 항목: {len(scr_items)}개") | |
| print(f"\n다음 단계: python scripts/02_build_vectordb.py --reset") | |