Text correction method and device, electronic equipment and storage medium

By using a lightweight BERT language model to correct OCR recognition results, the problem of multiple and missed word recognition in sentences in lightweight offline scenarios is solved, and accurate correction of scanned text is achieved, thus improving the effect of OCR recognition.

CN116524502BActive Publication Date: 2026-07-21WANGYIYOUDAO INFORMATION TECH BEIJING CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WANGYIYOUDAO INFORMATION TECH BEIJING CO LTD
Filing Date
2022-12-16
Publication Date
2026-07-21

Smart Images

  • Figure CN116524502B_ABST
    Figure CN116524502B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a text correction method and device, electronic equipment and storage medium. Wherein, the method comprises: obtaining a scanning text obtained by scanning a target object; inputting the scanning text into a lightweight bert language model to obtain target language features of the scanning text, wherein the parameter quantity of the lightweight bert language model is less than the standard parameter quantity of the standard Bert model; performing a first correction operation on the scanning text according to the target language features to obtain a first corrected text; and obtaining a second corrected text after completing the correction of the scanning text according to the first corrected text. The present application overcomes the technical problem that there is no OCR recognition result correction technology suitable for lightweight offline in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of optical character recognition, and more specifically, the embodiments of the present invention relate to text correction methods and apparatus, electronic devices and storage media. Background Technology

[0002] This section is intended to provide background or context for embodiments of the invention as set forth in the claims. The description herein is not an admission that it is prior art simply because it is included in this section.

[0003] When users scan text with a dictionary pen, OCR recognition results sometimes show errors, including over-recognition or under-recognition. This is especially true when scanning words within sentences, where over-recognition and under-recognition are more common.

[0004] A "word within a sentence" refers to a single word within a complete sentence. When users scan for "words within a sentence," the dictionary pen often fails to accurately scan the desired word. It may scan part or all of the words preceding and following the target word, or the target word may be incomplete. For example... Figure 1 As shown, when the user scanned the word "promotion," parts of the words before and after it were scanned, but the word "forecasting" was not scanned completely.

[0005] Among related technologies, there is the GECToR scheme (an error correction scheme for English scenarios), which mainly uses the BERT language model for English text error correction. Its main principle is to replace the last two branches with BERT and the trained model to perform error detection and correction on English sentences, respectively. Both error detection and correction are at the word level, and word correction heavily relies on the vocabulary generated during training. However, it is mainly for general text error correction, with applications in grammar correction and spell checking. Its error correction effect is not ideal for various scenarios such as textbooks, exercise books, picture books, and newspapers, and it is also prone to overcorrection. Furthermore, the original GECToR model is very large, making it unsuitable for lightweight offline deployment. Therefore, there is no OCR recognition result correction technology suitable for lightweight offline deployment in the related technologies.

[0006] In summary, there is a technical problem in the related technologies that there is no suitable OCR recognition result correction technology for lightweight offline applications. Summary of the Invention

[0007] However, because the original GECToR model is very large and not suitable for lightweight offline deployment, there is no existing technology for OCR recognition result correction suitable for lightweight offline deployment.

[0008] Therefore, there is a great need for an improved text correction method, device, electronic equipment, and storage medium to achieve the goal of OCR recognition result correction technology suitable for lightweight offline applications.

[0009] In a first aspect of the present invention, a text correction method is provided, comprising:

[0010] Obtain the scanned text obtained from scanning the target object;

[0011] The scanned text is input into a lightweight BERT language model to obtain the target language features of the scanned text, wherein the number of parameters of the lightweight BERT language model is less than the number of parameters of the standard BERT model.

[0012] The scanned text is subjected to a first correction operation based on the target language features to obtain a first corrected text.

[0013] Based on the first corrected text, a second corrected text is obtained after the scanned text has been corrected.

[0014] In one embodiment of the present invention, as described in the aforementioned text correction method, obtaining a second corrected text based on the first corrected text after correcting the scanned text includes:

[0015] Among all candidate correction objects in the first correction text, erroneous correction objects that do not meet the preset correction requirements are identified. The candidate correction objects are those that replace, add, or delete the scanned objects in the scanned text during the first correction operation.

[0016] According to the scan object corresponding to each candidate correction object, the erroneous correction object in the first correction text is restored to the scan object corresponding to the erroneous correction object, and the second correction text is obtained.

[0017] In one embodiment of the present invention, as described in the aforementioned text correction method, identifying erroneous correction objects that do not meet the preset correction requirements from all candidate correction objects in the first correction text includes at least one of the following:

[0018] If the candidate correction target is a word added to the first correction text, the candidate correction target is determined as the error correction target;

[0019] If the candidate correction object is obtained by performing a replacement operation on any scanned word in the first correction text, and the replacement operation does not meet the preset replacement requirements, the candidate correction object is determined as the error correction object, wherein the scanned object includes scanned words;

[0020] If the candidate correction object is obtained by performing part-of-speech correction on any scanned word in the first correction text, the candidate correction object is determined as the error correction object;

[0021] If the candidate correction object is obtained by replacing any scanned punctuation mark in the first correction text, the candidate correction object is determined as the error correction object, wherein the scanned object includes scanned punctuation marks.

[0022] In one embodiment of the present invention, as described in the foregoing text correction method, before inputting the scanned text into a lightweight BERT language model to obtain the target language features of the scanned text, the method further includes:

[0023] According to the error logs reported by users, the obtained data can be divided into first training data and first verification data. Both the first training data and the first verification data include a one-to-one corresponding first error object and a first correct object.

[0024] Based on the one-to-one correspondence between the first erroneous object and the first correct object, the error characteristic pattern is obtained;

[0025] Based on the error characteristic patterns, a corpus dataset that meets the preset text scanning scenario is determined in the target database, wherein the target database includes multiple corpus datasets;

[0026] The corpus dataset is divided into a first corpus data subset and a second corpus data subset;

[0027] Using the first subset of corpus data and the error feature patterns, second training data is obtained, wherein the second training data includes a one-to-one correspondence of a second error object and a second correct object.

[0028] In one embodiment of the present invention, as described in the foregoing text correction method, after determining a corpus dataset satisfying a preset text scanning scenario in the target database based on the error feature patterns, the method further includes:

[0029] The standard BERT model is trimmed to obtain a lightweight BERT model that meets the preset parameter requirements and removes the forward output layer.

[0030] The lightweight BERT model to be trained is trained using the second subset of corpus data to obtain a pre-trained lightweight BERT model, wherein the corpus included in the second subset of corpus data meets the preset corpus requirements.

[0031] In one embodiment of the present invention, as described in the foregoing text correction method, after training the lightweight BERT model to be trained using the second corpus data subset to obtain a pre-trained lightweight BERT model, the method further includes:

[0032] After the pre-trained lightweight BERT model, a training error detection module and a training correction module are added in sequence to obtain the training model. The error detection module is used to identify the error objects in the scanned text based on the language features obtained after the pre-trained lightweight BERT model is input into the text. The correction module is used to identify the correction objects for correcting the error objects based on the language features.

[0033] The model to be trained is trained using the first training data and the second training data to obtain the trained model.

[0034] After verifying the trained model using the first verification data and determining that the trained model meets the preset accuracy, a target error checking module and a target correction module are identified in the trained model.

[0035] In one embodiment of the present invention, as described in the foregoing text correction method, the step of performing a first correction operation on the scanned text according to the target language features to obtain a first corrected text includes:

[0036] The target error checking module determines the predicted error objects in the scanned text according to the target language characteristics;

[0037] The target correction module determines candidate correction objects for correcting the predicted error objects based on the target language features.

[0038] The first corrected text is obtained by replacing the predicted error object with the candidate corrected object.

[0039] In a second aspect of the present invention, a text correction device is provided, comprising:

[0040] The acquisition module is used to acquire the scanned text obtained from scanning the target object;

[0041] The feature module is used to input the scanned text into a lightweight BERT language model to obtain the target language features of the scanned text, wherein the number of parameters of the lightweight BERT language model is less than the number of parameters of the standard BERT model.

[0042] The first correction module is used to perform a first correction operation on the scanned text according to the target language features to obtain the first corrected text.

[0043] The second correction module is used to obtain a second corrected text after the scanned text has been corrected, based on the first corrected text.

[0044] According to an embodiment of the present invention, by inputting the scanned text into a lightweight BERT language model to obtain the target language features of the scanned text, and by making the number of parameters of the lightweight BERT language model less than the preset number of parameters of the standard BERT model, the method can be applied to application scenarios such as dictionary pens that require lightweight design. At the same time, a first correction operation is performed on the scanned text according to the target language features to obtain a first corrected text. Error correction can be performed on the scanned text based on the lightweight BERT language model to obtain the first corrected text. Finally, a second corrected text is obtained based on the first corrected text. This overcomes the technical problem that there is no suitable lightweight offline OCR recognition result correction technology in related technologies. Attached Figure Description

[0045] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description taken in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated in the drawings by way of example and not limitation, wherein:

[0046] Figure 1 A schematic flowchart of a text correction method according to an embodiment of the present invention is shown.

[0047] Figure 2 A schematic diagram illustrating scanning using a dictionary pen according to an embodiment of the present invention is shown.

[0048] Figure 3 A schematic diagram illustrating scanning using a dictionary pen according to yet another embodiment of the present invention is shown.

[0049] Figure 4 A schematic diagram illustrating scanning using a dictionary pen according to another embodiment of the present invention is shown.

[0050] Figure 5 A schematic diagram illustrating text calibration using a text correction model according to an embodiment of the present invention is shown.

[0051] Figure 6 This is a schematic illustration of a text correction device according to an exemplary embodiment of the present invention;

[0052] Figure 7 This is a schematic illustration of an electronic device according to an exemplary embodiment of the present invention;

[0053] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation

[0054] The principles and spirit of the invention will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are given merely to enable those skilled in the art to better understand and implement the invention, and are not intended to limit the scope of the invention in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art. Invention Overview

[0056] The inventors have discovered that when users scan text with a dictionary pen, OCR recognition results sometimes exhibit errors, including over-recognition or under-recognition. This is particularly prevalent when scanning "words within a sentence." A "word within a sentence" refers to a single word within a complete sentence. When scanning such words, users often fail to accurately scan the desired word into the dictionary pen. Either the pen scans part or all of the words preceding and following the target word, or the target word is scanned incompletely. For example, as shown... Figure 2 As shown, when the user scanned the word "promotion" with the dictionary pen, parts of the words before and after it were scanned, but the word "forecasting" was not scanned completely.

[0057] This invention provides a text correction method, comprising: acquiring scanned text obtained by scanning a target object; inputting the scanned text into a lightweight BERT language model to obtain target language features of the scanned text, wherein the number of parameters of the lightweight BERT language model is less than the preset number of parameters of the standard BERT model; performing a first correction operation on the scanned text according to the target language features to obtain a first corrected text; and obtaining a second corrected text based on the first corrected text. In this way, the dictionary pen only needs to be adapted to the scanning scenario used for scanning, such as textbooks, exercise books, picture books, and newspapers. Therefore, a single dictionary pen can be adapted to the candidate words of the scenarios involved, thus overcoming the problem that there is no suitable lightweight offline OCR recognition result correction technology in related technologies.

[0058] After introducing the basic principles of the present invention, various non-limiting embodiments of the present invention will be described in detail below.

[0059] Application Scenarios Overview

[0060] In this embodiment, the text correction method described above can be applied to a hardware environment consisting of a terminal and / or a server. The server connects to the terminal via a network and can be used to provide services to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services to the server.

[0061] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth.

[0062] First, the embodiments of the present invention can be implemented in various application scenarios. These scenarios include terminals and / or servers. Terminals can be mobile terminals, such as dictionary pens, mobile phones, tablets, laptops, personal digital assistants, and other mobile electronic devices, or desktop computers. Servers can be independent servers or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Communication between the terminal and the server can be established, for example, via mobile internet.

[0063] The text correction process can be performed on the server side or the terminal side. More specifically, for example, software for text correction can be installed on a dictionary pen (i.e., one type of optional terminal). The user obtains the scanned text obtained by scanning the target object through the text correction software on the dictionary pen; and then obtains a second corrected text after the scanned text has been corrected. This achieves the goal of providing a lightweight, offline OCR recognition result correction technology.

[0064] Exemplary methods

[0065] The following section, in conjunction with the above application scenarios, provides reference... Figure 1 This description outlines a text correction method according to exemplary embodiments of the present invention. It should be noted that the above application scenarios are shown only to facilitate understanding of the spirit and principles of the invention, and the embodiments of the invention are not limited in any way. Rather, the embodiments of the invention can be applied to any applicable scenario.

[0066] This invention is applicable to scenarios involving text correction using dictionary pens, but is not limited thereto.

[0067] For example, see Figure 1The diagram shown is a flowchart of a text correction method according to an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:

[0068] Step S101: Obtain the scanned text obtained by scanning the target object.

[0069] Optional, such as Figure 2 As shown, the dictionary pen's text scanning sensor can scan the target object to obtain the scanned text.

[0070] The target object can be a printed document, such as a textbook, workbook, picture book, or newspaper. It can also be a display screen used for e-books or to display documents.

[0071] Step S102: Input the scanned text into the lightweight BERT language model to obtain the target language features of the scanned text. The lightweight BERT language model has fewer parameters than the standard BERT model.

[0072] After obtaining the scanned text, it can be input into a specific language model to obtain the language features of the scanned text.

[0073] In this embodiment, the target language features corresponding to the scanned text can be obtained by inputting the scanned text into a lightweight BERT language model.

[0074] In this embodiment, the lightweight BERT language model has fewer parameters than the standard BERT model. For example, when the standard BERT model has 100M parameters, the lightweight BERT language model can have 10M, 15M, etc. Furthermore, the number of parameters in the lightweight BERT language model can be adjusted according to the application scenario of the dictionary pen in this application.

[0075] Step S103: Perform a first correction operation on the scanned text according to the target language features to obtain the first corrected text.

[0076] After obtaining the target language features, it is possible to determine whether there are errors in the scanned text based on the target language features. If errors are found, the first correction operation can be performed on the identified errors according to the target language features to obtain the first corrected text.

[0077] Step S104: Based on the first corrected text, obtain the second corrected text after the scanned text has been corrected.

[0078] Since the first corrected text is obtained by correcting the scanned text according to the target language features, and considering that the underlying language model used is a lightweight BERT language model, the language information learned by a lightweight BERT language model is always limited and cannot perfectly cover all language scenarios. Therefore, some errors sometimes occur during the inference of the correction model. These errors can be discovered through test data, and their characteristics are relatively obvious. Therefore, targeted rule optimization can be performed to make the results of the correction model more accurate.

[0079] Then, based on the first corrected text and all the operations included in the first corrected operation, the scanned text needs to be further corrected to obtain the corrected second corrected text.

[0080] The method in this embodiment, by inputting the scanned text into a lightweight BERT language model, obtains the target language features of the scanned text. The lightweight BERT language model has fewer parameters than the standard BERT model, making the method applicable to lightweight applications such as dictionary pens. Simultaneously, a first correction operation is performed on the scanned text according to the target language features to obtain the first corrected text. Error correction is then performed on the scanned text based on the lightweight BERT language model to obtain the first corrected text, and finally, a second corrected text is obtained based on the first corrected text. This overcomes the technical problem that there is no suitable lightweight offline OCR recognition result correction technology in related technologies.

[0081] As an optional implementation, as described in the aforementioned text correction method, step S104, which obtains the second corrected text after correcting the scanned text based on the first corrected text, includes the following steps:

[0082] Step S201: Among all candidate correction objects in the first correction text, identify erroneous correction objects that do not meet the preset correction requirements. The candidate correction objects are those that are replaced, added, or deleted from the scanned objects in the scanned text during the first correction operation.

[0083] Optionally, preset correction requirements can be determined in advance.

[0084] After the first correction operation is performed, the candidate correction objects are replaced, added, or deleted, and there may be erroneous candidate correction objects that do not meet the preset correction requirements. Candidate correction objects can be characters, words, or punctuation marks.

[0085] Pre-set correction requirements may include at least one requirement that cannot be corrected; for example, they may include one or more of the following:

[0086] Rule 1: If the candidate correction target is a word added in the first correction text, the candidate correction target is identified as an incorrect correction target;

[0087] In other words, this limits modifications that simply add words, because OCR recognition will not miss recognizing entire words.

[0088] Rule 2: If a candidate correction object is obtained by performing a replacement operation on any scanned word in the first correction text, and the replacement operation does not meet the preset replacement requirements, the candidate correction object is determined as an error correction object, wherein the scanned object includes the scanned word.

[0089] The default replacement requirement is that the target characters included in the object before replacement exist in the object after replacement, and the character order of each target character is consistent in the object before replacement and the object after replacement.

[0090] For example, replacing "like" with "love" is not allowed (i.e., it does not meet the default replacement requirements), but replacing "ike" with "like" is allowed (i.e., it meets the default replacement requirements).

[0091] In other words, this restricts the replacement of complete words. This is because OCR recognition will not incorrectly identify complete words.

[0092] Rule 3: If the candidate correction object is obtained by correcting the part-of-speech tag of any scanned word in the first correction text, the candidate correction object shall be identified as an incorrect correction object.

[0093] That is, to restrict the part of speech of words, such as verb tense, singular and plural, and noun singular and plural.

[0094] Rule 4: If a candidate object for correction is obtained by replacing any scanned punctuation mark in the first text to be corrected, the candidate object for correction shall be identified as an error object for correction, wherein the scanned object includes scanned punctuation marks.

[0095] That is, limiting the correction of punctuation marks and other details of the words being corrected.

[0096] Step S202: According to the scan object corresponding to each candidate correction object, restore the erroneous correction object in the first correction text to the scan object corresponding to the erroneous correction object to obtain the second correction text.

[0097] After any of the corrections in rules 1-4 above occurs, the erroneous correction object can be restored to the scan object corresponding to the erroneous correction object according to the scan object corresponding to each candidate correction object and the identified erroneous correction object, thereby obtaining the second corrected text.

[0098] The method in this embodiment can restore the incorrectly corrected object in the first corrected text, thereby improving the accuracy of the correction and avoiding technical problems that affect the user experience caused by incorrect correction.

[0099] As an optional implementation, the text correction method described above, before step S102 where the scanned text is input into the lightweight BERT language model to obtain the target language features of the scanned text, further includes the following steps:

[0100] Step S401: According to the error logs reported by the user, the obtained data can be divided into first training data and first verification data. The first training data and the first verification data each include a first error object and a first correct object.

[0101] Optionally, one could receive error logs from user-reported error-prone scenarios, label the error logs, and divide the resulting data into first training data and first validation data.

[0102] Optionally, both the first training data and the first validation data include a one-to-one correspondence of first error objects and first correct objects. Further, in this embodiment, it is not limited to whether one incorrect word corresponds to one correct word; it can also be an incorrect phrase or sentence corresponding to a correct phrase or sentence. Preferably, the training / validation data consists mostly of phrases or sentences. For example, when arranged according to the first error object and the first correct object, the optional string pairs can be: "I ike-Ilike", "a fow-a few", "I ike football.–I lile football."; when arranged according to the first correct object and the first error object, the optional string pairs can be: "I like-Iike", "a few-a fow", etc.

[0103] Step S402: Based on the one-to-one correspondence between the first erroneous object and the first correct object, obtain the error characteristic pattern.

[0104] After obtaining the first erroneous object and the first correct object that correspond one-to-one, we can analyze the pattern of error occurrence based on this information and obtain the error characteristic pattern.

[0105] The main characteristics of errors include the following:

[0106] 1. Multiple recognition issues caused by factors such as multi-scanning, complex backgrounds, and handwriting interference: for example Figure 2 The "uctpromotion str" segment shown is due to multiple recognitions caused by multiple scanning.

[0107] 2. Insufficient recognition due to factors such as incomplete scanning, complex backgrounds, and handwriting interference: for example Figure 2 The "forecasting" section shown indicates a lack of recognition due to insufficient scanning.

[0108] 3. Misidentification caused by special fonts, incomplete fonts, complex backgrounds, etc.: such as Figure 3 The example shown is an attempt to scan the phrase "Big Pig" using a dictionary pen. Due to the large font size, the scan was incomplete, resulting in incomplete character recognition. And similar examples... Figure 4 The image shows that when scanning "Tales" with a dictionary pen, the letter "l" is recognized as the number "1" due to the artistic font.

[0109] Therefore, the following patterns of error characteristics can be summarized:

[0110] 1. Multiple recognition, mainly when the correct word / sentence has the last letter of another word at the beginning or the first letter of another word at the end.

[0111] 2. Insufficient recognition, mainly because correct words / sentences are missing some of the letters before or after them.

[0112] 3. Misidentification mainly involves the loss or misidentification of some letters in the correct word, such as misidentifying y as v, or confusing I / 1 / l.

[0113] Step S403: Based on the error feature patterns, determine the corpus dataset that meets the preset text scanning scenario in the target database, wherein the target database includes multiple corpus datasets;

[0114] Once the error pattern is identified, the expected data for the text scanning scenarios most frequently scanned by users can be obtained from the target database based on this error pattern, thus obtaining the expected dataset.

[0115] Text scanning scenarios could include, for example, scanning too many or missing texts.

[0116] Step S404: Divide the corpus dataset into a first corpus data subset and a second corpus data subset;

[0117] After obtaining the expected dataset, it can be divided into a first subset of corpus data and a second subset of corpus data; optionally, the amount of data in the first subset of corpus data and the second subset of corpus data can be the same or different.

[0118] Step S405: Using the subset of the first corpus data and the error feature patterns, the second training data is obtained, wherein the training data includes a one-to-one correspondence of the second error object and the second correct object.

[0119] After obtaining the first expected data subset, the data can be synthesized based on the aforementioned error characteristic patterns to obtain the second training data, which includes a one-to-one correspondence of the second error object and the second correct object.

[0120] As an optional implementation, the text correction method described above, after determining the corpus dataset that meets the preset text scanning scenario in the target database based on the error feature rules in step S403, the method further includes the following steps:

[0121] Step S501: Prune the standard BERT model to obtain a lightweight BERT model that meets the preset parameter requirements and removes the forward output layer.

[0122] To obtain a lightweight BERT model, the original standard BERT model needs to be processed. In this embodiment, the standard BERT model is trimmed to obtain the lightweight BERT model to be trained.

[0123] In order for the obtained lightweight BERT model to be trained to meet the requirements of lightweight design, the lightweight BERT model to be trained needs to meet the preset parameter requirements and its forward output layer can be deleted.

[0124] The preset parameter requirement can be information used to indicate the maximum number of parameters. For example, 12M indicates that the number of parameters in the lightweight BERT model to be trained cannot exceed 12M.

[0125] In the schematic diagram of text calibration using the text correction model that implements the method of the aforementioned embodiments, the forward output layer is the output forward layer in the standard BERT model.

[0126] Step S502: Train the lightweight BERT model to be trained using the second corpus data subset to obtain a pre-trained lightweight BERT model, wherein the corpus contained in the second corpus data subset meets the preset corpus requirements.

[0127] After obtaining the lightweight BERT model to be trained, the model can be trained using the data from the second corpus subset obtained in the aforementioned embodiment, and the trained model is recorded as the pre-trained lightweight BERT model.

[0128] The second subset of corpus data must meet the following preset requirements: it must contain a certain amount of Chinese and mixed Chinese-English corpus.

[0129] As an optional implementation, such as the aforementioned text correction method, after step 502, where the lightweight BERT model to be trained is trained using a subset of the second corpus data to obtain a pre-trained lightweight BERT model, the method further includes the following steps:

[0130] Step S601: After the pre-trained lightweight BERT model, a training error checking module and a training correction module are added in sequence to obtain the training model. The error checking module is used to identify the error objects in the scanned text based on the language features obtained after the pre-trained lightweight BERT model is input into the text. The correction module is used to identify the correction objects for correcting the error objects based on the language features.

[0131] After obtaining the pre-trained lightweight BERT model, the features of the language input into the pre-trained lightweight BERT model can be obtained. In order to achieve the purpose of error detection and correction, an error detection module and an error correction module to be trained are added sequentially after the pre-trained lightweight BERT model to obtain the model to be trained.

[0132] like Figure 5 As shown, the error checking module is used to identify error objects (i.e., ion, ike, and fow) in the scanned text based on the language features obtained after pre-training the lightweight BERT model from the text input. The correction module is used to identify correction objects (i.e., correction of ion) based on the language features. <del>(That is, delete), ike is corrected to like, fow is corrected to few).

[0133] Step S602: Train the model to be trained using the first training data and the second training data to obtain the trained model.

[0134] Step S603: After verifying the trained model with the first verification data and confirming that the trained model meets the preset accuracy, the target error checking module and the target correction module are determined in the trained model.

[0135] The first training data and the second training data for training have been obtained from the foregoing embodiments. Therefore, the model to be trained can be trained using the first training data and the second training data to obtain the trained model.

[0136] After obtaining the trained model, it can be validated. In this embodiment, the trained model is validated using the first validation data obtained in the previous embodiment, and the corresponding validation results can be obtained.

[0137] If the training model meets the preset accuracy (e.g., 95%, 98%, etc.) based on the verification results, the target error checking module and the target correction module are determined in the training model.

[0138] As an optional implementation method, as described above, step S103 performs a first correction operation on the scanned text according to the target language features to obtain the first corrected text, including the following steps:

[0139] Step S701: The target error checking module identifies the predicted error objects in the scanned text based on the target language characteristics.

[0140] Step S702: The target correction module determines candidate correction objects for correcting the predicted erroneous objects based on the target language characteristics.

[0141] Step S703: Replace the predicted error object with the candidate correction object to obtain the first correction text.

[0142] As is known from the foregoing embodiments, the target error detection module and the target correction module have been trained. Therefore, the target error detection module can determine the predicted error objects in the scanned text according to the target language features output by the lightweight BERT model.

[0143] The predicted error object can be the error object identified by the target error checking module.

[0144] The target correction module can also obtain the target language features mentioned above, and then determine the candidate correction objects for correcting the predicted erroneous objects based on the target language features.

[0145] After obtaining the candidate correction object and the predicted error object, the predicted error object can be replaced by the candidate correction object to obtain the first correction text.

[0146] The following describes an application example that applies any of the foregoing embodiments:

[0147] like Figure 5 The proposed solution is mainly divided into two modules: the BERT language model module and the error checking and correction module (i.e., including both error checking and correction modules). The BERT language model module is the aforementioned lightweight BERT model, suitable for deployment on low-computing-power offline platforms. The error checking and correction module adds an optimized correction algorithm suitable for dictionary pen scenarios to the GECToR error detection and correction head.

[0148] This application example method is divided into two main phases: training and inference. In the training phase, this solution mainly involves data annotation and synthesis, pre-training of the ultra-lightweight BERT language model, and training of the error checking and correction module. The training phase can be performed on a server or PC and does not involve offline inference. In the inference phase, the main focus is on model pruning and the design of correction optimization algorithms suitable for dictionary pen scenarios.

[0149] 1. Training Phase

[0150] 1.1 Data Labeling and Synthesis

[0151] Based on error logs from user-reported error-prone scenarios (i.e., preset text scanning scenarios), annotations are generated to obtain string pairs (DataMP) of erroneous and correct text (i.e., a one-to-one correspondence of the first error object and the first correct object). Analysis of these annotated data reveals patterns in frequently misspelled words and errors involving over- or under-recognition.

[0152] Based on the error patterns identified in the above analysis, a corpus of data (DataS) representing the scenarios most frequently scanned by users was collected. This corpus was divided into two subsets: A (DataS-A, i.e., the first subset of the corpus) and B (DataS-B, i.e., the second subset of the corpus). Using this DataS-A data and the pattern recognition, string pairs of erroneous and correct texts (DataGP, i.e., the second training data) were synthesized.

[0153] 1.2 Ultra-lightweight BERT language model pre-training:

[0154] To adapt to offline scenarios such as dictionary pens, an ultra-lightweight BERT model (Bert-Tiny, i.e., a lightweight BERT model to be trained) was obtained by tailoring the standard BERT model. It has only 10.72M parameters and a computational cost of only 100.97MFlops. To enable the model to adapt to mixed Chinese and English scenarios, the pre-training corpus dataset DataS-B contains a certain amount of Chinese and mixed Chinese-English corpora (i.e., meets the preset corpus requirements).

[0155] 1.3 Correction Model Training:

[0156] Based on the pre-trained model from step 1.2, the correction model was trained using DataMP and DataGP. The training objective was primarily to add, delete, and modify erroneous parts.

[0157] 2. Reasoning Stage

[0158] 2.1 Model trimming

[0159] Because the vocabulary of the string tokenization part of the trained correction model (i.e., the BERT language model pre-encodes and tokenizes the language) is too long, a significant portion of which is rarely used or even never used in real-world scenarios, the weights of the string tokenization part were appropriately pruned based on the data from DataMP and DataS-A corpora. This significantly accelerated the model's inference speed on offline devices.

[0160] 2.2 Design of Correction and Optimization Algorithm Applicable to Dictionary Pen Scenarios

[0161] Given that the underlying language model used is a very lightweight BERT model, the linguistic information it learns is always limited and cannot perfectly cover all language scenarios. Therefore, some errors sometimes occur during the inference process of the correction model. These errors can be detected through test data, and their characteristics are quite obvious. Therefore, targeted rule optimization can be performed to make the results of the correction model more accurate.

[0162] The general rules are as follows:

[0163] Rule 1: Limit modifications that simply add words. This is because OCR recognition will not miss recognizing entire words.

[0164] Rule 2: Restrict the replacement of other complete words (i.e., when the candidate for correction is obtained by performing a replacement operation on any scanned word in the first correction text, and the replacement operation does not meet the preset replacement requirements). This is because the OCR recognition result will not incorrectly recognize complete words.

[0165] Rule 3: Restrict word part-of-speech correction, such as verb tenses, singular / plural forms, and noun singular / plural forms. The reason is the same as above.

[0166] Rule 4: Limit the correction of punctuation marks and other details of the words being corrected.

[0167] Exemplary device

[0168] After introducing the method of exemplary embodiments of the present invention, the following references are made. Figure 6 A text correction device according to an exemplary embodiment of the present invention includes:

[0169] Module 1 is used to acquire the scanned text obtained by scanning the target object;

[0170] Feature module 2 is used to input the scanned text into the lightweight BERT language model to obtain the target language features of the scanned text. The lightweight BERT language model has fewer parameters than the standard BERT model.

[0171] The first correction module 3 is used to perform a first correction operation on the scanned text according to the target language features to obtain the first corrected text.

[0172] The second correction module 4 is used to obtain the second corrected text after the scanned text has been corrected, based on the first corrected text.

[0173] It should be noted that the acquisition module 1 in this embodiment can be used to perform the above step S101, the feature module 2 in this embodiment can be used to perform the above step S102, the first correction module 3 in this embodiment can be used to perform the above step S103, and the second correction module 4 in this embodiment can be used to perform the above step S104.

[0174] In addition to the modules described above, the apparatus in this embodiment may also include modules that perform any method in any of the aforementioned text correction methods.

[0175] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules, as part of the device, can operate in ways such as... Figure 1 The method shown can be implemented in either software or hardware within a hardware environment, where the hardware environment includes a network environment.

[0176] As an optional implementation, the second correction module 4, as described above, includes:

[0177] The determination submodule is used to identify erroneous correction objects that do not meet the preset correction requirements from all candidate correction objects in the first correction text. The candidate correction objects are the objects that are replaced, added, or deleted from the scanned text during the first correction operation.

[0178] The restoration submodule is used to restore the erroneous correction objects in the first correction text to the corresponding scan objects according to the scan objects corresponding to each candidate correction object, so as to obtain the second correction text.

[0179] As an alternative implementation, the apparatus described above, the determining submodule is used to perform at least one of the following:

[0180] If the candidate to be corrected is a word added in the first text to be corrected, the candidate to be corrected will be identified as an incorrect correction target.

[0181] If the candidate correction object is obtained by performing a replacement operation on any scanned word in the first correction text, and the replacement operation does not meet the preset replacement requirements, the candidate correction object is determined as an error correction object, wherein the scanned object includes scanned words;

[0182] If the candidate correction object is obtained by correcting the part-of-speech tag of any scanned word in the first correction text, the candidate correction object will be identified as an incorrect correction object.

[0183] If the candidate correction object is obtained by replacing any scanned punctuation mark in the first correction text, the candidate correction object is determined as the error correction object, wherein the scanned object includes scanned punctuation marks.

[0184] As an optional implementation, the apparatus as described above further includes a data acquisition module for:

[0185] According to the error logs reported by users, the obtained data can be divided into first training data and first verification data. Both the first training data and the first verification data include a one-to-one corresponding first error object and a first correct object.

[0186] Based on the one-to-one correspondence between the first erroneous object and the first correct object, the error characteristic pattern is obtained;

[0187] Based on the error characteristics, a corpus dataset that meets the preset text scanning scenario is determined in the target database. The target database includes multiple corpus datasets.

[0188] The corpus dataset is divided into a first subset of corpus data and a second subset of corpus data;

[0189] Using a subset of the first corpus data and the error feature patterns, second training data is obtained, which includes a one-to-one correspondence of second error objects and second correct objects.

[0190] As an optional implementation, the apparatus as described above further includes a BERT model preprocessing module for:

[0191] The standard BERT model is trimmed to obtain a lightweight BERT model that meets the preset parameter requirements and removes the forward output layer.

[0192] The lightweight BERT model to be trained is trained using a second subset of the corpus data to obtain a pre-trained lightweight BERT model. The corpus contained in the second subset of the corpus data meets the preset corpus requirements.

[0193] As an optional implementation, the apparatus as described above further includes a training module for:

[0194] After the pre-trained lightweight BERT model is completed, a training error detection module and a training correction module are added in sequence to obtain the training model. The error detection module is used to identify the error objects in the scanned text based on the language features obtained after the pre-trained lightweight BERT model is input into the text. The correction module is used to identify the correction objects for correcting the error objects based on the language features.

[0195] The model to be trained is trained using the first training data and the second training data to obtain the trained model.

[0196] After verifying the trained model with the first validation data and confirming that the trained model meets the preset accuracy, the target error checking module and the target correction module are determined in the trained model.

[0197] As an optional implementation, in the aforementioned apparatus, the first correction module 3 is used to perform the following steps:

[0198] The target error checking module identifies the predicted error objects in the scanned text based on the characteristics of the target language;

[0199] The target correction module identifies candidate correction objects for correcting predicted errors based on the characteristics of the target language.

[0200] The first corrected text is obtained by replacing the predicted erroneous object with the candidate corrected object.

[0201] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described text correction method is also provided. The electronic device may be a server, a terminal, or a combination thereof.

[0202] According to another embodiment of this application, an electronic device is also provided, comprising: Figure 7 As shown, the electronic device may include: a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.

[0203] Memory 1503 is used to store computer programs;

[0204] When the processor 1501 executes the program stored in the memory 1503, it implements the steps as described in any of the preceding method embodiments.

[0205] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.

[0206] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0207] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0208] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the method steps of the above method embodiments when it runs.

[0209] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0210] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0211] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0212] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0213] It should be noted that although several devices or sub-devices of the text correction apparatus have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of the invention, the features and functions of two or more devices described above can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.

[0214] Furthermore, although the operations of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. Rather, the steps depicted in the flowchart may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0215] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0216] It should be understood that each block of a flowchart and / or block diagram, as well as combinations of blocks in a flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine that, when executed by a computer or other programmable data processing device, creates means for implementing the functions / operations specified in the blocks of the flowchart and / or block diagram.

[0217] These computer program instructions may also be stored in a computer-readable medium that enables a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable medium produce a product comprising instruction means that implement the functions / operations specified in the boxes of a flowchart and / or block diagram.

[0218] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions that execute on the computer or other programmable apparatus can provide a process for implementing the functions / operations specified in the boxes of a flowchart and / or block diagram.

[0219] The use of the verbs "including" and "contains" and their inflections in the application documents does not preclude the existence of elements or steps other than those described in the application documents. The article "a" or "one" preceding an element does not preclude the existence of multiple such elements.

[0220] While the spirit and principles of the invention have been described with reference to several specific embodiments, it should be understood that the invention is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined for benefit; such division is merely for ease of description. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims is to be interpreted in the broadest sense, thereby encompassing all such modifications and equivalent structures and functions.< / del>

Claims

1. A text correction method, characterized in that, Applications to dictionary pens include: Based on the error logs reported by users, the obtained data can be divided into first training data and first verification data. Both the first training data and the first verification data include a one-to-one correspondence of first error objects and first correct objects. Error feature patterns are obtained based on these one-to-one correspondences of the first error objects and first correct objects. According to these error feature patterns, a corpus dataset satisfying a preset text scanning scenario is determined in the target database. The target database includes multiple corpus datasets. The corpus dataset is divided into a first corpus dataset subset and a second corpus dataset subset. Using the first corpus dataset subset and the error feature patterns, second training data is obtained. The second training data includes a one-to-one correspondence of second error objects and second correct objects. Obtain the scanned text obtained from scanning the target object; The scanned text is input into a lightweight BERT language model to obtain the target language features of the scanned text, wherein the number of parameters of the lightweight BERT language model is less than the number of parameters of the standard BERT model. Performing a first correction operation on the scanned text according to the target language features to obtain a first corrected text includes: determining whether there is an error in the scanned text based on the target language features; and, if it is determined that there is an error in the scanned text, performing a first correction operation on the identified error according to the target language features to obtain the first corrected text. Based on the first corrected text, a second corrected text is obtained after the scanned text has been corrected.

2. The method according to claim 1, characterized in that, The step of obtaining a second corrected text based on the first corrected text, after correcting the scanned text, includes: Among all candidate correction objects in the first correction text, erroneous correction objects that do not meet the preset correction requirements are identified. The candidate correction objects are those that replace, add, or delete the scanned objects in the scanned text during the first correction operation. According to the scan object corresponding to each candidate correction object, the erroneous correction object in the first correction text is restored to the scan object corresponding to the erroneous correction object, and the second correction text is obtained.

3. The method according to claim 2, characterized in that, The step of identifying erroneous correction objects that do not meet the preset correction requirements from all candidate correction objects in the first correction text includes at least one of the following: If the candidate correction target is a word added to the first correction text, the candidate correction target is determined as the error correction target; If the candidate correction object is obtained by performing a replacement operation on any scanned word in the first correction text, and the replacement operation does not meet the preset replacement requirements, the candidate correction object is determined as the error correction object, wherein the scanned object includes scanned words; If the candidate correction object is obtained by performing part-of-speech correction on any scanned word in the first correction text, the candidate correction object is determined as the error correction object; If the candidate correction object is obtained by replacing any scanned punctuation mark in the first correction text, the candidate correction object is determined as the error correction object, wherein the scanned object includes scanned punctuation marks.

4. The method according to claim 1, characterized in that, After determining the corpus dataset that meets the preset text scanning scenario in the target database based on the error feature patterns, the method further includes: The standard BERT model is trimmed to obtain a lightweight BERT model that meets the preset parameter requirements and removes the forward output layer. The lightweight BERT model to be trained is trained using the second subset of corpus data to obtain a pre-trained lightweight BERT model, wherein the corpus included in the second subset of corpus data meets the preset corpus requirements.

5. The method according to claim 4, characterized in that, After training the lightweight BERT model to be trained using the second subset of corpus data to obtain a pre-trained lightweight BERT model, the method further includes: After the pre-trained lightweight BERT model, a training error detection module and a training correction module are added in sequence to obtain the training model. The error detection module is used to identify the error objects in the scanned text based on the language features obtained after the pre-trained lightweight BERT model is input into the text. The correction module is used to identify the correction objects for correcting the error objects based on the language features. The model to be trained is trained using the first training data and the second training data to obtain the trained model. After verifying the trained model using the first verification data and determining that the trained model meets the preset accuracy, a target error checking module and a target correction module are identified in the trained model.

6. The method according to claim 5, characterized in that, The first correction operation performed on the scanned text according to the target language features to obtain the first corrected text includes: The target error checking module determines the predicted error objects in the scanned text according to the target language characteristics; The target correction module determines candidate correction objects for correcting the predicted error objects based on the target language features. The first corrected text is obtained by replacing the predicted error object with the candidate corrected object.

7. A text correction device, characterized in that, Applications to dictionary pens include: One module is used to divide the data obtained from user-reported error logs into first training data and first verification data, wherein both the first training data and the first verification data include a one-to-one correspondence of first error objects and first correct objects; according to the one-to-one correspondence of the first error objects and the first correct objects, error feature patterns are obtained; based on the error feature patterns, a corpus dataset that meets a preset text scanning scenario is determined in the target database, wherein the target database includes multiple corpus datasets; the corpus dataset is divided into a first corpus dataset subset and a second corpus dataset subset; using the first corpus dataset subset and the error feature patterns, second training data is obtained, wherein the second training data includes a one-to-one correspondence of second error objects and second correct objects; The acquisition module is used to acquire the scanned text obtained from scanning the target object; The feature module is used to input the scanned text into a lightweight BERT language model to obtain the target language features of the scanned text, wherein the number of parameters of the lightweight BERT language model is less than the number of parameters of the standard BERT model. The first correction module is used to perform a first correction operation on the scanned text according to the target language features to obtain a first corrected text, including: determining whether there is an error in the scanned text based on the target language features; and if it is determined that there is an error in the scanned text, performing a first correction operation on the identified error according to the target language features to obtain the first corrected text. The second correction module is used to obtain a second corrected text after the scanned text has been corrected, based on the first corrected text.

8. An electronic device comprising a processor, a communication interface, a memory, and a communication bus, wherein, The processor, the communication interface, and the memory communicate with each other via the communication bus, characterized in that... The memory is used to store computer programs; The processor is configured to perform the method steps of any one of claims 1 to 6 by running the computer program stored in the memory.

9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the steps of the method described in any one of claims 1 to 6 when it is run.