Jobo16/ielts-buddy / skills/ielts-study-plan
ielts-study-plan
Verified根据考试目标、可用时间与真实学习证据制定或调整雅思学习安排,进行每日接续、周复盘,或将用户要求的下一步保存为 IELTS Buddy 待办。
scripts/learning-resource-recommender/validate_resource_recommendations_docx.py
View on GitHub#!/usr/bin/env python3
"""Validate an IELTS resource recommendation DOCX."""
from __future__ import annotations
import argparse
import json
import re
from pathlib import Path
from xml.etree import ElementTree as ET
from zipfile import ZipFile
W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
W = f"{{{W_NS}}}"
FONT = "Times New Roman"
def qn(tag: str) -> str:
return f"{W}{tag}"
def text_of(el: ET.Element) -> str:
return "".join(t.text or "" for t in el.iter(qn("t")))
def norm(text: str) -> str:
return " ".join(str(text).split())
def contains(haystack: str, needle: str) -> bool:
return norm(needle).lower() in norm(haystack).lower()
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("docx", type=Path)
parser.add_argument("--plan-json", type=Path, default=None)
args = parser.parse_args()
with ZipFile(args.docx) as zf:
missing = sorted({"word/document.xml", "word/styles.xml", "[Content_Types].xml"} - set(zf.namelist()))
if missing:
raise SystemExit(f"Missing required DOCX parts: {missing}")
doc_xml = zf.read("word/document.xml").decode("utf-8")
doc = ET.fromstring(doc_xml)
text = text_of(doc)
for marker in ["雅思学习资源推荐", "推荐资源", "使用方法"]:
if marker not in text:
raise SystemExit(f"Missing required text: {marker}")
if FONT not in doc_xml:
raise SystemExit(f"{FONT} not found in document XML")
tables = len(list(doc.iter(qn("tbl"))))
if tables < 1:
raise SystemExit("Expected at least one recommendation table")
if args.plan_json:
plan = json.loads(args.plan_json.read_text(encoding="utf-8"))
recommendations = [item for item in plan.get("recommendations", []) if isinstance(item, dict)]
if not recommendations:
raise SystemExit("Plan must contain recommendations")
if len(recommendations) > 7:
raise SystemExit("Too many recommendations; keep the list focused")
for item in recommendations:
for key in ("title", "url", "how_to_use"):
value = norm(item.get(key, ""))
if value and not contains(text, value[:100]):
raise SystemExit(f"{key} missing from DOCX: {value[:100]}")
page_breaks = sum(1 for br in doc.iter(qn("br")) if br.get(qn("type")) == "page")
words = len(re.findall(r"[A-Za-z]+(?:[-'][A-Za-z]+)?|\d+", text))
print(f"OK: tables={tables}, page_breaks={page_breaks}, words={words}")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |