169 lines
4.4 KiB
Plaintext
169 lines
4.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"040246 填空题\n",
|
|
"040247 填空题\n",
|
|
"040248 填空题\n",
|
|
"040249 填空题\n",
|
|
"040250 填空题\n",
|
|
"040251 填空题\n",
|
|
"040252 填空题\n",
|
|
"040253 填空题\n",
|
|
"040254 解答题\n",
|
|
"040255 解答题\n",
|
|
"040256 填空题\n",
|
|
"040257 填空题\n",
|
|
"040258 填空题\n",
|
|
"040259 填空题\n",
|
|
"040260 填空题\n",
|
|
"040261 填空题\n",
|
|
"040262 填空题\n",
|
|
"040263 填空题\n",
|
|
"040264 解答题\n",
|
|
"040265 解答题\n",
|
|
"040266 填空题\n",
|
|
"040267 填空题\n",
|
|
"040268 填空题\n",
|
|
"040269 填空题\n",
|
|
"040270 填空题\n",
|
|
"040271 填空题\n",
|
|
"040272 填空题\n",
|
|
"040273 填空题\n",
|
|
"040274 填空题\n",
|
|
"040275 填空题\n",
|
|
"040276 填空题\n",
|
|
"040277 填空题\n",
|
|
"040278 填空题\n",
|
|
"040279 填空题\n",
|
|
"040280 填空题\n",
|
|
"040281 填空题\n",
|
|
"040282 解答题\n",
|
|
"040283 解答题\n",
|
|
"040284 解答题\n",
|
|
"040285 解答题\n",
|
|
"040286 解答题\n",
|
|
"040287 解答题\n",
|
|
"040288 解答题\n",
|
|
"040289 解答题\n",
|
|
"040290 解答题\n",
|
|
"040291 填空题\n",
|
|
"040292 填空题\n",
|
|
"040293 选择题\n",
|
|
"040294 解答题\n",
|
|
"040295 解答题\n",
|
|
"040296 解答题\n",
|
|
"040297 解答题\n",
|
|
"040298 解答题\n",
|
|
"040299 填空题\n",
|
|
"040300 填空题\n",
|
|
"040301 填空题\n",
|
|
"040302 填空题\n",
|
|
"040303 填空题\n",
|
|
"040304 填空题\n",
|
|
"040305 填空题\n",
|
|
"040306 填空题\n",
|
|
"040307 填空题\n",
|
|
"040308 填空题\n",
|
|
"040309 填空题\n",
|
|
"040310 填空题\n",
|
|
"040311 解答题\n",
|
|
"040312 解答题\n",
|
|
"040313 解答题\n",
|
|
"040314 解答题\n",
|
|
"040315 解答题\n",
|
|
"040316 解答题\n",
|
|
"040317 填空题\n",
|
|
"040318 填空题\n",
|
|
"040319 填空题\n",
|
|
"040320 填空题\n",
|
|
"040321 填空题\n",
|
|
"040322 填空题\n",
|
|
"040323 填空题\n",
|
|
"040324 填空题\n",
|
|
"040325 填空题\n",
|
|
"040326 填空题\n",
|
|
"040327 填空题\n",
|
|
"040328 填空题\n",
|
|
"040329 填空题\n",
|
|
"040330 选择题\n",
|
|
"040331 选择题\n",
|
|
"040332 解答题\n",
|
|
"040333 解答题\n",
|
|
"040334 解答题\n",
|
|
"040335 解答题\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
|
|
}
|