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

146 lines
3.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"012760 填空题\n",
"012761 填空题\n",
"012762 填空题\n",
"012763 填空题\n",
"012764 填空题\n",
"012765 填空题\n",
"012766 填空题\n",
"012767 填空题\n",
"012768 填空题\n",
"012769 填空题\n",
"012770 填空题\n",
"012771 填空题\n",
"012772 选择题\n",
"012773 选择题\n",
"012774 选择题\n",
"012775 选择题\n",
"012776 解答题\n",
"012777 解答题\n",
"012778 解答题\n",
"012779 解答题\n",
"012780 解答题\n",
"031158 填空题\n",
"031159 填空题\n",
"031160 选择题\n",
"031161 解答题\n",
"031162 选择题\n",
"031163 选择题\n",
"031164 选择题\n",
"031165 解答题\n",
"031166 解答题\n",
"031167 解答题\n",
"031168 解答题\n",
"031169 解答题\n",
"031170 解答题\n",
"031171 解答题\n",
"031172 解答题\n",
"031173 解答题\n",
"031174 填空题\n",
"031175 解答题\n",
"031176 解答题\n",
"031177 解答题\n",
"031178 解答题\n",
"031179 解答题\n",
"031180 解答题\n",
"031181 解答题\n",
"031182 解答题\n",
"031183 解答题\n",
"031184 解答题\n",
"031185 解答题\n",
"031186 解答题\n",
"031187 解答题\n",
"031188 解答题\n",
"031189 解答题\n",
"031190 解答题\n",
"031191 填空题\n",
"031192 填空题\n",
"031193 填空题\n",
"031194 填空题\n",
"031195 填空题\n",
"031196 填空题\n",
"031197 解答题\n",
"031198 解答题\n",
"031199 解答题\n",
"031200 解答题\n",
"031201 选择题\n",
"031202 选择题\n",
"031203 选择题\n"
]
}
],
"source": [
"import os,re,json\n",
"\n",
"# 读取数据库并转成题目字典\n",
"with open(r\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
" database = f.read()\n",
"pro_dict = json.loads(database)\n",
"\n",
"#根据特征字符识别题目类型\n",
"for p in pro_dict:\n",
" if pro_dict[p][\"genre\"] == \"\":\n",
" if \"bracket\" in pro_dict[p][\"content\"]:\n",
" pro_dict[p][\"genre\"] = \"选择题\"\n",
" print(p,\"选择题\")\n",
" elif \"blank\" in pro_dict[p][\"content\"]:\n",
" pro_dict[p][\"genre\"] = \"填空题\"\n",
" print(p,\"填空题\")\n",
" else:\n",
" pro_dict[p][\"genre\"] = \"解答题\"\n",
" pro_dict[p][\"space\"] = \"12ex\"\n",
" print(p,\"解答题\")\n",
"\n",
"#将修改结果写入json数据库\n",
"database = json.dumps(pro_dict,indent = 4, ensure_ascii= False)\n",
"with open(r\"../题库0.3/Problems.json\",\"w\",encoding = \"utf8\") as f:\n",
" f.write(database)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.15 ('pythontest')",
"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.15"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "91219a98e0e9be72efb992f647fe78b593124968b75db0b865552d6787c8db93"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}