This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具/分年级专用工具/讲义题目分类按顺序梳理_制答题卡用.ipynb

119 lines
3.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 解答题 1\n",
"2 解答题 1\n",
"3 解答题 1\n",
"4 解答题 1\n",
"5 填空题 2\n",
"6 解答题 2\n",
"7 填空题 10\n",
"8 解答题 1\n",
"9 解答题 1\n",
"10 解答题 1\n",
"11 解答题 1\n",
"12 解答题 1\n",
"13 填空题 6\n",
"14 解答题 1\n",
"15 填空题 1\n",
"16 解答题 1\n",
"17 填空题 3\n",
"18 填空题 1\n",
"19 填空题 1\n",
"1 解答题 2\n",
"2 解答题 1\n",
"3 填空题 6\n",
"4 填空题 1\n",
"5 选择题 1\n",
"6 选择题 1\n",
"7 填空题 2\n",
"8 解答题 1\n",
"9 解答题 1\n",
"10 解答题 1\n",
"11 解答题 1\n",
"12 解答题 2\n",
"13 解答题 1\n"
]
}
],
"source": [
"import os,re\n",
"#修改文件名\n",
"filename = r\"C:\\Users\\Wang Weiye\\Documents\\wwy sync\\23届\\第一轮复习讲义\\20_描述空间位置关系的公理.tex\"\n",
"# filename = r\"C:\\Users\\Wang Weiye\\Documents\\wwy sync\\23届\\上学期周末卷\\国庆卷.tex\"\n",
"outputfile = \"临时文件/题目状态.txt\"\n",
"\n",
"outputstr = \"\"\n",
"with open(filename,\"r\",encoding = \"utf8\") as f:\n",
" data = f.read()\n",
"data = re.sub(r\"\\\\begin\\{center\\}[\\s\\S]*?\\\\end\\{center\\}\",\"\",data)\n",
"sections = re.findall(r\"\\\\begin\\{enumerate\\}([\\s\\S]*?\\\\end\\{enumerate\\})\",data)\n",
"for sec in sections:\n",
" sec = sec.replace(\"\\\\item\",\"\\\\enditem\\\\item\").replace(\"\\\\end{enumerate}\",\"\\\\enditem\")\n",
" problems = re.findall(r\"\\\\item([\\s\\S]*?)\\\\enditem\",sec)\n",
" count = 0\n",
" for p in problems:\n",
" count += 1\n",
" if \"\\\\bracket\" in p:\n",
" genre = \"选择题\"\n",
" parts = len(re.findall(r\"\\\\bracket\",p))\n",
" elif \"\\\\blank\" in p:\n",
" genre = \"填空题\"\n",
" parts = len(re.findall(r\"\\\\blank\",p))\n",
" else:\n",
" genre = \"解答题\"\n",
" parts = len(re.findall(r\"\\([\\d]{1,2}\\)\",p))\n",
" if parts == 0:\n",
" parts = 1\n",
" print(count,genre,parts)\n",
" outputstr += str(count) + \"-\" + genre + \"-\" + str(parts) + \"\\n\"\n",
" outputstr += \"\\n\"\n",
"with open(outputfile,\"w\",encoding = \"utf8\") as f:\n",
" f.write(outputstr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.7 ('base')",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "e4cce46d6be9934fbd27f9ca0432556941ea5bdf741d4f4d64c6cd7f8dfa8fba"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}