Delete report.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106import osimport io
OUTPUT_DIR = "outputs"
def ensure_dirs(): os.makedirs(OUTPUT_DIR, exist_ok=True)
def generate_pdf(path: str): ensure_dirs() lines = [ "SHL Assessment Recommendation System - Approach", "", "Architecture:", "- Ingestion: Playwright + BeautifulSoup to scrape SHL catalog (>=377 items).", "- Storage: JSONL at data/catalog.jsonl; Chroma vector store with metadata.", "- Embeddings: sentence-transformers/all-MiniLM-L6-v2; cosine similarity.", "- Retrieval: Hybrid semantic + BM25 lexical; K/P balancing.", "- API: FastAPI /health, /recommend; minimal frontend index page.", "- Evaluation: Recall@10 on TRAIN from Gen_AI Dataset.xlsx; mean metric.", "- Predictions: TEST queries to CSV as Query,Assessment_URL.", "", "Scraping Strategy:", "- Discover product links from SHL Product Catalog and Kenexa pages.", "- Parse detail pages for name, type (K/P), description, skills.", "- Normalize URLs; deduplicate by URL hash; retries and robust selectors.", "", "RAG/LLM Choices:", "- Local embeddings for reliability; BM25 for exact keyword alignment.", "- Query processing accepts text/JD text/JD URL; cleans JD content.", "- Balancing favors both Knowledge/Skills and Personality/Behavior.", "", "Evaluation:", "- Recall@10 per query: |top10 ∩ ground_truth| / |ground_truth|.", "- Mean Recall@10 across TRAIN; logged to outputs/train_recall.csv.", "", "API & Output:", "- /recommend returns 5–10 items: name, url, type.", "- TEST predictions CSV: outputs/firstname_lastname.csv.", "", "Deployment:", "- Uvicorn serving FastAPI; persistent index under data/chroma.", "", "Notes:", "- Ensure scraping coverage >=377 assessments before indexing.", "- Re-run index after scrape to refresh embeddings.", ] w = 612 h = 792 objs = [] def add_obj(s: bytes) -> int: pos = sum(len(x) for x in objs) objs.append(s) return pos out = io.BytesIO() out.write(b"%PDF-1.4\n%\xe2\xe3\xcf\xd3\n") xref = [] pos1 = add_obj(b"1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n") xref.append(pos1) pos2 = add_obj(b"2 0 obj\n<< /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >>\nendobj\n") xref.append(pos2) font_obj = b"7 0 obj\n<< /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica >>\nendobj\n" pos7 = add_obj(font_obj) xref.append(pos7) def make_stream(text_lines): y = h - 72 parts = ["BT /F1 12 Tf"] for t in text_lines: safe = t.replace("\\", "\\\\").replace("(", "\\(").replace(")", "\\)") parts.append(f"72 {int(y)} Td ({safe}) Tj") y -= 18 if y < 72: parts.append("ET") break parts.append("ET") content = "\n".join(parts).encode("utf-8") s = b"<< /Length " + str(len(content)).encode("ascii") + b" >>\nstream\n" + content + b"\nendstream\n" return s half = len(lines) // 2 + 1 page1_stream = make_stream(lines[:half]) pos5 = add_obj(b"5 0 obj\n" + page1_stream + b"endobj\n") xref.append(pos5) pos3 = add_obj(b"3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 7 0 R >> >> /Contents 5 0 R >>\nendobj\n") xref.append(pos3) page2_stream = make_stream(lines[half:]) pos6 = add_obj(b"6 0 obj\n" + page2_stream + b"endobj\n") xref.append(pos6) pos4 = add_obj(b"4 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 7 0 R >> >> /Contents 6 0 R >>\nendobj\n") xref.append(pos4) offsets = [] cur = out.tell() for s in objs: offsets.append(cur) out.write(s) cur = out.tell() xref_start = out.tell() out.write(b"xref\n0 " + str(len(offsets) + 1).encode("ascii") + b"\n") out.write(b"0000000000 65535 f \n") for off in offsets: out.write(f"{off:010d} 00000 n \n".encode("ascii")) out.write(b"trailer\n<< /Size " + str(len(offsets) + 1).encode("ascii") + b" /Root 1 0 R >>\nstartxref\n") out.write(str(xref_start).encode("ascii") + b"\n%%EOF") with open(path, "wb") as f: f.write(out.getvalue())report.pyDeleted-106