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

161 lines
4.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"with open(\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
" database = f.read()\n",
"import json\n",
"pro_dict = json.loads(database)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# 输入目标列表\n",
"t = \"\"\"K0901001B\n",
"K0901002B\n",
"K0901003B\n",
"K0901004B\n",
"K0902001B\n",
"K0902002B\n",
"K0902003B\n",
"K0902004B\n",
"K0903001B\n",
"K0903002B\n",
"K0903003B\n",
"K0903004B\n",
"K0903005B\n",
"K0903006B\n",
"K0904001B\n",
"K0904002B\n",
"K0904003B\n",
"K0904004B\n",
"K0904005B\n",
"K0904006B\n",
"K0904007B\n",
"K0905001B\n",
"K0905002B\n",
"K0905003B\n",
"K0905004B\n",
"K0905005B\n",
"K0906001B\n",
"K0906002B\n",
"K0906003B\n",
"K0906004B\n",
"K0906005B\n",
"K0906006B\n",
"K0906007B\n",
"K0906008B\n",
"K0906009B\n",
"K0906010B\n",
"K0907001B\n",
"K0907002B\n",
"K0907003B\n",
"K0907004B\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\"K0901001B\":\"030197,030198,030262\",\n",
"\"K0901002B\":\"000232,030195\",\n",
"\"K0901003B\":\"000241\",\n",
"\"K0902002B\":\"030226\",\n",
"\"K0902003B\":\"030199,030217,030223,030224,030229\",\n",
"\"K0902004B\":\"030203,030218,030228,030266\",\n",
"\"K0903001B\":\"030219,030221,030230,030231\",\n",
"\"K0903002B\":\"030220\",\n",
"\"K0903005B\":\"030170,030200,030201,030202,030204,030233,030265\",\n",
"\"K0903006B\":\"000234,000240,030196\",\n",
"\"K0904003B\":\"000235,030242\",\n",
"\"K0904004B\":\"000239\",\n",
"\"K0904005B\":\"030207,030210,030213,030238,030239\",\n",
"\"K0905001B\":\"000236\",\n",
"\"K0905002B\":\"030208\",\n",
"\"K0905003B\":\"030212\",\n",
"\"K0905004B\":\"000233\",\n",
"\"K0906004B\":\"030211,030214,030222,030234,030244,030259,030263,030264\",\n",
"\"K0906005B\":\"030246,030247,030252,030253,030254,030255,030268\",\n",
"\"K0906007B\":\"000238\",\n",
"\"K0906008B\":\"030241\",\n",
"\"K0906009B\":\"000237,030209,030248,030249,030258,030260,030269,030274\",\n",
"\"K0906010B\":\"030225,030227,030235,030250,030261\",\n",
"\"K0907001B\":\"030215\",\n",
"\"K0907003B\":\"000242,030243,030251,030270,030271,030272\",\n",
"\"K0907004B\":\"030206,030236,030237,030240,030245,030256,030257,030267\",\n"
]
}
],
"source": [
"dict1 = {}\n",
"for o in [l for l in t.split(\"\\n\") if len(l.strip())>0]:\n",
" dict1[o] = []\n",
"for id in pro_dict:\n",
" for o in dict1:\n",
" objs = pro_dict[id][\"objs\"]\n",
" flag = True\n",
" if not o in objs:\n",
" flag = False\n",
" for obj in objs:\n",
" if obj > o:\n",
" flag = False\n",
" break\n",
" if flag:\n",
" dict1[o].append(id)\n",
"for o in dict1:\n",
" if not dict1[o] == []:\n",
" print('\"'+o+'\":\"'+\",\".join(dict1[o])+'\",')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"\n"
]
}
],
"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
}