diff --git a/工具v3/Ui_文本转换处理.py b/工具v3/Ui_文本转换处理.py new file mode 100644 index 00000000..b13324f5 --- /dev/null +++ b/工具v3/Ui_文本转换处理.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file '文本转换处理.ui' +## +## Created by: Qt User Interface Compiler version 6.6.2 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QLabel, QPlainTextEdit, QPushButton, + QRadioButton, QSizePolicy, QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(720, 401) + self.plainTextEdit_origin = QPlainTextEdit(Form) + self.plainTextEdit_origin.setObjectName(u"plainTextEdit_origin") + self.plainTextEdit_origin.setGeometry(QRect(10, 30, 291, 361)) + self.label = QLabel(Form) + self.label.setObjectName(u"label") + self.label.setGeometry(QRect(10, 10, 54, 16)) + self.label_2 = QLabel(Form) + self.label_2.setObjectName(u"label_2") + self.label_2.setGeometry(QRect(390, 10, 54, 16)) + self.plainTextEdit_dest = QPlainTextEdit(Form) + self.plainTextEdit_dest.setObjectName(u"plainTextEdit_dest") + self.plainTextEdit_dest.setGeometry(QRect(430, 30, 281, 361)) + self.plainTextEdit_dest.setAutoFillBackground(False) + self.plainTextEdit_dest.setReadOnly(True) + self.pushButton_convert = QPushButton(Form) + self.pushButton_convert.setObjectName(u"pushButton_convert") + 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, 97, 126)) + self.verticalLayout = QVBoxLayout(self.layoutWidget) + self.verticalLayout.setObjectName(u"verticalLayout") + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.radioButton_mathpix = QRadioButton(self.layoutWidget) + self.radioButton_mathpix.setObjectName(u"radioButton_mathpix") + + self.verticalLayout.addWidget(self.radioButton_mathpix) + + self.radioButton_textcircled = QRadioButton(self.layoutWidget) + self.radioButton_textcircled.setObjectName(u"radioButton_textcircled") + + self.verticalLayout.addWidget(self.radioButton_textcircled) + + self.radioButton_multiple = QRadioButton(self.layoutWidget) + self.radioButton_multiple.setObjectName(u"radioButton_multiple") + + self.verticalLayout.addWidget(self.radioButton_multiple) + + self.radioButton_puctuations = QRadioButton(self.layoutWidget) + self.radioButton_puctuations.setObjectName(u"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) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u6587\u672c\u8f6c\u6362\u5904\u7406", None)) + self.plainTextEdit_origin.setPlaceholderText(QCoreApplication.translate("Form", u"\u5c06\u6e90\u6587\u672c \u7c98\u8d34 \u5728\u8fd9\u4e2a\u6587\u672c\u6846\u5185", None)) + self.label.setText(QCoreApplication.translate("Form", u"\u6e90\u6587\u672c", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"\u76ee\u6807\u6587\u672c", None)) + self.plainTextEdit_dest.setPlaceholderText(QCoreApplication.translate("Form", u"\u6309 \u8f6c\u6362 \u4ee5\u83b7\u5f97\u76ee\u6807\u6587\u672c", None)) + self.pushButton_convert.setText(QCoreApplication.translate("Form", u"\u8f6c\u6362", None)) + self.radioButton_mathpix.setText(QCoreApplication.translate("Form", u"Mathpix", 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_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/工具v3/Ui_生成直方图代码.py b/工具v3/Ui_生成直方图代码.py new file mode 100644 index 00000000..b9e290d2 --- /dev/null +++ b/工具v3/Ui_生成直方图代码.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file '生成直方图代码.ui' +## +## Created by: Qt User Interface Compiler version 6.6.2 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QLineEdit, + QPlainTextEdit, QPushButton, QSizePolicy, QTextBrowser, + QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(400, 381) + self.pushButton_generatexlist = QPushButton(Form) + self.pushButton_generatexlist.setObjectName(u"pushButton_generatexlist") + self.pushButton_generatexlist.setGeometry(QRect(10, 130, 121, 24)) + self.textBrowser = QTextBrowser(Form) + self.textBrowser.setObjectName(u"textBrowser") + self.textBrowser.setEnabled(False) + self.textBrowser.setGeometry(QRect(10, 160, 121, 211)) + self.label_6 = QLabel(Form) + self.label_6.setObjectName(u"label_6") + self.label_6.setGeometry(QRect(140, 10, 121, 16)) + self.plainTextEdit_yinfo = QPlainTextEdit(Form) + self.plainTextEdit_yinfo.setObjectName(u"plainTextEdit_yinfo") + self.plainTextEdit_yinfo.setGeometry(QRect(140, 30, 171, 181)) + self.pushButton_exec = QPushButton(Form) + self.pushButton_exec.setObjectName(u"pushButton_exec") + self.pushButton_exec.setGeometry(QRect(320, 30, 71, 181)) + font = QFont() + font.setBold(True) + self.pushButton_exec.setFont(font) + self.label_7 = QLabel(Form) + self.label_7.setObjectName(u"label_7") + self.label_7.setGeometry(QRect(140, 220, 71, 16)) + self.plainTextEdit_latexcode = QPlainTextEdit(Form) + self.plainTextEdit_latexcode.setObjectName(u"plainTextEdit_latexcode") + self.plainTextEdit_latexcode.setGeometry(QRect(140, 240, 251, 131)) + self.widget = QWidget(Form) + self.widget.setObjectName(u"widget") + self.widget.setGeometry(QRect(10, 10, 121, 108)) + self.verticalLayout = QVBoxLayout(self.widget) + self.verticalLayout.setObjectName(u"verticalLayout") + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.label = QLabel(self.widget) + self.label.setObjectName(u"label") + + self.horizontalLayout.addWidget(self.label) + + self.lineEdit_xmin = QLineEdit(self.widget) + self.lineEdit_xmin.setObjectName(u"lineEdit_xmin") + + self.horizontalLayout.addWidget(self.lineEdit_xmin) + + + self.verticalLayout.addLayout(self.horizontalLayout) + + self.horizontalLayout_2 = QHBoxLayout() + self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") + self.label_2 = QLabel(self.widget) + self.label_2.setObjectName(u"label_2") + + self.horizontalLayout_2.addWidget(self.label_2) + + self.lineEdit_xmax = QLineEdit(self.widget) + self.lineEdit_xmax.setObjectName(u"lineEdit_xmax") + + self.horizontalLayout_2.addWidget(self.lineEdit_xmax) + + + self.verticalLayout.addLayout(self.horizontalLayout_2) + + self.horizontalLayout_5 = QHBoxLayout() + self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") + self.label_5 = QLabel(self.widget) + self.label_5.setObjectName(u"label_5") + + self.horizontalLayout_5.addWidget(self.label_5) + + self.lineEdit_xwidth = QLineEdit(self.widget) + self.lineEdit_xwidth.setObjectName(u"lineEdit_xwidth") + + self.horizontalLayout_5.addWidget(self.lineEdit_xwidth) + + + self.verticalLayout.addLayout(self.horizontalLayout_5) + + self.horizontalLayout_4 = QHBoxLayout() + self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") + self.label_4 = QLabel(self.widget) + self.label_4.setObjectName(u"label_4") + + self.horizontalLayout_4.addWidget(self.label_4) + + self.lineEdit_xlabel = QLineEdit(self.widget) + self.lineEdit_xlabel.setObjectName(u"lineEdit_xlabel") + + self.horizontalLayout_4.addWidget(self.lineEdit_xlabel) + + + self.verticalLayout.addLayout(self.horizontalLayout_4) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"\u751f\u6210\u76f4\u65b9\u56fe\u4ee3\u7801", None)) + self.pushButton_generatexlist.setText(QCoreApplication.translate("Form", u"\u751f\u6210\u6a2a\u5750\u6807\u5e8f\u5217", None)) + self.textBrowser.setHtml(QCoreApplication.translate("Form", u"\n" +"\n" +"

\u4e0d\u6539\u53d8\u6a2a\u5750\u6807\u7684\u503c, \u5728\u9017\u53f7\u540e\u8f93\u5165\u7eb5\u5750\u6807\u7684\u503c

\n" +"

\u5982\u679c\u6807\u7b7e\u548c\u7eb5\u5750\u6807\u7684\u503c\u4e0d\u540c, \u5728\u540e\u9762\u7684\u65b9\u62ec\u53f7\u5185\u8f93\u5165\u6807\u7b7e\n" +"

\u5982:

\n" +"

(10,0.02)[]

\n" +"

(20,0.04)[a]

\n" +"

(30,0.04][]

\n" +"


", None)) + self.label_6.setText(QCoreApplication.translate("Form", u"\u8f93\u5165\u7eb5\u5750\u6807\u4fe1\u606f", None)) + self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u751f\u6210\u4ee3\u7801", None)) + self.label_7.setText(QCoreApplication.translate("Form", u"\u76f4\u65b9\u56fe\u4ee3\u7801", None)) + self.label.setText(QCoreApplication.translate("Form", u"x\u6700\u5c0f\u503c", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"x\u6700\u5927\u503c", None)) + self.label_5.setText(QCoreApplication.translate("Form", u"x\u5bbd\u5ea6", None)) + self.label_4.setText(QCoreApplication.translate("Form", u"x\u8f74label", None)) + # retranslateUi + diff --git a/工具v3/文本转换处理.py b/工具v3/文本转换处理.py new file mode 100644 index 00000000..38ccaa55 --- /dev/null +++ b/工具v3/文本转换处理.py @@ -0,0 +1,43 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_文本转换处理 import Ui_Form +from database_tools_2 import * + +class MyWindow(QWidget,Ui_Form): + def __init__(self): + super().__init__() + self.setupUi(self) + self.bind() + def bind(self): + self.radioButton_mathpix.setChecked(True) + self.pushButton_convert.clicked.connect(self.exec) + def exec(self): + raw_string = self.plainTextEdit_origin.toPlainText() + if self.radioButton_mathpix.isChecked(): + dest_string = RefineMathpix(raw_string) + elif self.radioButton_textcircled.isChecked(): + dest_string = re.sub(r"\((\d)\)",lambda x: "\\textcircled{"+x.group(1)+"}",raw_string) #替换所有的小括号包围的单个数字为圆圈包围的 + dest_string = re.sub(r"\$\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}$",dest_string) + dest_string = re.sub(r"\\textcircled\{\\scriptsize\{(\d)\}\}",lambda x: "\\textcircled{"+x.group(1)+"}",dest_string) + elif self.radioButton_multiple.isChecked(): + try: + dest_string = MultiplechoicetoBlankFilling(raw_string) + except: + 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) + + + + + + +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow() + windows.show() + app.exec() + diff --git a/工具v3/文本转换处理.ui b/工具v3/文本转换处理.ui new file mode 100644 index 00000000..373eec33 --- /dev/null +++ b/工具v3/文本转换处理.ui @@ -0,0 +1,142 @@ + + + Form + + + + 0 + 0 + 720 + 401 + + + + 文本转换处理 + + + + + 10 + 30 + 291 + 361 + + + + 将源文本 粘贴 在这个文本框内 + + + + + + 10 + 10 + 54 + 16 + + + + 源文本 + + + + + + 390 + 10 + 54 + 16 + + + + 目标文本 + + + + + + 430 + 30 + 281 + 361 + + + + false + + + true + + + 按 转换 以获得目标文本 + + + + + + 310 + 230 + 111 + 71 + + + + + true + + + + 转换 + + + + + + 320 + 80 + 97 + 126 + + + + + + + Mathpix + + + + + + + 圆圈数字 + + + + + + + 多选转填空 + + + + + + + 标点转半角 + + + + + + + 已有答案标红 + + + + + + + + + diff --git a/工具v3/生成直方图代码.py b/工具v3/生成直方图代码.py new file mode 100644 index 00000000..c3bbe062 --- /dev/null +++ b/工具v3/生成直方图代码.py @@ -0,0 +1,105 @@ +from PySide6.QtWidgets import QWidget, QApplication, QFileDialog +from Ui_生成直方图代码 import Ui_Form +import re + + +class MyWindow(QWidget,Ui_Form): + def __init__(self): + super().__init__() + self.setupUi(self) + self.bind() + def bind(self): + self.pushButton_generatexlist.clicked.connect(self.generateXList) + self.pushButton_exec.clicked.connect(self.exec) + def generateXList(self): + self.xmin = int(self.lineEdit_xmin.text()) + self.xmax = int(self.lineEdit_xmax.text()) + self.xwidth = int(self.lineEdit_xwidth.text()) + self.xlist = list(range(self.xmin,self.xmax,self.xwidth)) + output = "" + for x in self.xlist: + output += f"({x},)[]\n" + self.plainTextEdit_yinfo.setPlainText(output) + def folding(self): + if self.xmin <= self.xwidth: + foldingstr = "" + else: + midpoint = 1/2 * (self.xstart + self.xmin) + dist = (midpoint - self.xstart) / 6 + foldingstr = "" + height = 0.2/self.yscale + foldingstr += f" -- ({(self.xstart+dist*4):.2f},0)" + foldingstr += f" -- ({(self.xstart+dist*5):.2f},{height:.4f})" + foldingstr += f" -- ({(self.xstart+dist*7):.2f},{-height:.4f})" + foldingstr += f" -- ({(self.xstart+dist*8):.2f},0)" + return foldingstr + def exec(self): + xlabel = self.lineEdit_xlabel.text() + coordinateinfo = self.plainTextEdit_yinfo.toPlainText() + if self.xmin < self.xwidth: #计算x轴的起点坐标 + self.xstart = 0 + else: + self.xstart = self.xmin - self.xwidth + self.xmax = self.xlist[-1] + self.xwidth + self.xend = self.xmax + self.xwidth #计算x轴的终点坐标 + self.xscale = 5/(self.xend-self.xstart) #计算x放缩比例 + # print(self.xscale) + self.coordinatelist = re.findall(r"\(([\d\.]+),([\d\.]+)\)\[([\S]*)\]",coordinateinfo) #计算坐标信息 + for cindex in range(len(self.coordinatelist)): + x,y,label = self.coordinatelist[cindex] + if label.strip() == "": + self.coordinatelist[cindex] = (x,y,y) + self.coordinatestr_raw = [] + for coord in self.coordinatelist: + x,y,label = coord + self.coordinatestr_raw.append(f"{x}/{y}") + self.coordinatestr = ",".join(self.coordinatestr_raw) + # print(self.coordinatelist) + self.dasheddict = {} #计算以纵坐标为key的虚线信息, 内容为(x,label) + for coord in self.coordinatelist: + x,y,label = coord + if not y in self.dasheddict: + self.dasheddict[y] = (x,label) + else: + if x > self.dasheddict[y][0] and label == y: + self.dasheddict[y] = (x,self.dasheddict[y][1]) + elif x > self.dasheddict[y][0] and label != y: + self.dasheddict[y] = (x,label) + self.dashedstr_raw = [] + for y in self.dasheddict: + x,label = self.dasheddict[y] + self.dashedstr_raw.append(f"{x}/{y}/{label}") + self.dashedstr = ",".join(self.dashedstr_raw) + # print(self.dasheddict) + ymax = max([float(i) for i in self.dasheddict.keys()]) + self.yscale = 3/ymax #3是y的长度, 计算y放缩比例 + self.yend = ymax + 1/float(self.yscale) + latexcode = f"""\\begin{{center}} + \\begin{{tikzpicture}}[>=latex, xscale = {self.xscale:.4f}, yscale = {self.yscale:.4f}] + \\draw [->] ({self.xstart},0) {self.folding()}-- ({self.xend},0) node [below right] {{{xlabel}}}; + \\draw [->] ({self.xstart},0) -- ({self.xstart},{self.yend:.2f}) node [left] {{$\\dfrac{{\\text{{频率}}}}{{\\text{{组距}}}}$}}; + \\draw ({self.xstart},0) node [below] {{$0$}}; + \\foreach \\i/\\j in {{{self.coordinatestr}}} + {{\\draw (\\i,0) node [below] {{$\\i$}} --++ (0,\\j) --++ ({self.xwidth},0) --++ (0,-\\j);}}; + \\draw ({self.xmax},0) node [below] {{${self.xmax}$}}; + \\foreach \i/\j/\k in {{{self.dashedstr}}} + {{\\draw [dashed] (\\i,\\j) -- ({self.xstart},\\j) node [left] {{$\\k$}};}}; + \\end{{tikzpicture}} + \\end{{center}}""" + latexcode = re.sub(r"\n\s+","\n",latexcode) + self.plainTextEdit_latexcode.setPlainText(latexcode) + + + + + + + + + +if __name__ == '__main__': + app = QApplication([]) + windows = MyWindow() + windows.show() + app.exec() + diff --git a/工具v3/生成直方图代码.ui b/工具v3/生成直方图代码.ui new file mode 100644 index 00000000..c225b0a7 --- /dev/null +++ b/工具v3/生成直方图代码.ui @@ -0,0 +1,193 @@ + + + Form + + + + 0 + 0 + 400 + 381 + + + + 生成直方图代码 + + + + + 10 + 130 + 121 + 24 + + + + 生成横坐标序列 + + + + + false + + + + 10 + 160 + 121 + 211 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } +</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">不改变横坐标的值, 在逗号后输入纵坐标的值</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">如果标签和纵坐标的值不同, 在后面的方括号内输入标签</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">如:</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(10,0.02)[]</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(20,0.04)[a]</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(30,0.04][]</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + + + + 140 + 10 + 121 + 16 + + + + 输入纵坐标信息 + + + + + + 140 + 30 + 171 + 181 + + + + + + + 320 + 30 + 71 + 181 + + + + + true + + + + 生成代码 + + + + + + 140 + 220 + 71 + 16 + + + + 直方图代码 + + + + + + 140 + 240 + 251 + 131 + + + + + + + 10 + 10 + 121 + 108 + + + + + + + + + x最小值 + + + + + + + + + + + + + + x最大值 + + + + + + + + + + + + + + x宽度 + + + + + + + + + + + + + + x轴label + + + + + + + + + + + + + +