131 lines
3.4 KiB
Plaintext
131 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"020352 填空题\n",
|
|
"020353 填空题\n",
|
|
"020354 填空题\n",
|
|
"020355 填空题\n",
|
|
"020356 填空题\n",
|
|
"020357 填空题\n",
|
|
"020358 选择题\n",
|
|
"020359 选择题\n",
|
|
"020360 填空题\n",
|
|
"020361 填空题\n",
|
|
"020362 解答题\n",
|
|
"020363 填空题\n",
|
|
"020364 填空题\n",
|
|
"020365 选择题\n",
|
|
"020366 选择题\n",
|
|
"020367 解答题\n",
|
|
"020368 填空题\n",
|
|
"020369 填空题\n",
|
|
"020370 解答题\n",
|
|
"020371 解答题\n",
|
|
"020372 解答题\n",
|
|
"020373 解答题\n",
|
|
"020374 解答题\n",
|
|
"020375 解答题\n",
|
|
"020376 填空题\n",
|
|
"020377 选择题\n",
|
|
"020378 选择题\n",
|
|
"020379 选择题\n",
|
|
"020380 解答题\n",
|
|
"020381 解答题\n",
|
|
"020382 解答题\n",
|
|
"020383 解答题\n",
|
|
"020384 解答题\n",
|
|
"020385 解答题\n",
|
|
"020386 选择题\n",
|
|
"020387 选择题\n",
|
|
"020388 填空题\n",
|
|
"020389 填空题\n",
|
|
"020390 填空题\n",
|
|
"020391 填空题\n",
|
|
"020392 解答题\n",
|
|
"020393 解答题\n",
|
|
"020394 解答题\n",
|
|
"020395 填空题\n",
|
|
"020396 解答题\n",
|
|
"020397 解答题\n",
|
|
"020398 填空题\n",
|
|
"020399 填空题\n",
|
|
"020400 解答题\n",
|
|
"020401 解答题\n",
|
|
"020402 解答题\n",
|
|
"020403 解答题\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": "mathdept",
|
|
"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": "ff3c292c316ba85de6f1ad75f19c731e79d694e741b6f515ec18f14996fe48dc"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|