A text positioning and correction method system based on an OCR recognition result

By combining the LCSstr algorithm and the MLM model, the problem of reduced text recognition accuracy was solved, achieving fast and effective text correction and improving the accuracy and efficiency of recognition results.

CN115761740BActive Publication Date: 2026-11-06KUNMING UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211495374.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-27
Publication Date
2026-11-06
Estimated Expiration
2042-11-27

AI Technical Summary

Technical Problem

Existing text recognition technologies suffer from reduced accuracy when faced with complex scenes, resolution, tilt angle, text size, and background complexity. Furthermore, deep learning-based error correction methods are time-consuming and rely on large amounts of training data.

Method used

The LCSstr algorithm is used to locate the characters to be corrected, the perplexity is combined to select the sentences to be corrected, and the MLM model is used for error correction. The best error correction result is found by glyph similarity.

Benefits of technology

It enables rapid localization and error correction of recognized text, improves recognition accuracy, reduces error correction time, and reduces dependence on training data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115761740B_ABST
    Figure CN115761740B_ABST
Patent Text Reader

Abstract

This invention relates to a text localization and error correction method system based on OCR recognition results, belonging to the fields of natural language processing and character recognition technology. First, two sets of recognition text are acquired in the text acquisition module. Next, the recognition text is preprocessed in the text preprocessing module. Then, in the character localization module, the LCSstr algorithm is used to color-label the characters to be corrected, achieving localization. Next, the text is segmented in the sentence extraction module, and the sentence perplexity is calculated using a Bigram model to select the sentence to be corrected. Then, in the MLM model error correction module, a similar character set is introduced during pre-training, and the model obtains a prediction set of the characters to be corrected. Finally, in the character shape matching output module, the character shape similarity between the character to be corrected and the prediction set is calculated with respect to strokes, obtaining the best prediction result and outputting the corrected text. This invention achieves effective error correction of recognized text by comparing the results of dual-engine character recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a text localization and error correction method system based on OCR recognition results, belonging to the fields of natural language processing and character recognition technology. Background Technology

[0002] In recent years, the application of text recognition has been widely promoted, and the recognition technology has gradually matured. Currently, the recognition accuracy has reached over 90%, which can basically meet people's daily needs. However, the recognition accuracy can be reduced due to factors such as scene, resolution, tilt angle, text size, background complexity, and the outlines of objects with similar shapes to the text in the image. Therefore, error correction of the recognized content has become a popular research topic.

[0003] Current text correction methods mainly fall into two categories: rule-based and deep learning-based approaches. Rule-based methods primarily consist of two steps: error detection and error correction. Word segmentation is performed using a word segmenter. Since sentences contain misspellings, segmentation errors can occur. Errors can be detected at both the character and word levels. Based on the detection results at these two levels, a candidate set of suspected error locations is formed. In the error correction section, all suspected error locations are traversed, and words at the error locations are replaced using a similar-sounding and similar-looking dictionary. Then, a language model calculates the sentence perplexity, compares and ranks all candidate set results, and obtains the optimal corrected word. Deep learning methods are more numerous, mainly including end-to-end error correction, error correction through sequence labeling, and generation-based error correction. These models can learn sentence semantic or grammatical features, which is beneficial for text correction. Furthermore, they often incorporate phonetic and glyph features into the model to enhance its error correction effect. However, deep learning-based methods are time-consuming and require a large amount of training data. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a text localization and error correction method system based on OCR recognition results, thereby making up for the shortcomings of existing text recognition technology, realizing the localization and error correction of recognized text, and solving the above-mentioned problems.

[0005] The technical solution of this invention is: a text location and error correction method based on OCR recognition results. The core of this method is to use the LCSstr algorithm to locate the character to be corrected, use perplexity to select the sentence to be corrected, use the MLM model to perform error correction, and use character shape similarity to find the best result.

[0006] The specific steps are as follows:

[0007] Step 1: Use two text recognition engines to obtain two required texts, text1 and text2.

[0008] text1 = {a1, a2, ..., a...} i , ..., a m}, text2={b1, b2,…,b j , ..., b n}

[0009] Step 2: Preprocess the recognized text obtained in Step 1.

[0010] Step 3: Locate the characters to be corrected in the preprocessed text text1 and text2 from Step 2.

[0011] Step 4: Use punctuation marks to segment sentences, extract sentences with color-coded characters to form sentence pairs, calculate the perplexity of each sentence in the sentence pair, and the sentence with the lowest perplexity in each sentence pair is the sentence with error correction.

[0012] Step 5: Perform text correction. Replace the characters to be corrected in the sentence with masked characters and feed them into the trained MLM model. The model will locate and predict the characters to be corrected in the sentence, take the top of the prediction results, and finally output the corrected recognized text.

[0013] Step 2 specifically refers to:

[0014] Step 2.1: First, detect and identify invisible characters in the text, including Chinese and English spaces and line breaks, and remove these characters.

[0015] Step 2.2: Then detect whether there are half-width characters in the text, and replace them with the corresponding full-width characters if they exist.

[0016] Step 2.3: Finally, color-label the two recognized texts.

[0017] Step 3 specifically refers to:

[0018] Step 3.1: Let A = text1 and B = text2, and then add color labels to both text1 and text2.

[0019] Step 3.2: Randomly generate two characters c1 and c2, which must satisfy c1≠c2 and

[0020] Step 3.3: Solve for the longest common substring l of A and B using the recursive formula (1) of the LCSstr algorithm. p And store them sequentially into the common substring array L.

[0021]

[0022] In the formula, c[i,j] represents A i ={a1, a2, ..., a i ), where i∈{1,2,...,m} and B j ={b1, b2, ..., b j Let $\frac{\mathbf ...

[0023] Step 3.4: Replace one l in A and one l in B with c1 and c2 respectively. p .

[0024] Step 3.5: Repeat Step 3.3 and Step 3.4 until there are no common substrings in A and B, thus obtaining the filled common substring array L = {l1, l2, ..., l...} p , ..., l t}, where t≤min{m,n}.

[0025] Step 3.6: Extract the common substrings from the common substring array L in turn, and remove the color tags from the common substrings of text1 and text2 in turn.

[0026] The sentence perplexity in Step 4 is specifically as follows:

[0027]

[0028] In the formula, N is the number of characters in the sentence, and P(w i |w i-1 ) represents the probability of the i-th character appearing given that the (i-1)-th character has appeared, and w0 is the sentence start character. <bos>Not included in the total number of N, sentence terminator <eos>Include it in the total number of N.

[0029] Step 5 specifically includes:

[0030] During BERT's pre-training, 15% of the input characters are masked. Of these, 75% are randomly replaced with characters that look similar, 15% are replaced with random characters, and the remaining 10% are retained as original characters. If no similar characters are found, random characters from the BERT dictionary are used for replacement. The original NSP pre-training task in the BERT model is discarded during the pre-training phase. This pre-training task is not important for the error correction task.

[0031] In the MLM error correction model, adjustments were made to the model's pre-training. These adjustments allow the model to learn character shapes to some extent, which can influence the ranking of error correction results. However, it cannot guarantee that the optimal output of the error correction model is a character with a similar shape to the character to be corrected.

[0032] The characters to be corrected in the sentence are replaced with masked characters and then fed into the trained MLM model. The model locates and predicts the characters to be corrected in the sentence, takes the top of the prediction results, and finally outputs the corrected recognized text.

[0033] Step 5.1: First, calculate the edit distance between each character in the prediction set and the character to be corrected, with respect to stroke count. The formula for the edit distance between two Chinese characters with respect to stroke count is:

[0034]

[0035] In the formula, ED a,b (i, j) represents the Levenstein distance between the first i strokes of Chinese character a and the first j strokes of Chinese character b, where It is an indicator function, when a i =b j When the value is 0, it is 1; otherwise, it is 0. The first formula in the min operation represents deleting strokes from 'a' to achieve 'b'. The second formula represents inserting strokes. The third formula represents replacement, depending on whether the current strokes are the same.

[0036] Step 5.2: Then calculate the glyph similarity between each character in the prediction set and the character to be corrected. The formula for calculating glyph similarity is:

[0037]

[0038] In the formula, ED ab L represents the number of strokes required to transform Chinese character 'a' into Chinese character 'b'. a L represents the number of strokes in the Chinese character 'a'. b This represents the number of strokes in the Chinese character 'b'.

[0039] Step 5.3: Finally, use the prediction result with the highest similarity in the prediction set as the best prediction result, replace the character to be corrected with this result, and finally obtain the corrected recognition text, which is then output.

[0040] A text localization and error correction system based on OCR recognition results includes:

[0041] Text acquisition module: Used to obtain the recognition results of two different text recognition engines for the same image.

[0042] Text preprocessing module: used to remove invisible characters from the recognized text, convert half-width symbols in the text to full-width symbols, and add color labels to the recognized text.

[0043] The character positioning module is used to compare two recognized texts and remove the color labels from the characters that do not need to be corrected.

[0044] Sentence segmentation and extraction module: This module is used to segment the recognized text into individual sentences based on the punctuation marks of the separable sentences, extract the sentence pairs with color labels, and use perplexity to select the sentence for error correction in each sentence pair.

[0045] MLM model error correction module: Used to predict the characters to be corrected using BERT's MLM model, and obtain the prediction set.

[0046] Character shape matching output module: used to perform character shape matching between the characters in the prediction set and the characters to be corrected, select the best prediction result, and output the final corrected recognition text.

[0047] Both recognized texts obtained by the text acquisition module are short texts.

[0048] The text preprocessing module converts half-width characters to full-width characters primarily for punctuation marks, letters, and numbers. Invisible characters that need to be removed are those in the ASCII table, numbers 0-32 and 127.

[0049] In the character localization module, the common substring array of the recognized text is obtained through the LCSstr algorithm. Based on the common substring array, the color labels of the common substrings in the recognized text are removed, and the remaining characters with color labels are the characters to be corrected.

[0050] The punctuation marks used for sentence segmentation in the sentence extraction module include periods (.), exclamation marks (!), question marks (?), semicolons (.), and ellipses (...). After sentence segmentation, sentences with colored characters are extracted from the two recognized texts. A Bigram model is used to calculate the perplexity of each sentence pair, and the sentence with the lowest perplexity in each pair is selected as the sentence to be corrected.

[0051] The pre-training process of the MLM model's error correction module involves masking 15% of the input characters. Of these, 75% are randomly replaced with similar-looking characters, 15% are replaced with random characters, and the remaining 10% are retained as original characters. When no similar characters are found, the model is downgraded to replacing them with random characters. The character set used for replacement is generated based on current Chinese character sets and methods using character shape similarity. During the testing phase, the characters to be corrected in the sentence are replaced with masked characters and then fed into the model, which provides a prediction set of the characters to be corrected.

[0052] In the character shape matching output module, the character to be corrected is compared with each character in the prediction set based on the edit distance of the strokes. The prediction set result with the highest similarity is used to replace the character to be corrected, and finally the corrected recognized text is obtained.

[0053] The beneficial effects of this invention are: by comparing the results of dual-engine text recognition, the rapid location of the character to be corrected is achieved; by combining the similarity between the character to be corrected and the original character, the best error correction result of the prediction set is found, thus achieving effective error correction of the recognized text. Attached Figure Description

[0054] Figure 1 This is a flowchart of the steps of the present invention;

[0055] Figure 2 This is a flowchart of the text preprocessing module of the present invention;

[0056] Figure 3 This is a flowchart of the character positioning module to be corrected according to the present invention;

[0057] Figure 4 This is a flowchart of the sentence segmentation extraction module of the present invention;

[0058] Figure 5 This is a schematic diagram of the MLM error correction model of the present invention;

[0059] Figure 6 This is a flowchart of the character shape matching output module of the present invention; Detailed Implementation

[0060] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0061] Example 1: As Figure 1 As shown, a text localization and error correction method based on OCR recognition results includes the following steps:

[0062] Step 1: Use two text recognition engines to obtain two required texts, text1 and text2.

[0063] text1 = {a1, a2, ..., a...} i , ..., a m }, text2={b1, b2,…,b j , ..., b n }

[0064] Step 2: Preprocess the recognized text obtained in Step 1.

[0065] Step 3: Locate the characters to be corrected in the preprocessed text text1 and text2 from Step 2.

[0066] Step 4: Use punctuation marks to segment sentences, extract sentences with color-coded characters to form sentence pairs, calculate the perplexity of each sentence in the sentence pair, and the sentence with the lowest perplexity in each sentence pair is the sentence with error correction.

[0067] Step 5: Perform text correction. Replace the characters to be corrected in the sentence with masked characters and feed them into the trained MLM model. The model will locate and predict the characters to be corrected in the sentence, take the top of the prediction results, and finally output the corrected recognized text.

[0068] Step 2 specifically refers to:

[0069] Step 2.1: First, detect and identify invisible characters in the text, including Chinese and English spaces and line breaks, and remove these characters.

[0070] Step 2.2: Then detect whether there are half-width characters in the text, and replace them with the corresponding full-width characters if they exist.

[0071] Step 2.3: Finally, color-label the two recognized texts.

[0072] Step 3 specifically refers to:

[0073] Step 3.1: Let A = text1 and B = text2, and then add color labels to both text1 and text2.

[0074] Step 3.2: Randomly generate two characters c1 and c2, which must satisfy c1≠c2 and

[0075] Step 3.3: Solve for the longest common substring l of A and B using the recursive formula (1) of the LCSstr algorithm. p And store them sequentially into the common substring array L.

[0076]

[0077] In the formula, c[i, j] represents A i ={a1, a2, ..., a i }, where i∈{1,2,...,m} and B j ={b1, b2, ..., b j Let $\frac{\mathbf ...

[0078] Step 3.4: Replace one l in A and one l in B with c1 and c2 respectively. p .

[0079] Step 3.5: Repeat Step 3.3 and Step 3.4 until there are no common substrings in A and B, thus obtaining the filled common substring array L = {l1, l2, ..., l...} p , ..., l t }, where t≤min{m,n}.

[0080] Step 3.6: Extract the common substrings from the common substring array L in turn, and remove the color tags from the common substrings of text1 and text2 in turn.

[0081] The sentence perplexity in Step 4 is specifically as follows:

[0082]

[0083] In the formula, N is the number of characters in the sentence, and P(w i |w i-1 ) represents the probability of the i-th character appearing given that the (i-1)-th character has appeared, and w0 is the sentence start character. <bos>Not included in the total number of N, sentence terminator <eos>Include it in the total number of N.

[0084] Step 5 specifically includes:

[0085] Step 5.1: First, calculate the edit distance between each character in the prediction set and the character to be corrected, with respect to stroke count. The formula for the edit distance between two Chinese characters with respect to stroke count is:

[0086]

[0087] In the formula, ED a,b (i, j) represents the Levenstein distance between the first i strokes of Chinese character a and the first j strokes of Chinese character b, where It is an indicator function, when a i =b j When the value is 0, it is 1; otherwise, it is 0. The first formula in the min operation represents deleting strokes from 'a' to achieve 'b'. The second formula represents inserting strokes. The third formula represents replacement, depending on whether the current strokes are the same.

[0088] Step 5.2: Then calculate the glyph similarity between each character in the prediction set and the character to be corrected. The formula for calculating glyph similarity is:

[0089]

[0090] In the formula, ED ab L represents the number of strokes required to transform Chinese character 'a' into Chinese character 'b'. a L represents the number of strokes in the Chinese character 'a'. b This represents the number of strokes in the Chinese character 'b'.

[0091] Step 5.3: Finally, use the prediction result with the highest similarity in the prediction set as the best prediction result, replace the character to be corrected with this result, and finally obtain the corrected recognition text, which is then output.

[0092] A text localization and error correction system based on OCR recognition results includes:

[0093] Text acquisition module: Used to obtain the recognition results of two different text recognition engines for the same image.

[0094] Text preprocessing module: used to remove invisible characters from the recognized text, convert half-width symbols in the text to full-width symbols, and add color labels to the recognized text.

[0095] The character positioning module is used to compare two recognized texts and remove the color labels from the characters that do not need to be corrected.

[0096] Sentence segmentation and extraction module: This module is used to segment the recognized text into individual sentences based on the punctuation marks of the separable sentences, extract the sentence pairs with color labels, and use perplexity to select the sentence for error correction in each sentence pair.

[0097] MLM model error correction module: Used to predict the characters to be corrected using BERT's MLM model, and obtain the prediction set.

[0098] Character shape matching output module: used to perform character shape matching between the characters in the prediction set and the characters to be corrected, select the best prediction result, and output the final corrected recognition text.

[0099] Both recognized texts obtained by the text acquisition module are short texts.

[0100] The text preprocessing module converts half-width characters to full-width characters primarily for punctuation marks, letters, and numbers. Invisible characters that need to be removed are those in the ASCII table, numbers 0-32 and 127.

[0101] In the character localization module, the common substring array of the recognized text is obtained through the LCSstr algorithm. Based on the common substring array, the color labels of the common substrings in the recognized text are removed, and the remaining characters with color labels are the characters to be corrected.

[0102] In the character shape matching output module, the character to be corrected is compared with each character in the prediction set based on the edit distance of the strokes. The prediction set result with the highest similarity is used to replace the character to be corrected, and finally the corrected recognized text is obtained.

[0103] Example 2: Figure 1 As shown, a text localization and error correction system based on OCR recognition results includes a text acquisition module, a text preprocessing module, a character localization module, a sentence segmentation extraction module, an MLM model error correction module, and a character shape matching output module.

[0104] First, there is the text acquisition module, which uses two different text recognition engines to obtain the recognized text text1 and text2.

[0105] Using both Baidu's and Alibaba's text recognition engines to simultaneously identify the text content "Every spring, peonies and roses bloom in profusion. Their branches are full of buds, bursting into full bloom, so beautiful!", the resulting text1 and text2 are as follows:

[0106]

[0107] like Figure 2 As shown, the next step is to preprocess the recognized text. Invisible characters need to be removed, and half-width symbols need to be converted to full-width symbols. Finally, color labels are applied. Specifically, after processing text1 and text2, the following results are obtained:

[0108]

[0109] Next, the color tags on the common substrings of the preprocessed text need to be removed. First, the common substring array L of text1 and text2 is obtained according to the LCSstr algorithm. Specifically, L = {"Every spring, peonies and roses", "open together. They bloom", "open, so beautiful!", "full of branches, buds"}. Based on the obtained common substring array, the color tags of the common substrings in text1 and text2 are removed one by one. The characters with color tags at this point are the characters that need to be corrected later.

[0110]

[0111] Then, sentence segmentation is performed to extract sentence pairs containing color tag characters. Specifically, in the two sentences above, the "." and "!" symbols can be used to separate the two sentences. Because both sentences in text1 and text2 contain color tag characters, two sentence pairs will be extracted, namely S. 11 and S 12 S 21 and S 22 .

[0112] <![CDATA[S 11 ]]> Every spring, peonies and roses bloom in succession. <![CDATA[S 12 ]]> Every spring, peonies and roses bloom in competition. <![CDATA[S 21 ]]> Their branches are covered in buds, some still in bloom, and they are absolutely beautiful! <![CDATA[S 22 ]]> Their branches are covered in blossoms, some still in bud, some already open—they are absolutely beautiful!

[0113] Next, the Bigram model is used to calculate the perplexity of each sentence pair, and the sentence with the minimum perplexity in each sentence pair is extracted. Specifically, the perplexity of the two sentences S in the second sentence pair is calculated. 21 and S 22 The level of confusion.

[0114] Sentence S 21 The probability of it occurring is:

[0115]

[0116] Sentence S 21 The level of confusion is:

[0117]

[0118] Sentence S 22 The perplexity calculation is similar to that of sentence S. 21 Sentence S 22 The perplexity level of sentence S is 13.6174. This indicates that sentence S... 21 has a lower perplexity, and select the sentence S 21 for error correction.

[0119] Before performing error correction, the MLM error correction model should be pre-trained, where 15% of the input characters are masked, 75% of which are replaced with characters with similar glyphs, 15% are replaced with random characters, and the remaining 10% are kept as the original characters. If the character "ji" (self) in a sentence is masked during the pre-training process, there is a 15% probability that it will be replaced with a random character such as "jian" (reduce), a 75% probability that it will be replaced with its similar glyph character such as "si" (snake-like), and a 10% probability that it will remain unchanged. The pre-trained model is used for positioning and error correction. The character to be corrected is replaced with a mask marker character, and the model predicts the character to be corrected.

[0120] Specifically, the trained model processes the sentence S 21 to predict the characters "lei" (bud) and "ding" (ingot), that is, replacing the character "lei" with the mask marker character, and replacing the character "ding" with the mask marker character, taking the top 10 of the prediction results as the prediction set, obtaining the prediction set of "lei" as {"xiang" (fragrant), "kai" (open), "lei" (bud), "er" (son), "ban" (petal), "duo" (flower), "yan" (gorgeous), "xie" (fade), "guo" (fruit), "bao" (bud)}, and obtaining the prediction set of "ding" as {"dai" (wait), "yu" (desire), "nu" (angry), "zhan" (burst open), "ruo" (as if), "er" (and), "luan" (chaotic), "mu" (dusk), "da" (large), "chu" (initial)}.

[0121] Then glyph matching is performed on the prediction set results. Specifically, the number of strokes of the character "xiang" is 9, the number of strokes of the character "lei" is 16, and the edit distance between them is 10, so the glyph similarity is:

[0122]

[0123] After calculation, the stroke-based glyph similarity between "lei" and the characters in its prediction set is {0.375, 0.188, 1.000, 0.000, 0.158, 0.125, 0.313, 0.135, 0.188, 0.313}, and the optimal prediction result can be obtained as "lei". The stroke-based glyph similarity between "ding" and the characters in its prediction set is calculated as {0.308, 0.385, 0.154, 0.692, 0.154, 0.154, 0.231, 0.214, 0.231, 0.231}. The optimal prediction result can be obtained as "zhan".

[0124] Finally, the optimal prediction result is used to replace the character to be corrected, and the final corrected recognized text is obtained as "Every spring, peony flowers and Chinese rose flowers compete to bloom. Their branches are full of flower buds, in bud and bursting into bloom, which is extremely beautiful!" which is consistent with the content of the picture.

[0125] The specific embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.< / eos> < / bos> < / eos> < / bos>

Claims

1. A text localization and error correction method based on OCR recognition results, characterized in that: Step 1: Use two text recognition engines to obtain two required texts, text1 and text2; , ; Step 2: Preprocess the recognized text obtained in Step 1; Step 3: Locate the characters to be corrected in the preprocessed text text1 and text2 from Step 2; Step 4: Use punctuation marks to segment sentences, extract sentences with color-coded characters to form sentence pairs, calculate the perplexity of each sentence in the sentence pair, and the sentence with the lowest perplexity in each sentence pair is the sentence with error correction. Step 5: Perform text correction. Replace the characters to be corrected in the sentence with mask characters and then feed them into the trained MLM model. The model will locate and predict the characters to be corrected in the sentence, take the top of the prediction results, and finally output the corrected recognized text. During the pre-training process of BERT, 15% of the input characters are masked, of which 75% are randomly replaced with characters that are similar in shape, 15% are replaced with random characters, and the remaining 10% retain the original characters. If there are no similar characters, random characters from the BERT dictionary are used for replacement. The original NSP pre-training task in the BERT model is discarded during the pre-training stage. The sentence perplexity in Step 4 is specifically as follows: ; In the formula, The number of characters in the sentence. Indicates the first When the nth character appears, the nth The probability of each character appearing sentence start mark <bos>Not included In the total number of sentences, the sentence terminator <eos>counted in the total number;< / eos> < / bos> Step 5 specifically includes: Step 5.1: First, calculate the edit distance between each character in the prediction set and the character to be corrected, with respect to stroke count. The formula for the edit distance between two Chinese characters with respect to stroke count is: ; In the formula, Representing Chinese characters The former individual strokes and Chinese characters The former The Levenstein distance of each stroke, among which It is an indicator function, when When the time condition is met, its value is 0; otherwise, it is 1. The first formula in the operation represents from Delete strokes to achieve ; The second formula represents inserting a stroke; The third substitution depends on whether the current strokes are the same; Step 5.2: Then calculate the glyph similarity between each character in the prediction set and the character to be corrected. The formula for calculating glyph similarity is: ; In the formula, represents a Chinese character is changed to a Chinese character the number of strokes required for editing, represents a Chinese character the number of strokes, represents a Chinese character the number of strokes; Step 5.3: Finally, use the prediction result with the highest similarity in the prediction set as the best prediction result, replace the character to be corrected with this result, and finally obtain the corrected recognition text, which is then output.

2. The text localization and error correction method based on OCR recognition results according to claim 1, characterized in that, Step 2 specifically refers to: Step 2.1: First, detect and identify invisible characters in the text, including Chinese and English spaces and newlines, and remove these characters; Step 2.2: Then detect whether there are half-width characters in the text, and replace them with the corresponding full-width characters if they exist; Step 2.3: Finally, color-label the two recognized texts.

3. The text localization and error correction method based on OCR recognition results according to claim 1, characterized in that, Step 3 specifically refers to: Step 3.1: Let And color-code both text1 and text2; Step 3.2: Randomly generate two characters c1 and c2, which must satisfy... and ; Step 3.3: Solve using the recursive formula (1) for the length of the LCSstr algorithm. and Longest common substring And store them sequentially into a common substring array. middle; ; In the formula, express ,in and ,in The length of the longest common substring; Step 3.4: Use and Replace each and one of the ; Step 3.5: Repeat Step 3.3 and Step 3.4 until... and When there is no common substring, the array of common substrings is obtained after filling. ,in ; Step 3.6: Extract the common substring array sequentially The common substrings of text1 and text2 are then processed by removing color tags from the common substrings of text1 and text2 in turn.

4. A system for implementing the text localization and error correction method based on OCR recognition results as described in claim 1, characterized in that, include: Text acquisition module: used to obtain the recognition results of two different text recognition engines for the same image; Text preprocessing module: used to remove invisible characters from the recognized text, convert half-width symbols in the text to full-width symbols, and add color labels to the recognized text; The character positioning module to be corrected is used to compare two recognized texts and remove the color labels from the characters that do not need to be corrected. Sentence segmentation and extraction module: This module is used to segment the recognized text into individual sentences based on the punctuation marks of the separable sentences, extract the sentence pairs with color labels, and use perplexity to select the sentence for error correction in each sentence pair; MLM model error correction module: used to predict the characters to be corrected using BERT's MLM model and obtain a prediction set; Character shape matching output module: used to perform character shape matching between the characters in the prediction set and the characters to be corrected, select the best prediction result, and output the final corrected recognition text.

5. The system according to claim 4, characterized in that: Both recognized texts obtained by the text acquisition module are short texts.

6. The system according to claim 4, characterized in that: The text preprocessing module converts half-width symbols to full-width symbols for punctuation marks, letters, and numbers.

7. The system according to claim 4, characterized in that: In the character localization module, the common substring array of the recognized text is obtained through the LCSstr algorithm. Based on the common substring array, the color labels of the common substrings in the recognized text are removed, and the remaining characters with color labels are the characters to be corrected.

8. The system according to claim 4, characterized in that: In the character shape matching output module, the character to be corrected is compared with each character in the prediction set based on the stroke edit distance. The prediction set result with the highest similarity is used to replace the character to be corrected, and finally the corrected recognition text is obtained.

Citation Information

Patent Citations

  • Image text recognition and error correction method and system, electronic device and medium

    CN113743415A

  • Efficient identification and correction of optical character recognition errors through learning in a multi-engine environment

    US8331739B1