文本转换处理 中 增加 将已有的答案标红的功能
This commit is contained in:
parent
c985116866
commit
f31c1f9aa2
|
|
@ -39,13 +39,13 @@ class Ui_Form(object):
|
||||||
self.plainTextEdit_dest.setReadOnly(True)
|
self.plainTextEdit_dest.setReadOnly(True)
|
||||||
self.pushButton_convert = QPushButton(Form)
|
self.pushButton_convert = QPushButton(Form)
|
||||||
self.pushButton_convert.setObjectName(u"pushButton_convert")
|
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 = QFont()
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
self.pushButton_convert.setFont(font)
|
self.pushButton_convert.setFont(font)
|
||||||
self.layoutWidget = QWidget(Form)
|
self.layoutWidget = QWidget(Form)
|
||||||
self.layoutWidget.setObjectName(u"layoutWidget")
|
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 = QVBoxLayout(self.layoutWidget)
|
||||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
@ -69,6 +69,11 @@ class Ui_Form(object):
|
||||||
|
|
||||||
self.verticalLayout.addWidget(self.radioButton_puctuations)
|
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)
|
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_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_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_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
|
# retranslateUi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2145,7 +2145,23 @@ def startfile(filepath): #跨平台打开文件或文件夹
|
||||||
return ret
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ class MyWindow(QWidget,Ui_Form):
|
||||||
dest_string = "转换失败"
|
dest_string = "转换失败"
|
||||||
elif self.radioButton_puctuations.isChecked():
|
elif self.radioButton_puctuations.isChecked():
|
||||||
dest_string = RefinePunctuations(raw_string)
|
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)
|
self.plainTextEdit_dest.setPlainText(dest_string)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>310</x>
|
<x>310</x>
|
||||||
<y>210</y>
|
<y>230</y>
|
||||||
<width>111</width>
|
<width>111</width>
|
||||||
<height>71</height>
|
<height>71</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
|
@ -94,8 +94,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>320</x>
|
<x>320</x>
|
||||||
<y>80</y>
|
<y>80</y>
|
||||||
<width>91</width>
|
<width>97</width>
|
||||||
<height>100</height>
|
<height>126</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
|
@ -127,6 +127,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="radioButton_answers">
|
||||||
|
<property name="text">
|
||||||
|
<string>已有答案标红</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
||||||
Reference in New Issue