From ea334b5fb16405841b3340991d8d34e757df0faa Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Fri, 16 Jun 2023 20:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=85=B3=E9=94=AE=E5=AD=97?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E9=A2=98=E5=8F=B7=E7=9A=84=E5=89=8D=E9=9D=A2?= =?UTF-8?q?=E8=8B=A5=E5=B9=B2=E8=A1=8C,=20=E4=BD=BF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E7=95=8C=E9=9D=A2=E6=9B=B4=E7=AC=A6=E5=90=88?= =?UTF-8?q?=E9=98=85=E8=AF=BB=E4=B9=A0=E6=83=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具/关键字筛选题号.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/工具/关键字筛选题号.py b/工具/关键字筛选题号.py index 2b807270..5cabf6fa 100644 --- a/工具/关键字筛选题号.py +++ b/工具/关键字筛选题号.py @@ -2,7 +2,26 @@ import os,re,json """---设置关键字, 同一field下不同选项为or关系, 同一字典中不同字段间为and关系, 不同字典间为or关系, _not表示列表中的关键字都不含, 同一字典中的数字用来供应同一字段不同的条件之间的and---""" keywords_dict_table = [ - {"content":["椭圆"],"content2":["抛物线"],"usages_not":["2023"]}, + { + "id":[""], #题号 + "content":["椭圆"], #题面内容 + "objs":[""], #目标代码 + "tags":["第七"], #标签, 如["第二单元"]等 + "genre":[""], #题目类型, 填空题, 选择题, 解答题 + "ans":[""], #答案 + "solution":[""], #解答与提示 + "duration":[""], #解题时间(目前未设置) + "usages":[""], #使用记录, 数据库中格式为 <日期>\t<届别><班别>\t正确率[\t正确率]... 例如"20230301\t2023届01班\t0.985\t0.211 + "origin":[""], #题目来源 + "edit":[""], #导入者及编辑者 + "same":[""], #相同题目题号 + "related":[""], #关联题目题号 + "remark":[""], #备注, 注记 + "space":[""], #解答题下的空间(em)表示一个m的宽度 + "unrelated":[""], #无关题目题号 + # "content2":["双曲线"], #在字段名中加入数字表示这个字段的另一个必要条件 + # "content_not":["焦"], #加_not表示不能出现该样式的词 + }, ] """---关键字设置完毕---""" # 示例: keywords_dict_table = [ @@ -26,7 +45,7 @@ filename = "文本文件/题号筛选.txt" def match_condition(problem,condition_dict): match = True - for field1 in [c for c in condition_dict if not "_not" in c]: + for field1 in [c for c in condition_dict if not "_not" in c and not condition_dict[c] == [""]]: cond_list = condition_dict[field1] field = re.sub("\d","",field1) if type(problem[field]) == list: @@ -39,7 +58,7 @@ def match_condition(problem,condition_dict): current_match = True if current_match == False: match = False - for field1 in [c for c in condition_dict if "_not" in c]: + for field1 in [c for c in condition_dict if "_not" in c and not condition_dict[c] == [""]]: cond_list = condition_dict[field1] field1 = field1.replace("_not","") field = re.sub("\d","",field1)