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/text.py
View on GitHub# -*- coding: utf-8 -*-
"""Small shared text helpers: tokenizing (ASCII words + CJK bigrams), cleanup, slicing."""
import re
import unicodedata
CJK = "-ヿ㐀-䶿一-鿿"
_TOKEN_RE = re.compile(r"[a-z0-9][a-z0-9'+#\-]*|[%s]+" % CJK)
_CJK_RE = re.compile("[%s]" % CJK)
_STOP = frozenset(
"a an the is are was were be been being am do does did have has had will would shall should "
"can could may might must of in on at by for with about between into through to from up down "
"out off over under and or but not no so than too very this that these those it its we you they "
"he she i me my our your their what which who whom how when where why if then else".split()
)
# Ligatures and typography that PDF extraction commonly produces.
_REPLACE = {
"fi": "fi", "fl": "fl", "ff": "ff", "ffi": "ffi", "ffl": "ffl",
"’": "'", "‘": "'", "“": '"', "”": '"', " ": " ",
"−": "-", "–": "-", "—": "-",
}
def clean(text):
"""Normalize whitespace and typography without destroying paragraph breaks."""
if not text:
return ""
for k, v in _REPLACE.items():
text = text.replace(k, v)
text = text.replace("\r\n", "\n").replace("\r", "\n")
text = re.sub(r"[ \t\f\v]+", " ", text)
text = re.sub(r" *\n *", "\n", text)
text = re.sub(r"\n{3,}", "\n\n", text)
return text.strip()
def is_mostly_cjk(text, sample=4000):
"""True when CJK characters dominate the alphabetic content."""
if not text:
return False
sample_text = text[:sample]
cjk = len(_CJK_RE.findall(sample_text))
latin = sum(1 for ch in sample_text if ch.isascii() and ch.isalpha())
return cjk * 2 > latin # one CJK character carries about as much as two Latin letters
def tokenize(text):
"""ASCII words lowercased plus CJK character bigrams (unigram for a lone CJK char)."""
out = []
for tok in _TOKEN_RE.findall(text.lower()):
if _CJK_RE.match(tok):
if len(tok) == 1:
out.append(tok)
else:
out.extend(tok[i:i + 2] for i in range(len(tok) - 1))
else:
if tok in _STOP:
continue
if tok.endswith("'s"):
tok = tok[:-2]
out.append(tok)
return out
def split_paragraphs(text):
return [p.strip() for p in re.split(r"\n\s*\n", text) if p.strip()]
def pack(text, target, hard_max=None):
"""Split text into pieces of about `target` chars at paragraph, then line, boundaries."""
hard_max = hard_max or int(target * 1.4)
pieces, cur = [], ""
for para in split_paragraphs(text):
if len(para) > hard_max:
# very long paragraph: cut on lines / sentences
for line in re.split(r"(?<=[.!?。!?])\s+|\n", para):
if not line:
continue
if cur and len(cur) + len(line) + 1 > target:
pieces.append(cur)
cur = ""
cur = (cur + "\n" + line) if cur else line
continue
if cur and len(cur) + len(para) + 2 > target:
pieces.append(cur)
cur = ""
cur = (cur + "\n\n" + para) if cur else para
if cur:
pieces.append(cur)
return pieces
def shorten(text, n):
text = " ".join(text.split())
return text if len(text) <= n else text[: n - 1].rstrip() + "…"
def chinese_numeral(s):
"""Convert 一二三…十/百 numerals to int; returns None if not a numeral."""
if s.isdigit():
return int(s)
digits = {"零": 0, "一": 1, "二": 2, "两": 2, "三": 3, "四": 4, "五": 5, "六": 6, "七": 7, "八": 8, "九": 9}
if not s or any(ch not in digits and ch not in "十百" for ch in s):
return None
total, num = 0, 0
for ch in s:
if ch == "十":
total += (num or 1) * 10
num = 0
elif ch == "百":
total += (num or 1) * 100
num = 0
else:
num = digits[ch]
return total + num
def display_width(s):
return sum(2 if unicodedata.east_asian_width(ch) in "WF" else 1 for ch in s)
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 |