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

122 lines
3.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"012033 填空题\n",
"012034 填空题\n",
"012035 填空题\n",
"012036 填空题\n",
"012037 填空题\n",
"012038 填空题\n",
"012039 填空题\n",
"012040 填空题\n",
"012041 填空题\n",
"012042 填空题\n",
"012043 填空题\n",
"012044 填空题\n",
"012045 选择题\n",
"012046 选择题\n",
"012047 选择题\n",
"012048 选择题\n",
"012049 解答题\n",
"012050 解答题\n",
"012051 解答题\n",
"012052 解答题\n",
"012053 解答题\n",
"012054 填空题\n",
"012055 填空题\n",
"012056 填空题\n",
"012057 填空题\n",
"012058 填空题\n",
"012059 填空题\n",
"012060 填空题\n",
"012061 填空题\n",
"012062 填空题\n",
"012063 填空题\n",
"012064 填空题\n",
"012065 填空题\n",
"012066 选择题\n",
"012067 选择题\n",
"012068 选择题\n",
"012069 选择题\n",
"012070 解答题\n",
"012071 解答题\n",
"012072 解答题\n",
"012073 解答题\n",
"012074 解答题\n",
"030481 填空题\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.8.8 ('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.8.8"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "d311ffef239beb3b8f3764271728f3972d7b090c974f8e972fcdeedf230299ac"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}