改编关键字筛选题号输出方式,从题号枚举改为题号范围枚举
This commit is contained in:
parent
06e0db726e
commit
aae4864e9c
|
|
@ -2,7 +2,7 @@ import os,re,json
|
|||
|
||||
"""---设置关键字, 同一field下不同选项为or关系, 同一字典中不同字段间为and关系, 不同字典间为or关系, _not表示列表中的关键字都不含, 同一字典中的数字用来供应同一字段不同的条件之间的and---"""
|
||||
keywords_dict_table = [
|
||||
{"content":[r"椭圆"]}
|
||||
{"tags":[r"第九"]}
|
||||
]
|
||||
"""---关键字设置完毕---"""
|
||||
# 示例: keywords_dict_table = [
|
||||
|
|
@ -56,6 +56,31 @@ def match_condition(problem,condition_dict):
|
|||
|
||||
return match
|
||||
|
||||
def generate_exp(id_list):
|
||||
if not len(id_list) == 0:
|
||||
exp_list = []
|
||||
start = id_list[0]
|
||||
current = start
|
||||
end = start
|
||||
for id in id_list[1:]:
|
||||
# print(id,current)
|
||||
if int(id)-1 == int(current):
|
||||
current = id
|
||||
end = id
|
||||
else:
|
||||
if not start == end:
|
||||
exp_list.append('"'+start+":"+end+'"')
|
||||
else:
|
||||
exp_list.append('"'+start+'"')
|
||||
start = id
|
||||
current = id
|
||||
end = id
|
||||
if not start == end:
|
||||
exp_list.append('"'+start+":"+end+'"')
|
||||
else:
|
||||
exp_list.append('"'+start+'"')
|
||||
return exp_list
|
||||
|
||||
#读取题库json文件并转化为字典
|
||||
with open(r"../题库0.3/Problems.json","r",encoding = "utf8") as f:
|
||||
database = f.read()
|
||||
|
|
@ -66,8 +91,10 @@ for condition in keywords_dict_table:
|
|||
for id in pro_dict:
|
||||
if match_condition(pro_dict[id],condition) and not id in match_list:
|
||||
match_list.append(id)
|
||||
|
||||
match_list_exp = generate_exp(match_list)
|
||||
|
||||
with open(filename,"w",encoding="utf8") as f:
|
||||
f.write(",".join(match_list))
|
||||
f.write((",".join(match_list_exp)).replace('"',''))
|
||||
|
||||
os.system("code "+filename)
|
||||
|
|
@ -1 +1 @@
|
|||
000270,000271,000284,000285,000288,000379,000485,000510,000560,000625,000705,000723,000755,000801,000813,000895,000908,002306,002307,002308,002309,002310,002311,002313,002314,002315,002316,002317,002318,002319,002321,002322,002323,002324,002325,002326,002327,002328,002329,002330,002331,002332,002333,002334,002335,002337,002338,002339,002342,002343,002344,002345,002346,002347,002356,002363,002367,002380,002389,002428,002443,002447,002454,002469,002478,002479,002480,002481,002482,002505,002510,002513,002516,002518,002683,002686,002688,003399,003400,003401,003402,003403,003404,003406,003407,003408,003409,003410,003411,003413,003414,003415,003416,003417,003418,003428,003434,003451,003608,003619,003650,003664,003688,003692,003704,003733,003748,003826,003858,003895,003909,003918,003967,004078,004099,004120,004129,004133,004152,004162,004182,004196,004204,004221,004242,004288,004303,004309,004361,004487,004524,004529,004561,004566,004633,004701,004717,004722,004743,006993,007047,007048,007054,007069,007282,007468,008873,008875,008876,008877,008878,008879,008880,008881,008882,008883,008884,008885,008886,008887,008889,008890,008891,008892,008893,008894,008895,008897,008899,008916,008945,008946,008947,008948,008949,008959,008962,008964,008965,009080,009087,009089,009101,009105,009109,009338,009819,009820,009821,009822,009823,009824,009825,009932,010003,010667,010668,010669,010670,010671,010672,010673,010680,010690,010701,010702,010703,010704,010958,010984,011068,011075,011240,011261,011272,011282,011298,011311,011337,011366,011387,011406,011429,011450,011471,011485,011513,011534,011543,011572,011576,011600,011645,011655,011672,011713,012095,012115,012136,012146,012147,012170,012213,012218,012238,012255,012285,012306,012319,012327,012375,012379,012410,012433,012434,012447,012474,012483,012522,012548,012569,012590,012611,012624,012653,012674,012695,012716,012737,012758,012779,013080,013081,013082,013084,013085,013089,013099,013110,013125,013127,013128,013130,013133,013134,013286,013296,013325,013344,013355,013376,013380,013405,013435,013541,013556,013566,013606,013648,013690,013907,013979,013989,013990,013991,013994,013998,014001,014004,014006,014007,014017,014019,014022,014063,014456,014457,014458,014462,014466,014468,014470,014473,014474,014476,014477,014483,014484,014487,014489,014490,014493,014496,014500,014501,014502,014504,014506,014530,014702,014728,014762,014803,014824,014867,014873,014874,014875,014880,014883,014930,014938,014939,014956,015015,015057,015090,015125,015162,015204,015225,015247,021183,021184,021186,021187,021189,021190,021191,021192,021193,021194,021195,021196,021197,021198,021199,021200,021201,021202,021203,021204,021205,021206,021207,021208,021209,021210,021211,021212,021213,021214,021217,021218,021221,021224,021240,021247,021260,021269,021277,021353,021359,021362,021363,030471,030483,030510,031069,031070,031071,031072,031073,031074,031075,031077,031078,031079,031080,031081,031082,031083,031084,031085,031086,031087,031088,031090,031091,031092,031093,031094,031139,031140,031141,031144,031145,031154,031155,031248,031265,031276,031278,031285,031287,031330,031342,031376,031380,031386,040013,040014,040045,040050,040054,040144,040149,040152,040156,040159,040160,040314,040441,040453,040483,040515,040525
|
||||
000232:000242,000605,000671,000708,000720,000764,002666:002682,003576,003579,003587:003588,003617,003767,003803,003842,003845,003920,003960,004047:004058,004068,004107,004156,004262,004318,004480,004494,004624,004643,004709,004738,004751,009367:009390,009424,009755:009779,009970:009983,010561:010590,010904:010922,011077,011083,011088,011249,011276,011359:011360,011381,011458,011508,011517,011704,011719,012041,012047,012088,012100,012108,012385,012493,012527,012533,012576,012601,012618,012642,012668,012682,012704,012745,012752,012763,013218:013220,013225,013235,013237,013239,013289,013298,013338,013349,013373,013385,013397,013403,013410,013417,013425,013448,013462,013488,013501,013540,013546,013570,013585,013601,013614,013631,013638,013664,013676,013684,014084:014085,014087:014089,014098,014791,014797,014811:014812,014823,014844,015009,015026,015035,015051,015077,015094,015098,015106,015119,015130,015141,015145,015151,015177,015197,015203,015219,015241,021141:021182,030195:030272,030274:030275,030449,030521:030533,030553:030596,031165:031203,031266,031328
|
||||
|
|
@ -7,13 +7,13 @@ import os,re,time,json,sys
|
|||
"""---设置题目列表---"""
|
||||
#留空为编译全题库, a为读取文本文件中的题号筛选.txt文件生成题库
|
||||
problems = r"""
|
||||
|
||||
a
|
||||
"""
|
||||
"""---设置题目列表结束---"""
|
||||
|
||||
"""---设置文件名---"""
|
||||
#目录和文件的分隔务必用/
|
||||
filename = "临时文件/题库"
|
||||
filename = "临时文件/临时"
|
||||
"""---设置文件名结束---"""
|
||||
|
||||
"""---设置是否需要解答题的空格---"""
|
||||
|
|
|
|||
Reference in New Issue