100 lines
2.6 KiB
Plaintext
100 lines
2.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"012718 填空题\n",
|
|
"012719 填空题\n",
|
|
"012720 填空题\n",
|
|
"012721 填空题\n",
|
|
"012722 填空题\n",
|
|
"012723 填空题\n",
|
|
"012724 填空题\n",
|
|
"012725 填空题\n",
|
|
"012726 填空题\n",
|
|
"012727 填空题\n",
|
|
"012728 填空题\n",
|
|
"012729 填空题\n",
|
|
"012730 选择题\n",
|
|
"012731 选择题\n",
|
|
"012732 选择题\n",
|
|
"012733 选择题\n",
|
|
"012734 解答题\n",
|
|
"012735 解答题\n",
|
|
"012736 解答题\n",
|
|
"012737 解答题\n",
|
|
"012738 解答题\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 (main, Nov 24 2022, 14:39:17) [MSC v.1916 64 bit (AMD64)]"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "ff3c292c316ba85de6f1ad75f19c731e79d694e741b6f515ec18f14996fe48dc"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|