184 lines
4.9 KiB
Plaintext
184 lines
4.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"012550 填空题\n",
|
|
"012551 填空题\n",
|
|
"012552 填空题\n",
|
|
"012553 填空题\n",
|
|
"012554 填空题\n",
|
|
"012555 填空题\n",
|
|
"012556 填空题\n",
|
|
"012557 填空题\n",
|
|
"012558 填空题\n",
|
|
"012559 填空题\n",
|
|
"012560 填空题\n",
|
|
"012561 填空题\n",
|
|
"012562 选择题\n",
|
|
"012563 选择题\n",
|
|
"012564 解答题\n",
|
|
"012565 选择题\n",
|
|
"012566 解答题\n",
|
|
"012567 解答题\n",
|
|
"012568 解答题\n",
|
|
"012569 解答题\n",
|
|
"012570 解答题\n",
|
|
"012571 填空题\n",
|
|
"012572 填空题\n",
|
|
"012573 填空题\n",
|
|
"012574 填空题\n",
|
|
"012575 填空题\n",
|
|
"012576 填空题\n",
|
|
"012577 填空题\n",
|
|
"012578 填空题\n",
|
|
"012579 填空题\n",
|
|
"012580 填空题\n",
|
|
"012581 填空题\n",
|
|
"012582 填空题\n",
|
|
"012583 选择题\n",
|
|
"012584 选择题\n",
|
|
"012585 选择题\n",
|
|
"012586 解答题\n",
|
|
"012587 解答题\n",
|
|
"012588 解答题\n",
|
|
"012589 解答题\n",
|
|
"012590 解答题\n",
|
|
"012591 解答题\n",
|
|
"012592 填空题\n",
|
|
"012593 填空题\n",
|
|
"012594 填空题\n",
|
|
"012595 填空题\n",
|
|
"012596 填空题\n",
|
|
"012597 填空题\n",
|
|
"012598 填空题\n",
|
|
"012599 填空题\n",
|
|
"012600 填空题\n",
|
|
"012601 填空题\n",
|
|
"012602 填空题\n",
|
|
"012603 填空题\n",
|
|
"012604 选择题\n",
|
|
"012605 选择题\n",
|
|
"012606 选择题\n",
|
|
"012607 选择题\n",
|
|
"012608 解答题\n",
|
|
"012609 解答题\n",
|
|
"012610 解答题\n",
|
|
"012611 解答题\n",
|
|
"012612 解答题\n",
|
|
"012613 填空题\n",
|
|
"012614 填空题\n",
|
|
"012615 填空题\n",
|
|
"012616 填空题\n",
|
|
"012617 填空题\n",
|
|
"012618 填空题\n",
|
|
"012619 填空题\n",
|
|
"012620 填空题\n",
|
|
"012621 填空题\n",
|
|
"012622 填空题\n",
|
|
"012623 填空题\n",
|
|
"012624 填空题\n",
|
|
"012625 选择题\n",
|
|
"012626 填空题\n",
|
|
"012627 选择题\n",
|
|
"012628 选择题\n",
|
|
"012629 解答题\n",
|
|
"012630 解答题\n",
|
|
"012631 解答题\n",
|
|
"012632 解答题\n",
|
|
"012633 解答题\n",
|
|
"012634 填空题\n",
|
|
"012635 填空题\n",
|
|
"012636 填空题\n",
|
|
"012637 填空题\n",
|
|
"012638 填空题\n",
|
|
"012639 填空题\n",
|
|
"012640 填空题\n",
|
|
"012641 填空题\n",
|
|
"012642 填空题\n",
|
|
"012643 填空题\n",
|
|
"012644 填空题\n",
|
|
"012645 填空题\n",
|
|
"012646 选择题\n",
|
|
"012647 选择题\n",
|
|
"012648 选择题\n",
|
|
"012649 选择题\n",
|
|
"012650 解答题\n",
|
|
"012651 解答题\n",
|
|
"012652 解答题\n",
|
|
"012653 解答题\n",
|
|
"012654 解答题\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
|
|
}
|