Files

90 lines
6.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""演示题库(初中版):替代真实 OCR + 切题的占位。
每个知识点都带一道**变式**——这是初中版第二档验收要用的东西:
同题再做对是记忆,变式做对才是迁移。
"""
from __future__ import annotations
BANK: dict[tuple[str, int], list[dict]] = {
("math", 9): [
{"stem": "解方程:3x + 7 = 22", "answer": "5", "judge_type": "calc", "knowledge": "一元一次方程"},
{"stem": "计算:(-2)³ + 8 ÷ 2", "answer": "-4", "judge_type": "calc", "knowledge": "有理数运算"},
{"stem": "因式分解:x² - 9", "answer": "(x+3)(x-3)", "judge_type": "text", "knowledge": "因式分解"},
{"stem": "一次函数 y = 2x - 3,当 x = 4 时 y = ?", "answer": "5", "judge_type": "calc", "knowledge": "一次函数"},
{"stem": "化简:2(a + 3) - a", "answer": "a+6", "judge_type": "text", "knowledge": "整式化简"},
{"stem": "解分式方程:1/x = 2", "answer": "0.5", "judge_type": "calc", "knowledge": "分式方程"},
],
("physics", 9): [
{"stem": "物体 20 s 内通过 120 m,速度是多少?", "answer": "6m/s", "judge_type": "numeric", "knowledge": "速度"},
{"stem": "质量 54 g、体积 20 cm³,密度是多少?", "answer": "2.7g/cm3", "judge_type": "numeric", "knowledge": "密度"},
{"stem": "质量 2 kg 的物体受到的重力(g 取 10 N/kg)", "answer": "20N", "judge_type": "numeric", "knowledge": "重力"},
{"stem": "压力 500 N 作用在 0.5 m² 上,压强是多少?", "answer": "1000Pa", "judge_type": "numeric", "knowledge": "压强"},
{"stem": "用 20 N 的力沿力的方向移动 3 m,做功多少?", "answer": "60J", "judge_type": "numeric", "knowledge": "功"},
{"stem": "10 s 内做功 600 J,功率是多少?", "answer": "60W", "judge_type": "numeric", "knowledge": "功率"},
],
("chemistry", 9): [
{"stem": "写出水的化学式", "answer": "H2O", "judge_type": "text", "knowledge": "常见物质化学式"},
{"stem": "写出二氧化碳的化学式", "answer": "CO2", "judge_type": "text", "knowledge": "常见物质化学式"},
{"stem": "写出硫酸的化学式", "answer": "H2SO4", "judge_type": "text", "knowledge": "常见物质化学式"},
{"stem": "写出氢氧化钠的化学式", "answer": "NaOH", "judge_type": "text", "knowledge": "常见物质化学式"},
{"stem": "写出碳酸钙的化学式", "answer": "CaCO3", "judge_type": "text", "knowledge": "常见物质化学式"},
{"stem": "写出甲烷的化学式", "answer": "CH4", "judge_type": "text", "knowledge": "常见物质化学式"},
],
("english", 9): [
{"stem": "写出 go 的过去式", "answer": "went", "judge_type": "text", "knowledge": "不规则动词"},
{"stem": "He ___ to school yesterday. A. go B. went C. goes D. going", "answer": "B", "judge_type": "choice", "knowledge": "一般过去时"},
{"stem": "I have ___ (finish) my homework.", "answer": "finished", "judge_type": "text", "knowledge": "现在完成时"},
{"stem": "写出 good 的比较级", "answer": "better", "judge_type": "text", "knowledge": "形容词比较级"},
{"stem": "If it ___ tomorrow, we will stay home. A. rains B. will rain C. rained D. raining", "answer": "A", "judge_type": "choice", "knowledge": "条件状语从句"},
{"stem": "拼写:环境(英文)", "answer": "environment", "judge_type": "text", "knowledge": "词汇拼写"},
],
}
VARIANTS: dict[str, dict] = {
"一元一次方程": {"stem": "解方程:5x - 4 = 21", "answer": "5", "judge_type": "calc"},
"有理数运算": {"stem": "计算:(-3)² - 12 ÷ 4", "answer": "6", "judge_type": "calc"},
"因式分解": {"stem": "因式分解:x² - 16", "answer": "(x+4)(x-4)", "judge_type": "text"},
"一次函数": {"stem": "一次函数 y = 3x + 1,当 x = 2 时 y = ?", "answer": "7", "judge_type": "calc"},
"整式化简": {"stem": "化简:3(b + 2) - 2b", "answer": "b+6", "judge_type": "text"},
"分式方程": {"stem": "解分式方程:1/x = 4", "answer": "0.25", "judge_type": "calc"},
"速度": {"stem": "汽车 30 s 内行驶 900 m,速度是多少?", "answer": "30m/s", "judge_type": "numeric"},
"密度": {"stem": "质量 89 g、体积 10 cm³,密度是多少?", "answer": "8.9g/cm3", "judge_type": "numeric"},
"重力": {"stem": "质量 5 kg 的物体受到的重力(g 取 10 N/kg)", "answer": "50N", "judge_type": "numeric"},
"压强": {"stem": "压力 300 N 作用在 0.2 m² 上,压强是多少?", "answer": "1500Pa", "judge_type": "numeric"},
"功": {"stem": "用 15 N 的力沿力的方向移动 4 m,做功多少?", "answer": "60J", "judge_type": "numeric"},
"功率": {"stem": "20 s 内做功 800 J,功率是多少?", "answer": "40W", "judge_type": "numeric"},
"常见物质化学式": {"stem": "写出氯化钠的化学式", "answer": "NaCl", "judge_type": "text"},
"不规则动词": {"stem": "写出 see 的过去式", "answer": "saw", "judge_type": "text"},
"一般过去时": {"stem": "She ___ (buy) a book last week.", "answer": "bought", "judge_type": "text"},
"现在完成时": {"stem": "He has ___ (write) three letters.", "answer": "written", "judge_type": "text"},
"形容词比较级": {"stem": "写出 bad 的比较级", "answer": "worse", "judge_type": "text"},
"条件状语从句": {"stem": "If you ___ (heat) ice, it melts.", "answer": "heat", "judge_type": "text"},
"词汇拼写": {"stem": "拼写:经验(英文)", "answer": "experience", "judge_type": "text"},
}
SUBJECT_ZH = {"math": "数学", "physics": "物理", "chemistry": "化学", "english": "英语", "chinese": "语文"}
def papers_for(grade: int, subject: str) -> list[dict]:
items = BANK.get((subject, grade)) or BANK.get((subject, 9)) or []
return [dict(x) for x in items]
def variant_for(knowledge: str | None, subject: str) -> dict | None:
v = VARIANTS.get(knowledge or "")
if v:
return dict(v, knowledge=knowledge)
items = BANK.get((subject, 9)) or []
return dict(items[0], knowledge=items[0]["knowledge"]) if items else None
def weak_points(knowledge_list: list[str], subjects: list[str]) -> list[str]:
"""把「哪几个知识点没消灭」翻成一句家长听得懂的话。"""
out = []
for k in knowledge_list[:3]:
out.append(f"{k}:连对两次没做到,先按 3 天间隔再来一遍")
if not out:
out.append("本周没有反复错的题")
return out