A text correction method, apparatus, electronic device and storage medium
By recognizing text confidence levels and using text prediction models to correct text with low confidence levels, the problem of high cost and low efficiency in OCR error correction is solved, improving the accuracy of text correction and user experience.
Patent Information
- Application Number
- CN202211158604.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-09-22
AI Technical Summary
Existing OCR error correction technologies suffer from high labor costs, slow speed, and insufficient generalization performance. Error correction algorithms based on similar word dictionaries also have low efficiency and accuracy.
The image recognition module identifies the confidence level of text, obtains the codes of adjacent text, uses a pre-trained text prediction model to correct text with low confidence, and dynamically updates the recognized content.
It improves the accuracy and efficiency of text correction, enhancing the user reading experience.
Smart Images

Figure CN115455940B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a text error correction method and device, electronic equipment and storage medium. BACKGROUND
[0002] With the continuous development of robotic process automation, artificial intelligence technology liberates people from tedious electronic document tasks, and optical character recognition (OCR) recognition technology is a technical means that can achieve this process. However, due to image tilt, wrinkles, shadows, watermarks, and occlusions, the OCR technology may have text recognition errors.
[0003] Currently, there are two ways to implement OCR text correction. The first way is manual correction, that is, manually identifying and correcting the incorrect text of the OCR output result. The second way is to use a machine learning algorithm to implement OCR text correction. Most existing OCR correction algorithms use a homophone dictionary language model for correction.
[0004] However, the first way has the problem of high labor cost and slow speed, and cannot achieve accurate correction of large-scale text. The second way has the problem of correcting based on a homophone dictionary, which requires a good and comprehensive homophone dictionary. If the dictionary does not exist, it is difficult to correct, so the generalization performance is not good enough, resulting in relatively low efficiency and accuracy of text correction. SUMMARY
[0005] The present application provides a text error correction method, device, electronic equipment and storage medium, which narrows the prediction range of correct text in the text error correction process, plays a guiding role in text prediction, improves the accuracy and efficiency of text error correction, and improves the fluency of users reading text.
[0006] In a first aspect, the present application provides a text error correction method, which comprises:
[0007] identifying text information and a confidence level of the text information in the image to be processed based on an image recognition module;
[0008] When it is detected that there is text to be corrected with a confidence level lower than a preset confidence threshold, at least two recognized texts adjacent to the text to be corrected are obtained;
[0009] According to at least one selected text associated with the text to be corrected, the text to be corrected corresponding to the text to be corrected is determined;
[0010] determine the target sentence code based on the recognized character code corresponding to each recognized character and the error correction character code;
[0011] input the target sentence code into the character prediction model trained in advance to obtain a target sentence; wherein the target sentence includes a predicted character corresponding to the error correction character;
[0012] replace the error correction character with the predicted character in the target sentence.
[0013] In a second aspect, the present application provides a text error correction device, which comprises:
[0014] a confidence determination module configured to determine the confidence of the character information recognized by the image recognition module from the image to be processed;
[0015] an error correction character acquisition module configured to acquire at least two recognized characters adjacent to the error correction character when it is detected that there is an error correction character with a confidence lower than a preset confidence threshold;
[0016] an error correction character code determination module configured to determine the error correction character code corresponding to the error correction character according to at least one selected character associated with the error correction character;
[0017] a target code determination module configured to determine the target sentence code based on the recognized character code corresponding to each recognized character and the error correction character code;
[0018] a target sentence determination module configured to input the target sentence code into the character prediction model trained in advance to obtain a target sentence; wherein the target sentence includes a predicted character corresponding to the error correction character;
[0019] a predicted character replacement module configured to replace the error correction character with the predicted character in the target sentence.
[0020] In a third aspect, the present application provides a text error correction electronic device, which comprises:
[0021] at least one processor; and
[0022] a memory in communication connection with the at least one processor; wherein,
[0023] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the text error correction method of any embodiment of the present application.
[0024] In a fourth aspect, the present application provides a computer readable storage medium storing computer instructions for causing a processor to implement the method of text correction of any of the embodiments of the present application when executed.
[0025] In a fifth aspect, the present application provides a computer program product comprising a computer program for implementing the method of text correction of any of the embodiments of the present application when executed by a processor.
[0026] The embodiments of the present application provide a text correction method. The image recognition module is used to recognize the text information in the image to be processed and the confidence of the text information. When it is detected that there is text to be corrected with a confidence lower than a preset confidence threshold, a plurality of recognized texts adjacent to the text to be corrected are obtained. Then, according to at least one selected text associated with the text to be corrected, the text code corresponding to the text to be corrected is determined. Then, based on the recognized text code corresponding to each recognized text and the text code of the text to be corrected, the target sentence code is determined. The target sentence code is input into the text prediction model trained in advance to obtain the target sentence including the predicted text corresponding to the text to be corrected. Finally, the text to be corrected is replaced by the predicted text in the target sentence. The technical scheme provided by the embodiments of the present application solves the technical problems of high cost and low efficiency in the process of realizing text correction by manual correction and machine learning algorithm. In the text recognition process, the text to be corrected is determined based on the confidence of the extracted text, and then the text to be corrected is corrected. Finally, the correct text information is displayed. Or, after the text is converted, the content of the text recognition can be dynamically updated in the process of reading the text, and the wrong word recognition is corrected, which improves the accuracy and efficiency of text correction and improves the user's reading experience of the text.
[0027] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0029] Figure 1 A flowchart of a text correction method provided for the first embodiment of the present application;
[0030] A flowchart of a text correction method provided for the first embodiment of the present application;Figure 2 A flow chart of a text correction method provided for the second embodiment of the present application;
[0031] Figure 3 A flow chart of a text correction method provided for the third embodiment of the present application;
[0032] Figure 4 A structural schematic diagram of a text correction device provided for the fourth embodiment of the present application;
[0033] Figure 5 A structural schematic diagram of an electronic device provided for the fifth embodiment of the present application. DETAILED DESCRIPTION
[0034] In order to make the personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the personnel in the art without creative labor should belong to the protection scope of the present application.
[0035] It should be noted that the terms "first preset condition", "second preset condition" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0036] Embodiment one
[0037] Figure 1 A flow chart of a text correction method provided for the first embodiment of the present application; the present embodiment can be applicable to the case of correcting the text recognized by an automatic device. The method can be executed by a text correction device, which can be realized in the form of hardware and / or software, and can be configured on a computer device, which can be a notebook, a desktop computer, a smart tablet and the like. As shown in the figure, the method comprises: Figure 1
[0038] S110, identify the text information in the image to be processed and the confidence of the text information based on the image recognition module.
[0039] The image recognition module can be a neural network model and can be obtained by pre-training. The image to be processed is an image carrying text content, which needs to be recognized. The text information is the text content in the image to be processed. The confidence is a numerical information, which represents the degree of correctness of the text recognized by the image recognition module.
[0040] Specifically, the image to be processed carrying text content can be captured by a camera configured on a mobile terminal device, or pre-acquired. The image to be processed is input into a pre-determined image recognition module, and the text information in the image to be processed and the confidence value corresponding to each text can be obtained. The confidence value of the text information can represent the degree of correctness of the text recognized by the image recognition module. The larger the value, the greater the probability that the text recognized by the image recognition module is correct; the smaller the value, the smaller the probability that the text recognized by the image recognition module is correct.
[0041] For example, the text content contained in the image to be processed is "text correction method". The image to be processed is input into the image recognition module, and the output result of the image recognition module is: text, confidence 95%; wood, confidence 10%; correct, confidence 96%; measure, confidence 16%; square, confidence 90%; method, confidence 85%.
[0042] Further, after determining the text information and the confidence of the text information, the following steps are further included:
[0043] The text to be corrected with a confidence lower than a pre-set confidence threshold is displayed differently on the display interface.
[0044] The confidence threshold is a pre-set value for screening the text to be corrected. The text to be corrected is determined according to the confidence threshold. If the confidence corresponding to the text is lower than the confidence threshold, the text is determined as the text to be corrected.
[0045] Specifically, according to the pre-determined confidence threshold, the text to be corrected can be screened. If the confidence corresponding to the text is lower than the confidence threshold, the text is determined as the text to be corrected. If the confidence corresponding to the text is higher than the confidence threshold, the text is not determined as the text to be corrected. The determined text to be corrected is displayed differently on the display interface, for example, the text to be corrected can be highlighted, displayed in a different text color or marked with an underline.
[0046] S120. When detecting that there are words to be corrected with a confidence level lower than the preset confidence threshold, obtain at least two recognized words adjacent to the words to be corrected.
[0047] Here, "adjacent" refers to the words on the left and right of the words to be corrected. The determined adjacent recognized words and the words to be corrected can form a sentence. For example, when determining the adjacent recognized words, take the punctuation marks on the left and right of the sentence where the words to be corrected are located as the boundaries, and obtain the words between the punctuation marks on the left and right of the sentence where the words to be corrected are located. The recognized words can include all the text information in the to-be-processed image recognized by the image recognition module. The number of recognized words can be two or more. To improve the accuracy and efficiency of determining text correction, the number of recognized words can be multiple, so as to determine the correct replacement words for the words to be corrected based on multiple recognized words.
[0048] Specifically, when detecting that the confidence level corresponding to a word is lower than the confidence threshold and determining it as a word to be corrected, at least two recognized words adjacent to this word to be corrected can be obtained. For example, the word on the left of the word to be corrected and the adjacent word on the right can be obtained, or the recognized words adjacent to the word to be corrected can be determined with the nearest punctuation mark as the boundary.
[0049] Optionally, the method of determining recognized words can also include: obtaining at least two recognized words of the sentence to which the words to be corrected belong; or, taking the words to be corrected as the starting point, obtaining a preset number of words before and after the words to be corrected to obtain at least two recognized words.
[0050] Exemplarily, assume that the preset confidence threshold is 90%. The text content included in the to-be-processed image is "Text correction method, which has a wide range of applications". After being processed by the image recognition module: the confidence level of "措" is 16%, and the confidence levels corresponding to the rest of the words are all greater than the preset confidence threshold of 90%. At this time, "措" can be used as the word to be corrected. When detecting that there is a word to be corrected "措", obtain 3 words adjacent to the left of the word to be corrected and 2 words adjacent to the right as: "文本纠措方法"; or determine the recognized words adjacent to the word to be corrected with the nearest punctuation mark as the boundary. It can be known that the nearest punctuation mark to "措" is ",", then the recognized words adjacent to the word to be corrected are determined as: "文本纠措方法".
[0051] S130. Determine the error correction word code corresponding to the word to be corrected according to at least one selectable word associated with the word to be corrected.
[0052] Among them, the text to be selected is the text that has an associated relationship with the text to be corrected. It can be text with similar pronunciations, such as cobra and elapidae; text with similar glyphs, such as kaoliang and gaoliang; text with reversed word order, such as peace and placidity; text that does not conform to common sense content, such as Haizhu District, Guangzhou and Haizhu District, Shenzhen, etc. The encoding of the text to be corrected is the encoded content obtained by encoding multiple texts to be selected that are associated with the text to be corrected, and can be represented in the form of a vector. The encoded content corresponding to each character is different. In order to distinguish which character belongs to a specific sentence, position encoding information and segmentation encoding information need to be added. Therefore, the specific content of the encoding of the text to be corrected can include three aspects: the encoding information of the text to be corrected, for example, the text to be corrected can be an encoded vector of a specified length; position encoding, which represents the position information of the text to be corrected in the target sentence to which it belongs, and can be represented by a data number; segmentation encoding. In order to enhance the adaptability of the model to handle tasks, many downstream tasks are processed in one model. Therefore, there may be two target sentences in one model. The segmentation encoding can represent which of the two target sentences the current text to be corrected belongs to.
[0053] Specifically, since there may be multiple texts that have an associated relationship with the text to be corrected, each text to be selected can be encoded, and finally the encoded content including all the texts to be selected that are associated with the text to be corrected is obtained and output in the form of a vector. Different identification positions of the vector can represent different information contents.
[0054] Exemplarily, in the sentence "Text error correction method, which has a wide range of applications", "cuo" is the text to be corrected. The texts to be selected that have an associated relationship with the text to be corrected can be: "错 (错)", "蹉 (蹉)", "借 (借)", "醋 (醋)", etc. These four texts to be selected can be encoded respectively, and finally the encoded content including the four texts to be selected of "错 (错)", "蹉 (蹉)", "借 (借)", and "醋 (醋)" is obtained. The determined encoded content can be output in the form of a vector. Different identification positions of the vector can represent different information contents.
[0055] S140. Determine the target sentence encoding based on the encoded text of the recognized characters and the encoded text of the text to be corrected.
[0056] Among them, the target sentence encoding is the encoding obtained by splicing the encoded text of the text to be corrected and the encoded text of each recognized character in sequence.
[0057] Specifically, each of the recognized characters is coded, each of the recognized characters has a corresponding recognized character code, and each of the recognized character codes is different. Since the position of each recognized character in the determined context and paragraph is different, and the position of the to-be-corrected character in the context and paragraph is fixed, the to-be-corrected character code and the recognized character code corresponding to each recognized character are spliced in order to obtain the target sentence code.
[0058] S150, input the target sentence code into the pre-trained character prediction model to obtain a target sentence.
[0059] The target sentence includes a predicted character corresponding to the to-be-corrected character.
[0060] The character prediction model can be a trained BERT Masked Language Model. The target sentence includes a predicted character corresponding to the to-be-corrected character determined by the character prediction model. The predicted character is one of the to-be-selected characters.
[0061] Specifically, the target sentence code is input into the pre-trained character prediction model, and the character prediction model can output a target sentence including a predicted character corresponding to the to-be-corrected character. The main work of the character prediction model is to predict a predicted character corresponding to the to-be-corrected character from a plurality of to-be-selected characters, and then obtain a target sentence including a predicted character corresponding to the to-be-corrected character. During training, the character prediction model can be trained on more relevant corpus to improve the accuracy of the model.
[0062] S160, replace the to-be-corrected character based on the predicted character in the target sentence.
[0063] In a specific application process, the detected to-be-corrected character in the target sentence can be replaced with a predicted character, that is, the prediction result of the character prediction model is used to replace the character corresponding to the to-be-corrected character in the target sentence, and the text correction is completed.
[0064] Optionally, the corresponding predicted character is displayed at the position associated with the to-be-corrected character, so as to replace the to-be-corrected character based on a trigger operation on the predicted character.
[0065] The trigger operation can be performed by a user, and when the user triggers the predicted character corresponding to the display position, the process of replacing the detected to-be-corrected character in the target sentence with the predicted character is completed.
[0066] Specifically, the predicted word determined according to the to-be-corrected word can be displayed near the to-be-corrected word, and the user can determine whether to accept the predicted word corresponding to the to-be-corrected word according to subjective judgment. If the user accepts, the to-be-corrected word in the target sentence can be replaced with the predicted word by triggering the predicted word displayed at the position.
[0067] The technical solution provided in the above embodiment, by means of the image recognition module, the text information in the to-be-processed image and the confidence of the text information are recognized. When it is detected that there is to-be-corrected text with a confidence lower than a pre-set confidence threshold, at least two recognized texts adjacent to the to-be-corrected text are obtained. Then, at least one to-be-selected text associated with the to-be-corrected text is determined according to the at least one to-be-selected text, and a to-be-corrected text code corresponding to the to-be-corrected text is determined based on the at least one to-be-selected text. Further, a target sentence code is determined based on the recognized text code corresponding to each recognized text and the to-be-corrected text code. The target sentence code is input into the text prediction model trained in advance to obtain a target sentence including a predicted word corresponding to the to-be-corrected text. Finally, the to-be-corrected text is replaced based on the predicted word in the target sentence. The technical solution provided in the embodiment of the present application solves the technical problem of high cost and low efficiency in the process of implementing text correction by manual correction and machine learning algorithm. In the text recognition process, the to-be-corrected text is determined based on the confidence, and then the to-be-corrected text is corrected. Finally, the correct text information is displayed. Alternatively, after the text is converted, the content of the text recognition can be dynamically updated in the process of reading the text by combining the confidence of each word to correct the recognized wrong words, thereby improving the accuracy and efficiency of text correction and improving the user's reading experience of the text.
[0068] Embodiment Two
[0069] Figure 2 A flowchart of a data processing method provided in Embodiment Two of the present application is shown in FIG. 13B. The embodiment of the present application further refines the content corresponding to S130-S140 of the foregoing embodiment on the basis of the foregoing embodiment. The embodiment of the present application can be combined with each optional scheme in one or more of the foregoing embodiments. As shown in FIG. 13B, the method comprises the following steps. Figure 2
[0070] S210, recognizing text information in a to-be-processed image and a confidence of the text information based on an image recognition module.
[0071] S220, when it is detected that there is to-be-corrected text with a confidence lower than a pre-set confidence threshold, obtaining at least two recognized texts adjacent to the to-be-corrected text.
[0072] S230, determining at least one to-be-selected text associated with the to-be-corrected text and a to-be-selected confidence corresponding to each to-be-selected text in the text based on a pre-set corpus.
[0073] wherein the corpus can be determined in advance, the corpus includes a large number of characters, the characters can be divided into multiple groups according to the same shape, meaning or pronunciation, and the confidence of the characters in the corpus or the confidence of the characters in the corpus inserted into the determined text is combined to select the top n characters to form a list of similar characters, and the corresponding selected character is selected from the list of similar characters of the to-be-corrected character when replacing the to-be-corrected character. The to-be-selected confidence indicates the possibility that the selected character is the correct replacement character if the to-be-corrected character is replaced by the selected character.
[0074] Specifically, the corpus can be pre-set to determine a plurality of to-be-selected characters associated with the to-be-corrected character, and the plurality of to-be-selected characters determined to be associated with the to-be-corrected character are obtained, and each to-be-selected character has a corresponding to-be-selected confidence in the text.
[0075] S240, determining a to-be-selected text code corresponding to each to-be-selected character based on each to-be-selected character and the corresponding to-be-selected confidence;
[0076] In this embodiment, the number of to-be-selected characters can be multiple, and the to-be-selected characters can be determined according to each to-be-selected character and the corresponding to-be-selected confidence. For example, a threshold value is pre-set, assuming that the threshold value is 10, if the number of to-be-selected characters is less than 10, the to-be-selected text code corresponding to each to-be-selected character is determined based on each to-be-selected character and the corresponding to-be-selected confidence; if the number of to-be-selected characters is greater than 10, the to-be-selected characters can be sorted according to the to-be-selected confidence of each to-be-selected character in the text, the top 10 to-be-selected characters are selected, and the to-be-selected text code corresponding to each of the top 10 to-be-selected characters is determined based on the top 10 to-be-selected characters and the corresponding to-be-selected confidence.
[0077] Optionally, determining a to-be-selected text code corresponding to each to-be-selected character based on each to-be-selected character and the corresponding to-be-selected confidence comprises: for each to-be-selected character, determining a to-be-used character code corresponding to the current to-be-selected character; calculating the product of the to-be-used character code and the confidence of the current to-be-selected character to obtain the to-be-selected character code corresponding to the current to-be-selected character.
[0078] In this embodiment, for the to-be-corrected character, the to-be-selected characters of the to-be-corrected character are determined, and then the to-be-used character code corresponding to the current to-be-selected character is obtained. Further, the product of the to-be-used character code corresponding to the to-be-corrected character position and the confidence of the current to-be-selected character is calculated.
[0079] S250, determining a to-be-used character code based on each to-be-selected text code;
[0080] In the specific application process, the to-be-selected character encoding of each to-be-selected character of the to-be-corrected character can be determined, and the confidence corresponding to each to-be-selected character of the to-be-corrected character can be obtained, and then the to-be-used character encoding and the confidence of the current to-be-selected character are multiplied to obtain the to-be-selected text encoding corresponding to the current to-be-selected character. Subsequently, for each to-be-selected text encoding determined, the to-be-used character encoding can be determined in a weighted sum manner.
[0081] Based on each to-be-selected text encoding, the specific implementation process of determining the to-be-used character encoding is as follows: the product of the encoding of the first n to-be-selected texts at the position of the to-be-corrected character and the confidence thereof is calculated, and each to-be-selected text encoding is added to obtain the final result as the to-be-used character encoding at the position, which can be referred to as a pseudo-mask. The calculation formula of the to-be-used character encoding is as follows:
[0082]
[0083] Wherein, e' is the to-be-used character encoding, n is the total number of to-be-selected text encodings, p i is the encoding of the i-th to-be-selected text, e i is the confidence of the i-th to-be-selected text.
[0084] S260, based on the to-be-used character encoding, the position encoding of the to-be-corrected character belonging to the target sentence, and the segmentation encoding, determine the to-be-corrected character encoding corresponding to the to-be-corrected character;
[0085] Wherein, the target sentence includes the to-be-corrected character and at least two recognized characters.
[0086] Wherein, the to-be-used character encoding is the encoding information of the to-be-corrected character, for example, it can be a specified length of the encoding vector. The position encoding represents the position information of the to-be-corrected character in the target sentence to which it belongs, which can be represented by a data number, for example, the encoding information of the word "ben" in the target sentence "text correction method" can be "2". In order to enhance the adaptability of the model to process tasks, many downstream tasks are processed in one model, so there can be two target sentences in one model. The segmentation encoding can represent which of the two target sentences the current to-be-corrected character belongs to, for example, the two sentences in the model are represented by A and B respectively, and the segmentation encoding can be "A" or "B".
[0087] In the present embodiment, in order to input the recognized character information into the pre-set model, it is necessary to encode the to-be-corrected character. In the present embodiment, the encoding of the to-be-corrected character can be realized based on the to-be-used character encoding, the position encoding of the to-be-corrected character belonging to the target sentence, and the segmentation encoding, to obtain the to-be-corrected character encoding corresponding to the to-be-corrected character.
[0088] S270. According to the position information of the recognized text and the text to be corrected in the target sentence, splice the corresponding recognized text encoding and the text to be corrected encoding to obtain the target sentence encoding.
[0089] Among them, the position information refers to the position of a certain text in the target sentence that includes multiple recognized texts determined according to the text to be corrected.
[0090] Exemplarily, the text content is "Text error correction method, which has a wide range of applications". After being processed by the image recognition module: "措" is used as the text to be corrected. Assume that the recognized text adjacent to the text to be corrected is: "文本纠措方法". Then the text to be corrected "措" is in the fourth position in the target sentence; the recognized text "文" is in the first position in the target sentence; the recognized text "本" is in the second position in the target sentence; the recognized text "纠" is in the third position in the target sentence; the recognized text "方" is in the fifth position in the target sentence; the recognized text "法" is in the sixth position in the target sentence. Therefore, according to the position information of the recognized text and the text to be corrected in the target sentence, from the first position to the sixth position, the recognized text encoding and the text to be corrected encoding are encoded in sequence according to the order to obtain the target sentence encoding.
[0091] S280. Input the target sentence encoding into a pre-trained text prediction model to obtain the target sentence.
[0092] S290. Replace the text to be corrected with the predicted text in the target sentence.
[0093] In the above technical solution, the image recognition module recognizes the text information and the confidence of the text information in the image to be processed. When it is detected that there is a text to be corrected with a confidence lower than the preset confidence threshold, multiple recognized texts adjacent to the text to be corrected are obtained. Subsequently, according to at least one selectable text associated with the text to be corrected, the text to be corrected encoding corresponding to the text to be corrected is determined. Furthermore, based on the recognized text encoding corresponding to each recognized text and the text to be corrected encoding, the target sentence encoding is determined. Input the target sentence encoding into a pre-trained text prediction model to obtain the target sentence including the predicted text corresponding to the text to be corrected. Finally, replace the text to be corrected with the predicted text in the target sentence. The technical solution provided by the embodiments of the present invention solves the technical problems of high cost and low efficiency in manual error correction and algorithm implementation of machine learning for text error correction, improves the accuracy and efficiency of text error correction, and improves the fluency of users' reading text.
[0094] Embodiment III
[0095] In the embodiments of the present invention, the process of text error correction is introduced in a specific implementation manner. Figure 3A structural schematic diagram of a text error correction method provided for Embodiment Three of the present application, which comprises the following steps:
[0096] (1) First, text detection and text recognition are performed based on the image recognition module in the OCR recognition technology. In the decoding stage of recognition, if the character confidence is higher than the pre-set confidence threshold, no error correction is needed, and the correct recognition result is directly output; and for the character whose confidence is lower than the pre-set confidence threshold, it is considered that there is a high possibility of misrecognition, and it needs to be judged whether it needs further error correction in the following steps;
[0097] (2) The text that needs further error correction can be referred to as to-be-corrected text, at least two recognized texts adjacent to the to-be-corrected text are obtained, the recognized texts are sorted in combination with the detection frame position and the reading order, and a complete context segment is obtained as much as possible;
[0098] (3) For the text in the complete context segment, the text that does not need error correction uses the same representation as in BERT; and for the to-be-corrected text, the product sum of the encoding of the first n characters and the confidence thereof given at the position of the to-be-corrected text is selected as the encoding of the position;
[0099] (4) The product sum of the encoding of the first n characters and the confidence thereof is obtained as the encoding of the position, and the target sentence encoding of the text string is obtained by sequentially splicing;
[0100] (5) The target sentence encoding is input into the trained BERT Masked Language Model to predict the text at the to-be-corrected position, and a target sentence including the predicted text corresponding to the to-be-corrected text is obtained, and the text error correction is completed.
[0101] For the BERT model, the pre-trained Masked Language Model is used for transfer training on the self-defined corpus. The self-defined corpus is composed of homograph of a certain character. In the process of self-defining the corpus, the homograph list can be generated with the help of OCR, the first n characters with high confidence are selected to form the homograph list, and the homograph list is extracted when replacing a certain character. In the training stage, when generating the corpus representation, the encoding of the homograph is directly used instead of the weighted encoding of the homograph sequence, and the segmentation and position encoding mode remains the same as other characters.
[0102] The technical scheme, after the system acquires a text image needing to be recognized, the text detection and text recognition are performed through an image recognition module to obtain a preliminary recognition result, for the text with low word confidence, the context segment thereof is found out, encoded into target sentence encoding, and the text prediction is performed through a Masked Language Model pre-training model of BERT and a model after migration learning on a self-defined corpus, so that the text correction is realized, the accuracy and efficiency of the text correction are improved, and the user's reading experience of the text is improved.
[0103] Embodiment four
[0104] Figure 4 A structure schematic diagram of a text correction device provided by Embodiment Four of the present application is provided, and the device can execute the text correction method provided by the embodiments of the present application. The device comprises a confidence determination module 410, a to-be-corrected word acquisition module 420, a to-be-corrected word encoding determination module 430, a target encoding determination module 440, a target sentence determination module 450 and a predicted word replacement module 460.
[0105] The confidence determination module 410 is configured to determine the confidence of the text information in the image to be processed based on the image recognition module.
[0106] The to-be-corrected word acquisition module 420 is configured to acquire at least two recognized words adjacent to the to-be-corrected word when it is detected that there is to-be-corrected text with a confidence lower than a pre-set confidence threshold.
[0107] The to-be-corrected word encoding determination module 430 is configured to determine the to-be-corrected word encoding corresponding to the to-be-corrected word according to at least one to-be-selected word associated with the to-be-corrected word.
[0108] The target encoding determination module 440 is configured to determine the target sentence encoding based on the recognized word encoding corresponding to each recognized word and the to-be-corrected word encoding.
[0109] On the basis of the above technical schemes, the target encoding determination module 440 is further configured to splice the corresponding recognized word encoding and to-be-corrected word encoding according to the position information of the recognized words and the to-be-corrected words in the target sentence to obtain the target sentence encoding.
[0110] The target sentence determination module 450 is configured to input the target sentence encoding into the pre-trained word prediction model to obtain a target sentence, wherein the target sentence comprises predicted words corresponding to the to-be-corrected words.
[0111] The predicted word replacement module 460 is configured to replace the to-be-corrected words with the predicted words in the target sentence.
[0112] On the basis of each of the above technical solutions, the confidence degree determination module 410 is further configured to display the to-be-corrected character with a confidence degree lower than a preset confidence degree threshold on the display interface.
[0113] On the basis of each of the above technical solutions, the to-be-corrected character obtaining module 420 comprises an identified character obtaining unit, which is specifically configured to obtain at least two identified characters of a sentence to which the to-be-corrected character belongs; or obtain a preset number of characters before and after the to-be-corrected character, to obtain at least two identified characters.
[0114] On the basis of each of the above technical solutions, the to-be-corrected character encoding determination module 430 comprises a confidence degree determination unit, a text encoding determination unit, a character encoding determination unit and a to-be-corrected character encoding determination unit.
[0115] The confidence degree determination unit is configured to determine at least one to-be-selected character associated with the to-be-corrected character and a to-be-selected confidence degree corresponding to each to-be-selected character in the text based on a pre-set corpus.
[0116] The text encoding determination unit is configured to determine a to-be-selected text encoding corresponding to each to-be-selected character based on each to-be-selected character and the corresponding to-be-selected confidence degree.
[0117] On the basis of each of the above technical solutions, the text encoding determination unit comprises a to-be-used character encoding determination subunit and a to-be-selected character encoding determination subunit.
[0118] The to-be-used character encoding determination subunit is configured to determine, for each to-be-selected character, a to-be-used character encoding corresponding to the current to-be-selected character.
[0119] The to-be-selected character encoding determination subunit is configured to calculate a product of the to-be-used character encoding and the confidence degree of the current to-be-selected character, to obtain a to-be-selected character encoding corresponding to the current to-be-selected character.
[0120] The technical scheme provided in the above embodiment, by means of the image recognition module, the text information in the image to be processed and the confidence of the text information are recognized, when it is detected that there is text to be corrected with a confidence lower than a preset confidence threshold, a plurality of recognized texts adjacent to the text to be corrected are acquired, then according to at least one text to be selected associated with the text to be corrected, the text to be corrected code corresponding to the text to be corrected is determined, and then based on the recognized text code corresponding to each recognized text and the text to be corrected code, the target sentence code is determined. The target sentence code is input into the text prediction model trained in advance, and the target sentence including the predicted text corresponding to the text to be corrected is obtained, and finally, the text to be corrected is replaced based on the predicted text in the target sentence. The technical scheme provided in the embodiment of the present application solves the technical problems of high cost and low efficiency in the process of realizing text correction by manual correction and machine learning algorithm, and the present scheme determines the text to be corrected based on the confidence in the text recognition process, and then corrects the text to be corrected, and finally displays the correct text information. Or, after the text is converted, the content of the text recognition can be dynamically updated in combination with the confidence of each character during reading the text, and the wrong characters in the recognition are corrected, thereby improving the accuracy and efficiency of text correction and improving the user's reading experience of the text.
[0121] The data processing apparatus provided in the embodiments of the present disclosure can execute the video determination method provided in any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of the execution method.
[0122] It should be noted that each unit and module included in the above apparatus is only divided according to the function logic, but is not limited to the above division, as long as the corresponding function can be realized; in addition, the specific name of each functional unit is only for convenient mutual distinction, and does not limit the protection scope of the embodiments of the present disclosure.
[0123] Embodiment five
[0124] Figure 5 A structural schematic diagram of an electronic device is provided for the fifth embodiment of the present application. The electronic device 10 is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0125] As Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication. The memory stores a computer program executable by the at least one processor 11, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0126] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0127] The processor 11 can be various general and / or special-purpose processing components having processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the road surface identification method.
[0128] In some embodiments, the road surface identification method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the road surface identification method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the road surface identification method by any other appropriate means, such as by means of firmware.
[0129] The various embodiments of the systems and techniques described above can be implemented in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a load programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0130] Computer programs used to implement the processes of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program
[0131] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store computer programs for use by or in connection with an instruction execution system, apparatus, or device. Computer-readable storage media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0132] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0133] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), blockchain network, and the Internet.
[0134] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service. It should be understood that various forms of flow shown above can be used to reorder, add or delete steps. For example, each step described in the present application can be executed in parallel, sequentially or in different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein. The above specific embodiments do not constitute a limitation on the scope of protection of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method of text correction, characterized by, The method comprises the following steps: identifying text information in a to-be-processed image and a confidence level of the text information based on an image recognition module; when it is detected that there is to-be-corrected text with a confidence level lower than a preset confidence threshold, obtaining at least two recognized texts adjacent to the to-be-corrected text; determining a to-be-corrected text code corresponding to the to-be-corrected text according to at least one to-be-selected text associated with the to-be-corrected text, wherein the to-be-corrected text code is obtained by encoding a plurality of to-be-selected texts associated with the to-be-corrected text; determining a target sentence code based on the recognized text code corresponding to each recognized text and the to-be-corrected text code; inputting the target sentence code into a pre-trained text prediction model to obtain a target sentence, wherein the target sentence includes a predicted text corresponding to the to-be-corrected text; replacing the to-be-corrected text with the predicted text in the target sentence; wherein the determination of the to-be-corrected text code corresponding to the to-be-corrected text according to at least one to-be-selected text associated with the to-be-corrected text comprises: determining at least one to-be-selected text associated with the to-be-corrected text and a to-be-selected confidence level corresponding to each to-be-selected text in the text based on a pre-set corpus, wherein the texts in the corpus are divided into multiple groups according to their shapes, meanings or pronunciations; the to-be-selected texts are selected based on a list of homograph of the to-be-corrected text; the list of homograph is composed of texts with top n confidence levels based on the confidence levels of the texts or based on the confidence levels of inserting the texts into the text; the to-be-selected confidence level is the possibility of selecting the current to-be-selected text to replace the to-be-corrected text, and the current to-be-selected text is the correct replacement text; determining a to-be-selected text code corresponding to each to-be-selected text based on each to-be-selected text and the corresponding to-be-selected confidence level, comprising: sorting the to-be-selected confidence levels corresponding to each to-be-selected text in the text, selecting the top m to-be-selected texts, and calculating the product of the encoding of the top m to-be-selected texts and their confidence levels to obtain the to-be-selected text code corresponding to each of the top m to-be-selected texts; determining a to-be-used text code based on each to-be-selected text code, wherein the to-be-used text code is the final result obtained by adding each to-be-selected text code; determining the to-be-corrected text code corresponding to the to-be-corrected text based on the to-be-used text code, the position code of the to-be-corrected text belonging to the target sentence, and the segmentation code.
2. The method of claim 1, wherein, After the image recognition module identifies the text information in the to-be-processed image and the confidence level of the text information, the method further comprises: displaying the to-be-corrected text with a confidence level lower than the preset confidence threshold on a display interface.
3. The method of claim 1, wherein, The method of obtaining at least two recognized texts adjacent to the to-be-corrected text comprises: obtaining at least two recognized texts of the sentence to which the to-be-corrected text belongs; or obtaining a preset number of texts before and after the to-be-corrected text as the starting point to obtain the at least two recognized texts.
4. The method of claim 1, wherein, The target sentence code is determined based on the identified character codes corresponding to the identified characters and the error correction character code. The target sentence code is obtained by splicing the identified character codes and the error correction character code according to the positions of the identified characters and the error correction character in the target sentence.
5. The method of claim 1, wherein, Further comprising: The corresponding predicted character is displayed at the position associated with the error correction character, so that the error correction character is replaced by the predicted character based on a triggering operation on the predicted character.
6. A text error correction device for performing the text error correction method of any one of claims 1-5, the device comprising: A confidence determination module configured to determine character information in an image to be processed and a confidence of the character information based on an image recognition module. An error correction character acquisition module configured to acquire at least two identified characters adjacent to an error correction character when it is detected that the error correction character has a confidence lower than a preset confidence threshold. An error correction character code determination module configured to determine an error correction character code corresponding to the error correction character based on at least one selected character associated with the error correction character, wherein the error correction character code is obtained by encoding the plurality of selected characters associated with the error correction character. A target code determination module configured to determine a target sentence code based on the identified character codes corresponding to the identified characters and the error correction character code. A target sentence determination module configured to input the target sentence code into a pre-trained character prediction model to obtain a target sentence, wherein the target sentence includes a predicted character corresponding to the error correction character. A predicted character replacement module configured to replace the error correction character with the predicted character in the target sentence. The error correction character code determination module comprises a confidence determination unit and a text code determination unit. The confidence determination unit is configured to determine at least one selected character associated with the error correction character and a selected confidence corresponding to each selected character in the text based on a pre-set corpus, wherein the characters in the corpus are divided into multiple groups according to their shapes, meanings or pronunciations; the selected characters are selected based on a list of homograph characters of the error correction character; the list of homograph characters is composed of characters with top n confidence based on the confidence of each character or based on the confidence of inserting each character into the text; and the selected confidence is the possibility of selecting the current selected character as a correct replacement for the error correction character. The text code determination unit is configured to determine a selected text code corresponding to each selected character based on each selected character and the corresponding selected confidence, including: sorting the selected confidence corresponding to each selected character in the text, selecting the top m selected characters, calculating the product of the code of the top m selected characters and their confidence, and obtaining the selected text code corresponding to each of the top m selected characters. The to-be-error-corrected word encoding determination module further includes: determining a to-be-used word encoding based on each to-be-selected text encoding; wherein the to-be-used word encoding is a final result obtained by adding each to-be-selected text encoding; Determine the to-be-error-corrected word encoding corresponding to the to-be-error-corrected word based on the to-be-used word encoding, the position encoding of the to-be-error-corrected word belonging to the target sentence, and the segmentation encoding.
7. An electronic device, comprising: The electronic device includes: At least one processor; and The memory is in communication connection with the at least one processor; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the text error correction method of any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to implement the text error correction method of any one of claims 1-5 when executed.
Citation Information
Patent Citations
Text processing method, text processing device, electronic equipment and storage medium
CN114330238A
Text error correction method and training method based on RPA and AI and related equipment thereof
CN114863429A