使用梅校的算法
This commit is contained in:
@@ -22,6 +22,14 @@ EXAM_HINT = re.compile(
|
||||
re.I,
|
||||
)
|
||||
SKIP_SHEETS = ("说明", "readme", "目录")
|
||||
|
||||
|
||||
def _is_skip_sheet(name: str) -> bool:
|
||||
n = name.lower()
|
||||
if any(x in n for x in SKIP_SHEETS):
|
||||
return True
|
||||
return "概率分析" in n or "指标数" in n
|
||||
|
||||
ART_RE = re.compile(r"艺术|体育|艺体")
|
||||
LEAVE_RE = re.compile(r"请假|出国|休学|国际|不在校|港澳|港籍.*假")
|
||||
|
||||
@@ -76,6 +84,8 @@ def parse_workbook(path: Path | BytesIO) -> dict:
|
||||
|
||||
for ws in wb.worksheets:
|
||||
kind = _sheet_kind(ws.title)
|
||||
if _is_skip_sheet(ws.title):
|
||||
continue
|
||||
rows = ws.iter_rows(values_only=True)
|
||||
try:
|
||||
header_row = next(rows)
|
||||
@@ -201,7 +211,7 @@ def summarize_parse(parsed: dict) -> dict:
|
||||
tracks = {}
|
||||
classes = {}
|
||||
status = {}
|
||||
art = leave = 0
|
||||
art = leave = moves = 0
|
||||
exam_present = {e: 0 for e in exams}
|
||||
for s in students:
|
||||
tracks[s["track"] or "未分方向"] = tracks.get(s["track"] or "未分方向", 0) + 1
|
||||
@@ -211,6 +221,8 @@ def summarize_parse(parsed: dict) -> dict:
|
||||
art += 1
|
||||
if s["leave"]:
|
||||
leave += 1
|
||||
if (s.get("move") or "").strip() or s.get("sheet_kind") in ("art", "leave"):
|
||||
moves += 1
|
||||
for e in exams:
|
||||
if s["scores"].get(e) is not None:
|
||||
exam_present[e] += 1
|
||||
@@ -236,6 +248,7 @@ def summarize_parse(parsed: dict) -> dict:
|
||||
"status": status,
|
||||
"art": art,
|
||||
"leave": leave,
|
||||
"moves": moves,
|
||||
"exam_present": exam_present,
|
||||
"score_scale": score_scale,
|
||||
"sheets": parsed["sheets"],
|
||||
|
||||
Reference in New Issue
Block a user