ZeKaiNie/universal-examprep-skill / skills/universal-exam-cram-coach
universal-exam-cram-coach
Flagged临考复习教练 / Exam cram coach. 学生给一个课程资料文件夹(课件 PDF/PPTX/DOCX/笔记/作业/答案/真题/往年卷),它按章节讲解并标出处、把讲义和题目里的图裁出来展示、只用资料里的题考试判分、记错题和笔记、按天排复习计划、做小抄,并标明每句话是否来自资料。触发词:期末、期中、考试、备考、复习、突击、刷题、真题、作业讲解、错题本、划重点、小抄、复习计划、考研、考证、课件讲解、讲义。Use when a student wants to prepare for a final, midterm or any exam from their own course files: teach chapter by chapter with page citations and the figures cropped from the materials, quiz only from the homework and past papers, keep progress, mistakes and notes across chats, plan the remaining days, build a cheat sheet, and label what comes from the materials. Triggers: exam prep, cram, revise, study for the test, lecture slides, homework solutions, past papers, practice questions, quiz me, mistake log, cheat sheet, study plan, study guide, flashcards.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 1.0 KB |
| SKILL.md | skill md | 10.3 KB |
| coach.py | script | 286 B |
| coach/__init__.py | script | 154 B |
| coach/chapters.py | script | 8.1 KB |
| coach/cli.py | script | 58.3 KB |
| coach/extract.py | script | 11.3 KB |
| coach/figures.py | script | 13.1 KB |
| coach/guard.py | script | 6.6 KB |
| coach/index.py | script | 2.4 KB |
| coach/questions.py | script | 15.3 KB |
| coach/state.py | script | 6.4 KB |
| coach/text.py | script | 4.0 KB |
coach/index.py
View on GitHub# -*- coding: utf-8 -*-
"""Tiny BM25 retrieval over chapter chunks. No dependencies, rebuilt in memory on load."""
import json
import math
import os
from collections import Counter
from .text import pack, tokenize
INDEX_FILE = "index.json"
CHUNK_CHARS = 600
K1, B = 1.5, 0.75
class BM25(object):
def __init__(self, docs_tokens):
self.n = len(docs_tokens)
self.tf = [Counter(t) for t in docs_tokens]
self.dl = [len(t) for t in docs_tokens]
self.avgdl = (sum(self.dl) / self.n) if self.n else 1.0
df = Counter()
for c in self.tf:
df.update(c.keys())
self.idf = {t: math.log(1 + (self.n - d + 0.5) / (d + 0.5)) for t, d in df.items()}
def scores(self, query_tokens):
out = [0.0] * self.n
for q in set(query_tokens):
idf = self.idf.get(q)
if idf is None:
continue
for i, c in enumerate(self.tf):
f = c.get(q)
if not f:
continue
out[i] += idf * f * (K1 + 1) / (f + K1 * (1 - B + B * self.dl[i] / self.avgdl))
return out
def best(self, query_tokens, k=5):
sc = self.scores(query_tokens)
order = sorted(range(self.n), key=lambda i: -sc[i])
return [(i, sc[i]) for i in order[:k] if sc[i] > 0]
def build_chunks(chapters):
chunks = []
for ch in chapters:
for rel, page, text in ch.blocks:
for piece in pack(text, CHUNK_CHARS):
chunks.append({"chapter": ch.number, "file": rel, "page": page, "text": piece})
return chunks
def save_index(ws, chunks):
path = os.path.join(ws, INDEX_FILE)
tmp = path + ".tmp"
with open(tmp, "w", encoding="utf-8") as fh:
json.dump({"version": 5, "chunks": chunks}, fh, ensure_ascii=False)
os.replace(tmp, path)
def load_index(ws):
path = os.path.join(ws, INDEX_FILE)
if not os.path.exists(path):
return []
with open(path, encoding="utf-8") as fh:
return json.load(fh).get("chunks", [])
def search(chunks, query, k=5, chapter=None):
"""Return [(chunk, score)] ranked by BM25; empty list means the materials have no match."""
pool = [c for c in chunks if chapter is None or c["chapter"] == chapter]
if not pool:
return []
bm = BM25([tokenize(c["text"]) for c in pool])
q = tokenize(query)
return [(pool[i], s) for i, s in bm.best(q, k)]
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |