From f31c1f9aa2b518c00a3dfee130997cae8fd0def3 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Mon, 18 Mar 2024 21:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=9C=AC=E8=BD=AC=E6=8D=A2=E5=A4=84?= =?UTF-8?q?=E7=90=86=20=E4=B8=AD=20=E5=A2=9E=E5=8A=A0=20=E5=B0=86=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E7=AD=94=E6=A1=88=E6=A0=87=E7=BA=A2=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/Ui_文本转换处理.py | 10 ++++++++-- 工具v2/database_tools.py | 18 +++++++++++++++++- 工具v2/文本转换处理.py | 3 +++ 工具v2/文本转换处理.ui | 13 ++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/工具v2/Ui_文本转换处理.py b/工具v2/Ui_文本转换处理.py index 4707f004..b13324f5 100644 --- a/工具v2/Ui_文本转换处理.py +++ b/工具v2/Ui_文本转换处理.py @@ -39,13 +39,13 @@ class Ui_Form(object): self.plainTextEdit_dest.setReadOnly(True) self.pushButton_convert = QPushButton(Form) self.pushButton_convert.setObjectName(u"pushButton_convert") - self.pushButton_convert.setGeometry(QRect(310, 210, 111, 71)) + self.pushButton_convert.setGeometry(QRect(310, 230, 111, 71)) font = QFont() font.setBold(True) self.pushButton_convert.setFont(font) self.layoutWidget = QWidget(Form) self.layoutWidget.setObjectName(u"layoutWidget") - self.layoutWidget.setGeometry(QRect(320, 80, 91, 100)) + self.layoutWidget.setGeometry(QRect(320, 80, 97, 126)) self.verticalLayout = QVBoxLayout(self.layoutWidget) self.verticalLayout.setObjectName(u"verticalLayout") self.verticalLayout.setContentsMargins(0, 0, 0, 0) @@ -69,6 +69,11 @@ class Ui_Form(object): self.verticalLayout.addWidget(self.radioButton_puctuations) + self.radioButton_answers = QRadioButton(self.layoutWidget) + self.radioButton_answers.setObjectName(u"radioButton_answers") + + self.verticalLayout.addWidget(self.radioButton_answers) + self.retranslateUi(Form) @@ -86,5 +91,6 @@ class Ui_Form(object): self.radioButton_textcircled.setText(QCoreApplication.translate("Form", u"\u5706\u5708\u6570\u5b57", None)) self.radioButton_multiple.setText(QCoreApplication.translate("Form", u"\u591a\u9009\u8f6c\u586b\u7a7a", None)) self.radioButton_puctuations.setText(QCoreApplication.translate("Form", u"\u6807\u70b9\u8f6c\u534a\u89d2", None)) + self.radioButton_answers.setText(QCoreApplication.translate("Form", u"\u5df2\u6709\u7b54\u6848\u6807\u7ea2", None)) # retranslateUi diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 1144e6cc..65240ce9 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -2145,7 +2145,23 @@ def startfile(filepath): #跨平台打开文件或文件夹 return ret - +def PaintRedAnswers(string,prodict): #将prodict中已有的答案标红色 + output = string + IDandContentList = generateListOfIDandContent(output) + for id,content in IDandContentList: + raw_string = id+")"+content + # u = output.index(raw_string) + if "textcolor{blue}" in raw_string: + new_ans = generateAnswerTex(content,anspreamble="\\textcolor{blue}{") + raw_ans = prodict[id]["ans"] + if new_ans == raw_ans: + sub_string = raw_string.replace("textcolor{blue}","textcolor{red}") + output = output.replace(raw_string,sub_string) + elif raw_ans == "": + print(f"{id} 已有答案, 请运行提取答案控件以获取新录入的答案") + elif new_ans != "暂无答案": + print(f"{id} 新答案 {new_ans} 和原答案 {raw_ans} 有所不同, 请仔细检查") + return output if __name__ == "__main__": diff --git a/工具v2/文本转换处理.py b/工具v2/文本转换处理.py index 6dfe2f2f..85a9272c 100644 --- a/工具v2/文本转换处理.py +++ b/工具v2/文本转换处理.py @@ -25,6 +25,9 @@ class MyWindow(QWidget,Ui_Form): dest_string = "转换失败" elif self.radioButton_puctuations.isChecked(): dest_string = RefinePunctuations(raw_string) + elif self.radioButton_answers.isChecked(): + self.pro_dict = load_dict("../题库0.3/Problems.json") + dest_string = PaintRedAnswers(raw_string,self.pro_dict) self.plainTextEdit_dest.setPlainText(dest_string) diff --git a/工具v2/文本转换处理.ui b/工具v2/文本转换处理.ui index 17698267..373eec33 100644 --- a/工具v2/文本转换处理.ui +++ b/工具v2/文本转换处理.ui @@ -75,7 +75,7 @@ 310 - 210 + 230 111 71 @@ -94,8 +94,8 @@ 320 80 - 91 - 100 + 97 + 126 @@ -127,6 +127,13 @@ + + + + 已有答案标红 + + +