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

123 lines
3.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"040202 填空题\n",
"040203 填空题\n",
"040204 填空题\n",
"040205 填空题\n",
"040206 填空题\n",
"040207 填空题\n",
"040208 填空题\n",
"040209 填空题\n",
"040210 填空题\n",
"040211 填空题\n",
"040212 填空题\n",
"040213 填空题\n",
"040214 填空题\n",
"040215 填空题\n",
"040216 填空题\n",
"040217 填空题\n",
"040218 填空题\n",
"040219 填空题\n",
"040220 填空题\n",
"040221 解答题\n",
"040222 选择题\n",
"040223 选择题\n",
"040224 解答题\n",
"040225 解答题\n",
"040226 填空题\n",
"040227 填空题\n",
"040228 填空题\n",
"040229 填空题\n",
"040230 填空题\n",
"040231 填空题\n",
"040232 填空题\n",
"040233 填空题\n",
"040234 填空题\n",
"040235 填空题\n",
"040236 填空题\n",
"040237 填空题\n",
"040238 填空题\n",
"040239 填空题\n",
"040240 填空题\n",
"040241 填空题\n",
"040242 解答题\n",
"040243 解答题\n",
"040244 解答题\n",
"040245 解答题\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": "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
}