src/matcher.pyscorer.pytests/test_matcher.pyconftest.py
1def rank(pool, role):2"""Rank candidates by fit against one role."""3scored = []4for c in pool:5depth = score_depth(c, role.stack)6if depth < 0.4:7continue8scored.append((depth, c))910ranked = sorted(scored, reverse=True)11return [c for _, c in ranked[:10]]1213def score_depth(c, stack):14hits = [s for s in stack if s in c.skills]15return len(hits) / len(stack)1617def shortlist(pool, role, limit=10):18"""Top matches for one role, best first."""19ranked = rank(pool, role)20return ranked[:limit]2122def explain(c, role):23hits = [s for s in role.stack if s in c.skills]24return ", ".join(hits)2526def to_row(c, role):27depth = score_depth(c, role.stack)28return {"id": c.id, "depth": round(depth, 2)}2930def report(pool, role):31for c in shortlist(pool, role):32row = to_row(c, role)33print(row["id"], row["depth"])3435def best(pool, role):36ranked = rank(pool, role)37return ranked[0] if ranked else None38