A formula-based data processing method and apparatus

CN113903034BActive Publication Date: 2025-12-02BEIJING SOGOU TECHNOLOGY DEVELOPMENT CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111155055.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2025-12-02
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

[0004]本申请所要解决的技术问题是:识别得到的公式存在语法错误时,无法输出所识别到的公式

Benefits of technology

[0049]本申请实施例提供了一种基于公式的数据处理方法,在该方法中:可以获取存在语法错误的待处理公式字符串,而后,将所述待处理公式字符串输入机器学习模型,得到目标公式字符串。此处提及的机器学习模型,可以将存在语法错误的公式字符串修正为符合语法要求的公式字符串。因此,在本申请实施例中,将所述待处理公式字符串输入所述机器学习模型之后,可以得到符合语法要求的目标公式字符串,换言之,所得到的目标公式字符串不存在语法错误。因此,得到目标公式字符串之后,可以根据所述目标公式字符串得到目标公式。由此可见,利用本申请实施例的方案,对于存在语法错误的待处理公式字符串,能够对待处理公式字符串存在的语法错误进行纠错,从而得到目标公式。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113903034B_ABST
    Figure CN113903034B_ABST
Patent Text Reader

Abstract

This application discloses a formula-based data processing method that can obtain a formula string containing grammatical errors, and then input the formula string into a machine learning model to obtain a target formula string. The machine learning model mentioned here can correct the grammatically incorrect formula string into a grammatically correct one. Therefore, in this embodiment, after inputting the formula string into the machine learning model, a grammatically correct target formula string can be obtained; in other words, the obtained target formula string does not contain grammatical errors. Therefore, after obtaining the target formula string, the target formula can be derived from it. Thus, the solution of this embodiment can correct the grammatical errors in a formula string containing grammatical errors, thereby obtaining the target formula.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and in particular to a formula-based data processing method and apparatus. Background Technology

[0002] In some scenarios, it's necessary to identify formulas within images. Formula description languages, such as LaTeX, can be used to describe the identified formulas. However, when using a formula description language, it must conform to its syntax standards; otherwise, the identified formula cannot be output correctly. Therefore, if a misidentification occurs during formula recognition, resulting in a syntax error, the identified formula cannot be output.

[0003] Therefore, there is an urgent need for a solution that can correctly output the corresponding formula even when the identified formula has a syntax error. Summary of the Invention

[0004] The technical problem this application aims to solve is that when a recognized formula contains a syntax error, the recognized formula cannot be output. A formula-based data processing method and apparatus are provided.

[0005] In a first aspect, embodiments of this application provide a formula-based data processing method, the method comprising:

[0006] Obtain the formula string to be processed, wherein the formula string to be processed is a string containing syntax errors;

[0007] The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0008] The target formula is obtained based on the target formula string.

[0009] Optionally, the method further includes:

[0010] Obtain the training formula string containing syntax errors and the label of the training formula string, wherein the label of the training formula string is used to indicate the syntax errors in the training formula string;

[0011] The machine learning model is trained based on the training formula string and its label.

[0012] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0013] Optionally, obtaining the training formula string includes:

[0014] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0015] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0016] Optionally, the formula string to be processed is a LaTeX string.

[0017] Optionally, before obtaining the string to be processed, the method further includes:

[0018] It was determined that the string to be processed contained a syntax error.

[0019] Secondly, embodiments of this application provide a formula-based data processing apparatus, the apparatus comprising:

[0020] The first acquisition unit is used to acquire the formula string to be processed, wherein the formula string to be processed is a string with syntax errors;

[0021] The first processing unit is used to input the formula string to be processed into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0022] The second processing unit is used to obtain the target formula based on the target formula string.

[0023] Optionally, the device further includes:

[0024] The second acquisition unit is used to acquire a training formula string with syntax errors and a label for the training formula string, wherein the label for the training formula string is used to indicate the syntax errors in the training formula string.

[0025] The training unit is used to train the machine learning model based on the training formula string and the label of the training formula string.

[0026] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0027] Optionally, obtaining the training formula string includes:

[0028] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0029] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0030] Optionally, the formula string to be processed is a LaTeX string.

[0031] Optionally, the device further includes:

[0032] The determining unit is used to determine that the string to be processed contains a syntax error before obtaining the string to be processed.

[0033] Thirdly, embodiments of this application provide a formula-based data processing apparatus, characterized in that it includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs contain instructions for performing the following operations:

[0034] Obtain the formula string to be processed, wherein the formula string to be processed is a string containing syntax errors;

[0035] The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0036] The target formula is obtained based on the target formula string.

[0037] Optionally, the operation further includes:

[0038] Obtain the training formula string containing syntax errors and the label of the training formula string, wherein the label of the training formula string is used to indicate the syntax errors in the training formula string;

[0039] The machine learning model is trained based on the training formula string and its label.

[0040] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0041] Optionally, obtaining the training formula string includes:

[0042] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0043] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0044] Optionally, the formula string to be processed is a LaTeX string.

[0045] Optionally, before obtaining the string to be processed, the operation further includes:

[0046] It was determined that the string to be processed contained a syntax error.

[0047] Fourthly, embodiments of this application provide a computer-readable medium having instructions stored thereon that, when executed by one or more processors, cause a device to perform the method described in any of the first aspects above.

[0048] Compared with the prior art, the embodiments of this application have the following advantages:

[0049] This application provides a formula-based data processing method. In this method, a formula string containing grammatical errors is obtained, and then input into a machine learning model to obtain a target formula string. The machine learning model mentioned here can correct the grammatically incorrect formula string into a grammatically correct one. Therefore, in this application embodiment, after inputting the formula string into the machine learning model, a grammatically correct target formula string can be obtained; in other words, the obtained target formula string does not contain grammatical errors. Therefore, after obtaining the target formula string, the target formula can be derived from it. Thus, the solution of this application embodiment can correct grammatical errors in a formula string containing grammatical errors, thereby obtaining the target formula. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 A flowchart illustrating a formula-based data processing method provided in this application embodiment;

[0052] Figure 2 A schematic diagram of the structure of a formula-based data processing device provided in this application embodiment;

[0053] Figure 3 This is a schematic diagram of the client structure provided in the embodiments of this application;

[0054] Figure 4 This is a schematic diagram of the server structure provided in an embodiment of this application. Detailed Implementation

[0055] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0056] The inventors of this application discovered through research that recognized formulas can be described using formula description languages ​​such as LaTeX. However, when using a formula description language to describe a formula, it must conform to the syntax standards of that language. If a recognized formula described using a formula description language contains syntax errors, the recognized formula cannot be output correctly. For example, if a formula described using LaTeX is missing a single '}', the recognized formula cannot be output. Therefore, if syntax correction can be performed on formulas described using a formula description language, the above problem can be solved.

[0057] Therefore, embodiments of this application provide a formula-based data processing method and apparatus.

[0058] The various non-limiting embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0059] Exemplary methods

[0060] See Figure 1 The figure is a flowchart illustrating a formula-based data processing method provided in an embodiment of this application.

[0061] The methods provided in this application embodiment can be executed by a first device, which includes, but is not limited to, terminal devices and servers. The terminal devices mentioned herein can be mobile terminals such as smartphones and tablets, or terminal devices such as desktop computers.

[0062] The formula-based data processing method provided in this application can be applied to the post-processing stage of formula recognition. Specifically: after obtaining a formula string from an image, a syntax discriminator determines whether the obtained formula string contains syntax errors. If no syntax errors are found, the formula can be directly output. If syntax errors are found, the obtained formula string can be further used as the formula string to be processed in this application embodiment, and the formula-based data processing method provided in this application embodiment can be executed to perform syntax correction on the formula string to be processed, so as to correctly output the formula included in the image.

[0063] Figure 1 The method shown can be implemented, for example, through the following steps S101-S103.

[0064] S101: Obtain the formula string to be processed, wherein the formula string to be processed is a string with syntax errors.

[0065] In this embodiment of the application, the formula string to be processed is a string described using a formula description language. In one example, the formula string to be processed is a LaTeX string.

[0066] The statement that the formula string to be processed has a syntax error means that the formula string to be processed does not conform to the syntax standard of the formula description language corresponding to the formula string. For example, the formula string to be processed includes "{" but does not include "}"; or the formula string to be processed includes "begin" but does not include "end".

[0067] In one example, before executing S101, the obtained formula string to be processed can be judged to determine whether there are any syntax errors. After determining that there are syntax errors in the formula string, S101 is then executed. In one example, a syntax discriminator can be used to determine whether there are any syntax errors in the formula string to be processed. The syntax discriminator will not be described in detail here.

[0068] S102: Input the formula string to be processed into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements.

[0069] In this embodiment of the application, the formula string that meets the grammatical requirements is that which is the formula string that does not have grammatical errors.

[0070] In this embodiment, after obtaining the formula string to be processed, a machine learning model can be used to perform syntax correction on the string. Specifically, the machine learning model can output a formula string without syntax errors based on a formula string containing syntax errors. In other words, after inputting the formula string to be processed into the machine learning model, the model can correct the formula string and output a target formula string without syntax errors.

[0071] In this embodiment of the application, the machine learning model may be pre-trained. For details on the specific method of training the machine learning model, please refer to the relevant description section below, which will not be described in detail here.

[0072] This application does not specifically limit the machine learning model. In one example, the machine learning model may be a BERT model. Furthermore, this application does not specifically limit the algorithm used to train the machine learning model. In one example, when the machine learning model is a BERT model, the algorithm used to train the machine learning model is a Mask Language Model (MLM) algorithm.

[0073] S103: Obtain the target formula based on the target formula string.

[0074] It is understood that the target formula string does not contain any syntax errors; therefore, the target formula can be obtained from the target formula string. In one example, a formula recognizer that supports the description language corresponding to the target formula string can be used to recognize the target formula string, thereby obtaining the target formula. For example, a formula recognizer that supports the LaTeX language can be used to recognize the target formula string, thereby obtaining the target formula.

[0075] As can be seen from the above description, the solution of this application embodiment can correct the syntax errors in the formula string to be processed that have syntax errors, thereby obtaining the target formula.

[0076] Next, the method for training the machine learning model will be introduced.

[0077] In this embodiment of the application, the machine learning model can be obtained by training through the following steps AB.

[0078] In the following description, the formula string to be processed is a LaTeX string as an example.

[0079] Step A: Obtain the training formula string containing syntax errors and the label of the training formula string. The label of the training formula string is used to indicate the syntax errors in the training formula string.

[0080] In this application embodiment, obtaining the training formula string can be implemented in various ways. In one example, formula strings with grammatical errors obtained from image recognition can be collected as the training formula string.

[0081] In another example, one could first obtain (e.g., generate) a formula string free of syntax errors, and then process this string to obtain a formula string with syntax errors. For example, one could randomly delete certain characters from the string free of syntax errors, or randomly modify the positions of certain characters in the string free of syntax errors, and so on.

[0082] In this embodiment, the labels of the training formula string can be manually pre-annotated. In one example, a label can be added between any two characters of the training formula string. This label is used to indicate whether a character needs to be added or deleted at that position. Specifically, when a character needs to be added at that position, the label also indicates the specific character to be added. Deleting a character at that position can mean deleting the character preceding or following that position; this embodiment does not impose specific limitations. For example, if there is label 1 between characters A and B, label 1 can be used to indicate that the character "{" needs to be added at that position. Similarly, if there is label 2 between characters A and B, label 2 can be used to indicate that character A needs to be deleted. It is understood that the set of labels formed by the labels between any two characters of the training formula string constitutes the label of the training formula string.

[0083] It is understood that, for the training formula string, not all characters in the training formula string can affect its validity. In other words, the training formula string includes strings that affect syntactic validity and strings that do not. The validity of the training formula string mentioned here refers to whether the training formula string conforms to the syntax of its corresponding formula description language. For example, for a formula... The corresponding LaTeX string is "\frac{a}{b}". The characters "\frac", "{", and "}" all affect the syntactic validity, while the characters "a" and "b" do not. In other words, the string affecting syntactic validity consists of five characters: "\frac", two "{", and two "}", while the string not affecting syntactic validity consists of two characters: "a" and "b".

[0084] It is understandable that, for the training formula string, each character in the string that does not affect its validity can be any possible character. However, since the string that does not affect the validity of the training formula string does not affect the validity of the training formula string, the value of the string that does not affect the validity of the training formula string does not affect the recognition performance of the trained machine learning model. Therefore, in one example, in order to facilitate the management of the training formula string and to avoid the string that does not affect the validity of the training formula string from interfering with the string that does affect the validity of the training formula string, all characters included in the string that does not affect the validity of the syntax are the same character. For example, all characters are the character "a", or all characters are the character "b", and this application embodiment does not make specific limitations.

[0085] Step B: Train the machine learning model based on the training formula string and its labels.

[0086] After obtaining the training formula string and its labels, the machine learning model can be trained using the training formula string and its labels. In one example, the BERT model can be trained using the MLM algorithm, the training formula string, and its labels.

[0087] Exemplary device

[0088] Based on the methods provided in the above embodiments, this application also provides an apparatus, which will be described below with reference to the accompanying drawings.

[0089] See Figure 2 The figure is a schematic diagram of the structure of a formula-based data processing device provided in an embodiment of this application. The device 200 may specifically include, for example, a first acquisition unit 201, a first processing unit 202, and a second processing unit 203.

[0090] The first acquisition unit 201 is used to acquire a formula string to be processed, wherein the formula string to be processed is a string with a syntax error.

[0091] The first processing unit 202 is used to input the formula string to be processed into a machine learning model to obtain a target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0092] The second processing unit 203 is used to obtain the target formula based on the target formula string.

[0093] Optionally, the device further includes:

[0094] The second acquisition unit is used to acquire a training formula string with syntax errors and a label for the training formula string, wherein the label for the training formula string is used to indicate the syntax errors in the training formula string.

[0095] The training unit is used to train the machine learning model based on the training formula string and the label of the training formula string.

[0096] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0097] Optionally, obtaining the training formula string includes:

[0098] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0099] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0100] Optionally, the formula string to be processed is a LaTeX string.

[0101] Optionally, the device further includes:

[0102] The determining unit is used to determine that the string to be processed contains a syntax error before obtaining the string to be processed.

[0103] Since the device 200 is a device corresponding to the method provided in the above method embodiments, the specific implementation of each unit of the device 200 is based on the same concept as the above method embodiments. Therefore, the specific implementation of each unit of the device 200 can be referred to the description section of the above method embodiments, and will not be repeated here.

[0104] The method provided in this application embodiment can be executed by a client or a server. The client and server executing the above method are described below respectively.

[0105] Figure 3 A block diagram of a client 300 is shown. For example, client 300 can be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness device, personal digital assistant, etc.

[0106] Reference Figure 3 The client 300 may include one or more of the following components: processing component 302, memory 304, power supply component 306, multimedia component 308, audio component 310, input / output (I / O) interface 33, sensor component 314, and communication component 316.

[0107] Processing component 302 typically controls the overall operation of client 300, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 302 may include one or more processors 320 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 302 may include one or more modules to facilitate interaction between processing component 302 and other components. For example, processing component 302 may include a multimedia module to facilitate interaction between multimedia component 308 and processing component 302.

[0108] Memory 304 is configured to store various types of data to support operation on client 300. Examples of this data include instructions for any application or method operating on client 300, contact data, phonebook data, messages, pictures, videos, etc. Memory 304 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0109] Power supply component 306 provides power to various components of client 300. Power supply component 306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to client 300.

[0110] Multimedia component 308 includes a screen that provides an output interface between the client 300 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 308 includes a front-facing camera and / or a rear-facing camera. When the client 300 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0111] Audio component 310 is configured to output and / or input audio signals. For example, audio component 310 includes a microphone (MIC) configured to receive external audio signals when client 300 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 304 or transmitted via communication component 316. In some embodiments, audio component 310 also includes a speaker for outputting audio signals.

[0112] The I / O interface provides an interface between the processing component 302 and the peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to, a home button, volume buttons, a power button, and a lock button.

[0113] Sensor assembly 314 includes one or more sensors for providing status assessments of various aspects of client 300. For example, sensor assembly 314 may detect the on / off state of device 300, the relative positioning of components such as the display and keypad of client 300, changes in position of client 300 or a component thereof, the presence or absence of user contact with client 300, orientation or acceleration / deceleration of client 300, and temperature changes of client 300. Sensor assembly 314 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 314 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 314 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0114] Communication component 316 is configured to facilitate wired or wireless communication between client 300 and other devices. Client 300 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 316 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 316 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0115] In an exemplary embodiment, client 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the following methods:

[0116] Obtain the formula string to be processed, wherein the formula string to be processed is a string containing syntax errors;

[0117] The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0118] The target formula is obtained based on the target formula string.

[0119] Optionally, the method further includes:

[0120] Obtain the training formula string containing syntax errors and the label of the training formula string, wherein the label of the training formula string is used to indicate the syntax errors in the training formula string;

[0121] The machine learning model is trained based on the training formula string and its label.

[0122] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0123] Optionally, obtaining the training formula string includes:

[0124] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0125] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0126] Optionally, the formula string to be processed is a LaTeX string.

[0127] Optionally, before obtaining the string to be processed, the method further includes:

[0128] It was determined that the string to be processed contained a syntax error.

[0129] Figure 4 This is a schematic diagram of the server structure in an embodiment of this application. The server 400 can vary significantly due to different configurations or performance, and may include one or more central processing units (CPUs) 422 (e.g., one or more processors) and memory 432, and one or more storage media 430 (e.g., one or more mass storage devices) for storing application programs 442 or data 444. The memory 432 and storage media 430 can be temporary or persistent storage. The program stored in the storage media 430 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 422 may be configured to communicate with the storage media 430 and execute the series of instruction operations in the storage media 430 on the server 400.

[0130] Furthermore, the central processing unit 422 can perform the following methods:

[0131] Obtain the formula string to be processed, wherein the formula string to be processed is a string containing syntax errors;

[0132] The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0133] The target formula is obtained based on the target formula string.

[0134] Optionally, the method further includes:

[0135] Obtain the training formula string containing syntax errors and the label of the training formula string, wherein the label of the training formula string is used to indicate the syntax errors in the training formula string;

[0136] The machine learning model is trained based on the training formula string and its label.

[0137] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0138] Optionally, obtaining the training formula string includes:

[0139] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0140] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0141] Optionally, the formula string to be processed is a LaTeX string.

[0142] Optionally, before obtaining the string to be processed, the method further includes:

[0143] It was determined that the string to be processed contained a syntax error.

[0144] Server 400 may also include one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input / output interfaces 456, one or more keyboards 456, and / or one or more operating systems 441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0145] This application also provides a computer-readable medium storing instructions that, when executed by one or more processors, cause a device to perform the following method:

[0146] Obtain the formula string to be processed, wherein the formula string to be processed is a string containing syntax errors;

[0147] The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to: correct the formula string with syntax errors into a formula string that meets the syntax requirements;

[0148] The target formula is obtained based on the target formula string.

[0149] Optionally, the method further includes:

[0150] Obtain the training formula string containing syntax errors and the label of the training formula string, wherein the label of the training formula string is used to indicate the syntax errors in the training formula string;

[0151] The machine learning model is trained based on the training formula string and its label.

[0152] Optionally, the training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity, wherein the characters included in the strings that do not affect the grammatical validity are all the same character.

[0153] Optionally, obtaining the training formula string includes:

[0154] Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

[0155] Optionally, the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm.

[0156] Optionally, the formula string to be processed is a LaTeX string.

[0157] Optionally, before obtaining the string to be processed, the method further includes:

[0158] It was determined that the string to be processed contained a syntax error.

[0159] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0160] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

[0161] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A formula-based data processing method, characterized in that, The method includes: After obtaining the formula string through image recognition, the syntax discriminator determines whether the formula string contains syntax errors. If the formula string contains a syntax error, then the formula string will be used as the formula string to be processed; the formula string to be processed is a LaTeX string. The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to correct the formula string with syntax errors into a formula string that meets the syntax requirements. The machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm. The target formula is obtained by recognizing the target formula string using a formula recognizer that supports the description language corresponding to the target formula string; The training process of the machine learning model includes: Obtain a training formula string containing grammatical errors and a label for the training formula string. The training formula string includes strings that affect grammatical validity and strings that do not affect grammatical validity. The strings that do not affect grammatical validity contain the same character. The label is located between any two characters in the training formula string. The label is used to indicate grammatical errors in the training formula string and to indicate whether characters need to be added or deleted at the position. The machine learning model is trained based on the MLM algorithm, the training formula string, and the labels of the training formula string.

2. The method according to claim 1, characterized in that, The step of obtaining the training formula string includes: Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

3. A formula-based data processing device, characterized in that, The device includes: The first acquisition unit is used to determine whether there is a syntax error in the formula string after obtaining it through image recognition, based on a syntax discriminator; if there is a syntax error in the formula string, the formula string is used as a formula string to be processed; the formula string to be processed is a LaTeX string. The first processing unit is used to input the formula string to be processed into the machine learning model to obtain the target formula string; the machine learning model is used to correct the formula string with syntax errors into a formula string that meets the syntax requirements; the machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm. The second processing unit is used to recognize the target formula string using a formula recognizer that supports the description language corresponding to the target formula string, and obtain the target formula; The second acquisition unit is used to acquire a training formula string with a syntax error and a label of the training formula string. The training formula string includes strings that affect the grammatical validity and strings that do not affect the grammatical validity. The strings that do not affect the grammatical validity include all characters of the same character. The label is located between any two characters in the training formula string. The label is used to indicate the syntax error in the training formula string and to indicate whether characters need to be added or deleted at the position. The training unit is used to train the machine learning model based on the MLM algorithm, the training formula string, and the labels of the training formula string.

4. The apparatus according to claim 3, characterized in that, The step of obtaining the training formula string includes: Obtain the formula string that has no syntax errors, process the formula string that has no syntax errors, and obtain the training formula string.

5. A formula-based data processing device, characterized in that, It includes memory and one or more programs, wherein one or more programs are stored in memory and configured to be executed by one or more processors. The one or more programs contain instructions for performing the following operations: After obtaining the formula string through image recognition, the syntax discriminator determines whether the formula string contains syntax errors. If the formula string contains a syntax error, then the formula string will be used as the formula string to be processed, and the formula string to be processed will be a LaTeX string. The formula string to be processed is input into the machine learning model to obtain the target formula string; the machine learning model is used to correct the formula string with syntax errors into a formula string that meets the syntax requirements. The machine learning model is a BERT model, and the algorithm used to train the machine learning model is the Masked Language Model (MLM) algorithm. The target formula is obtained based on the target formula string; The training process of the machine learning model includes: Obtain a training formula string containing grammatical errors and a label for the training formula string. The training formula string includes strings that affect grammatical validity and strings that do not affect grammatical validity. The strings that do not affect grammatical validity contain the same character. The label is located between any two characters in the training formula string. The label is used to indicate grammatical errors in the training formula string and to indicate whether characters need to be added or deleted at the position. The machine learning model is trained based on the MLM algorithm, the training formula string, and the labels of the training formula string.

6. A computer-readable medium having instructions stored thereon that, when executed by one or more processors, cause a device to perform the method of any one of claims 1 to 2.

Citation Information

Patent Citations

  • BERT and feedforward neural network-based text error correction method

    CN112836496A

  • Formula processing method and system for educational resource library

    CN113326675A

  • Method and device for training and recognizing grammar error recognition model, medium and program

    CN114580384A