新增移除关联题号功能

This commit is contained in:
wangweiye7840 2023-06-28 13:37:51 +08:00
parent 9600c10cb0
commit 3196dce1a8
3 changed files with 29 additions and 50 deletions

View File

@ -566,5 +566,21 @@ def ModifyProblembyTeX(id_string,prodict,toeditfilepath,editor): # vscode打开.
save_dict(prodict,"../题库0.3/problems.json") save_dict(prodict,"../题库0.3/problems.json")
return generate_exp(editedIDList) # 返回编辑过的字典 return generate_exp(editedIDList) # 返回编辑过的字典
def RemoveMutualLink(metadata,prodict): # 删除双向关联id(same,related,unrelated), 输入为一个字符串, 每行表示一对题号, 用空格或制表符隔开
lines = [re.sub(r"[\s]+",r"\t",line).strip() for line in metadata.split("\n")]
for line in lines:
if not line == []:
id1,id2 = line.split("\t")
id1 = id1.zfill(6)
id2 = id2.zfill(6)
for field in ["same","related","unrelated"]:
if id1 in prodict[id2][field]:
prodict[id2][field].remove(id1)
if id2 in prodict[id1][field]:
prodict[id1][field].remove(id2)
return 0 # 返回0
if __name__ == "__main__": if __name__ == "__main__":
print("数据库工具, import用.") print("数据库工具, import用.")

View File

@ -1,50 +1,3 @@
usages 52 8096
52 8097
000003 53 8096
20220825 2023届高三02班 0.909 0.758
20220825 2023届高三08班 0.929 0.818
20220825 2023届高三10班 0.963
20220826 2023届高三11班 0.543 0.213
ans
1
$2$
2
正好
objs
123
K0102001B
opp
121
23456
id
000008
000009
origin
12345
123456
unrelated
3
4
unrelated
4
3
tags
5
哈哈
六六
usages
000003
20220825 2023届高三08班 0.929 0.818 FORCE
20220824 2023届高三08班 0.939 0.818

View File

@ -0,0 +1,10 @@
metadatafilepath = "文本文件/metadata.txt"
from database_tools import *
pro_dict = load_dict("../题库0.3/problems.json")
metadata = ReadTextFile(metadatafilepath).strip()
RemoveMutualLink(metadata,pro_dict)
save_dict(pro_dict,"../题库0.3/problems.json")