OCR recognition result optimization method based on reference text comparison

By introducing contextual co-occurrence analysis of candidate character sets and external reference texts into the OCR system, the OCR recognition results are optimized, the problems of misspellings and missing characters are solved, and efficient automatic error correction and improved recognition accuracy are achieved.

CN120599641AActive Publication Date: 2025-09-05CENT SOUTH UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511107217.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-08
Publication Date
2025-09-05
Estimated Expiration
2045-08-08

AI Technical Summary

Technical Problem

Existing OCR systems are prone to typos and omissions when recognizing handwriting, similar character structures, or complex typesetting, and lack the ability to correct errors based on contextual semantics, making it difficult to automatically optimize recognition results.

Method used

By establishing a candidate character set and combining it with the contextual co-occurrence relationship of external reference text, probability analysis and optimal replacement are performed to optimize OCR recognition results.

Benefits of technology

It improves the accuracy of text recognition, reduces the cost of manual proofreading, and enhances the automation and intelligence level of the recognition process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120599641A_ABST
    Figure CN120599641A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of character image recognition processing, and particularly discloses an OCR (Optical Character Recognition) result optimization method based on reference text comparison, which takes an OCR result as a basis, introduces a pre-generated candidate character set, and utilizes a character co-occurrence relationship in an external reference text under a real context to optimize an OCR recognition result. And by counting high-frequency collocation characters of contexts before and after the suspected characters, the most probable substitute characters in semantics are constructed. And finally, selecting an optimal alternative character in an intersection of the candidate priority ranking and the context co-occurrence statistics to realize efficient correction of character set recognition errors, thereby improving the accuracy of final recognition of the text and reducing the manual proofreading cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of character image recognition processing, and specifically discloses a method for optimizing OCR recognition results based on reference text comparison. Background Art

[0002] Currently, OCR systems are widely used in scenarios such as bill recognition, file digitization, and document processing. Mainstream methods rely on deep learning models such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), and transformers to implement end-to-end text recognition processes. These systems achieve high accuracy when recognizing standard fonts or high-quality images.

[0003] However, in actual applications, due to factors such as handwriting, similar character structure, character adhesion or complex typesetting, the OCR system may still produce typos, omissions or inaccurate character recognition during the recognition process.

[0004] Furthermore, most current mainstream OCR systems only return single recognition results and lack contextual semantic error correction capabilities. This makes automatic correction and optimization of these results difficult, especially in scenarios without human intervention. While some systems can generate candidate characters for error correction, they lack effective judgment of these candidates based on linguistic context, making efficient and reliable automatic optimization impossible.

[0005] The present invention provides an OCR recognition result optimization method based on reference text comparison to solve the above problems. Summary of the Invention

[0006] The purpose of the present invention is to improve the accuracy of the final recognized text and reduce the cost of manual proofreading by inputting preliminary recognition results and pre-generated candidate character sets, and combining the contextual co-occurrence relationship in the external reference corpus to perform probability analysis and optimal replacement of characters suspected of being misrecognized.

[0007] In order to achieve the above objectives, the basic solution of the present invention provides an OCR recognition result optimization method based on reference text comparison, comprising the following steps: Step A1: establishing a candidate character set storing a plurality of candidate replacement characters; Step A2: Receive the OCR recognition result and the external reference text, perform sentence segmentation on the OCR recognition result to obtain a character sequence, wherein the character sequence includes sentence indexes divided by the number of layers and position indexes divided by the character sequence of the sentence to which it belongs; Step A3: Traverse all characters of all sentences obtained after segmentation, find characters that can be optimized in the candidate character set, directly optimize them, and then enter Step A7 for result output. For characters to be optimized not recorded in the candidate character set, enter Step A4. For sentences that do not need optimization, directly enter Step A7 for result output; Step A4: Receive the character to be optimized, and extract the context characters for the current position of the character to be optimized; Step A5: Use the external reference text for co-occurrence statistical analysis to obtain the adjacent characters of the context characters, respectively construct adjacent character sets, merge and deduplicate them, and sort them by frequency to generate a context recommended character set; Step A6: Traverse all candidate characters in the candidate character set. When a candidate character appears in the context recommended character set, update the character at the same position in the character sequence, and terminate this round of traversal. If it does not appear, keep the character at the same position in the character sequence unchanged and terminate this round of traversal. After this round of traversal, return to Step A3 to perform the traversal of the next position character; Step A7: Loop through Steps A3 to A6 until all sentences are processed. Concatenate each sentence in the finally updated character sequence into a string, assign it to the optimized output result as the final optimized recognition result.

[0008] Furthermore, in Step A1, the candidate character set CandidateSet_sentences is a nested dictionary structure, including an outer dictionary and an inner dictionary, which are represented as follows: The keys of the outer dictionary are sentence indices, denoted as s, representing the s-th sentence, where s = 0, 1, 2...; The keys of the inner dictionary are character indices, denoted as i, representing the i-th character in sentence s, where i = 0, 1, 2...

[0009] Furthermore, in Step A2, the character sequence obtained after sentence segmentation is represented as C_ocr_sentences. Among them, for the s-th sentence after segmentation, it is represented as C_ocr_sentences[s], and the i-th character of the s-th sentence is represented as C_ocr_sentences[s][i]. s is the sentence index, the same as the key of the outer dictionary, and i is the position index of the character in the sentence, the same as the key of the inner dictionary.

[0010] Furthermore, in Step A3, the process of finding the required sentences includes the following steps: Step A301: Initialize the sentence index of the current character sequence, and set s = 0; Step A302: When s < len(C_ocr_sentences), enter Step A303; otherwise, enter Step A308; Step A303: Initialize the character index i = 0 of the current sentence; Step A304: When i < len(C_ocr_sentences[s]), enter Step A305 to process each character in sequence; otherwise, enter Step A306; Step A305: Determine whether the position (s, i) exists in the candidate character set CandidateSet_sentences and the corresponding candidate list is not empty: If not, keep the original character C_ocr_sentences[s][i] in the character sequence unchanged, execute i = i + 1, and return to Step A304 to continue processing the next character; If so, enter Step A4 for context extraction and processing; Step A306: When i ≥ len(C_ocr_sentences[s]), enter Step A307; Step A307: Execute s = s + 1, and return to Step A303 to process the next sentence; Step A308: Until s ≥ len(C_ocr_sentences), indicating that all sentences have been processed, enter Step A7 for result output.

[0011] Further, in Step A4, during the process of extracting context characters, the following rules are followed: When the character is at the beginning of the sentence, extract the next character; If the character is at the end of the sentence, extract the previous character; Otherwise, extract both the previous character and the next character.

[0012] Further, during the implementation of Step A5, the following steps are included: When there is a next character, count the frequency of the characters following it and construct a set of following characters; When there is a previous character, count the frequency of the characters preceding it and construct a set of preceding characters; Merge and deduplicate the set of following characters and the set of preceding characters, sort them according to the character occurrence frequency, and generate a set of context recommended characters.

[0013] Further, the value of the inner dictionary is a pre-generated list of strings List[str], representing candidate replacement characters, arranged in a priority sequence from high to low according to character similarity, and a high character similarity means a high priority sequence; In Step A6, during the process of traversing the candidate character set, traverse in the order of the priority sequence.

[0014] The principle and effect of this solution are as follows: 1. Compared with existing technologies, this method uses OCR recognition results as a foundation, introduces a pre-generated candidate character set, and leverages character co-occurrence relationships in real-world context within external reference text. By counting the high-frequency collocations of the suspected character's preceding and following context, the method constructs the most semantically probable replacement character. Ultimately, the optimal replacement character is selected from the intersection of candidate priority ranking and contextual co-occurrence statistics, enabling efficient correction of character set recognition errors.

[0015] 2. Compared with existing technologies, this invention can automatically replace incorrect characters for characters with similar structures and easily confused semantics, combining a co-occurrence analysis mechanism with reference text context, effectively reducing the risk of misidentification caused by character confusion. It can also significantly reduce the need for manual review and intervention, improve the automation and processing efficiency of the recognition process, and enhance the system's usability and intelligence in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 A flowchart of an OCR recognition result optimization method based on reference text comparison proposed in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0018] In order to further illustrate the technical means and effects adopted by the present invention to achieve the predetermined purpose of the invention, the specific implementation methods, structures, features and effects of the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.

[0019] The OCR recognition result optimization method based on reference text comparison is implemented, for example Figure 1 As shown, the following steps are included: Step A1: Create a candidate character set CandidateSet_sentences, which stores candidate replacement characters. The candidate character set CandidateSet_sentences represents a set of candidate characters corresponding to characters that may have errors in the OCR recognition result.

[0020] In this embodiment, the candidate character set CandidateSet_sentences is a nested dictionary structure, including an outer dictionary and an inner dictionary. Its structure is defined as: The key of the outer dictionary is the sentence index, denoted as s, which represents the sth sentence, s = 0, 1, 2...; The key of the inner dictionary is the character index, denoted as i, which represents the i-th character in sentence s, i=0, 1, 2...

[0021] The inner dictionary value is a pre-generated string list List[str], representing candidate replacement characters. These characters are prioritized from highest to lowest similarity, with higher similarity ranking higher. The candidate character set CandidateSet_sentences is of type Dict[int,Dict[int,List[str]]].

[0022] If the candidate list corresponding to the candidate character set CandidateSet_sentences[s][i] is empty, it means that the current character does not need to be modified and the original recognition result is retained.

[0023] Step A2: Receive the OCR recognition result and the external reference text, perform sentence segmentation on the OCR recognition result to obtain a character sequence, where the character sequence includes sentence indexes divided by the number of layers and position indexes divided by the character sequence of the sentence to which it belongs.

[0024] Specifically, the character sequence obtained after sentence segmentation is represented as C_ocr_sentences, where the s-th sentence after segmentation is represented as C_ocr_sentences[s], and the i-th character of the s-th sentence is represented as C_ocr_sentences[s][i], where s is the sentence index, that is, the key of the CandidateSet_sentences outer dictionary in step A1 is the sentence index; i is the key of the CandidateSet_sentences inner dictionary is the character index.

[0025] Specifically, the reference text is external text material that is highly relevant to the OCR recognition result in terms of semantics or corpus, and is represented as ReferentText.

[0026] Step A3: Traverse all characters of all sentences obtained after segmentation, search for characters that can be optimized in the candidate character set, and directly optimize them before proceeding to step A7 to output the results. For characters to be optimized that are not recorded in the candidate character set, proceed to step A4. For sentences that do not require optimization, proceed directly to step A7 to output the results.

[0027] Specifically, the process of finding the required sentences includes the following steps: Step A301: Initialize the sentence index parameter of the current character sequence, setting s=0; Step A302: When s < len(C_ocr_sentences), go to Step A303; otherwise, go to Step A308; Step A303: Initialize the character index i = 0 for the current sentence; Step A304: When i < len(C_ocr_sentences[s]), go to Step A305 to process each character in sequence; otherwise, go to Step A306; Step A305: Determine whether the position (s, i) exists in the candidate character set CandidateSet_sentences and the corresponding candidate list is not empty: If not, keep the original character C_ocr_sentences[s][i] in the character sequence unchanged, execute i = i + 1, and return to Step A304 to continue processing the next character; If so, go to Step A4 for context extraction and processing; Step A306: When i ≥ len(C_ocr_sentences[s]), it means the current sentence has been processed, go to Step A307; Step A307: Execute s = s + 1, and return to Step A303 to process the next sentence; Step A308: Until s ≥ len(C_ocr_sentences), indicating that all sentences have been processed, go to Step A7 for result output; Step A4: Receive the characters to be optimized not recorded in the candidate character set, and extract the context characters for the position (s, i) of the characters to be optimized. In this embodiment, the sentence where the characters to be optimized not recorded in the candidate character set are located is the sentence that needs to be subjected to context extraction and processing.

[0028] During the process of extracting context characters, the following rules are followed: If it is the beginning of a sentence, that is, when i == 0, extract the next character C_post = C_ocr_sentences[s][i + 1]; If it is the end of a sentence, that is, when i == len(C_ocr_sentences[s]) - 1, extract the previous character C_pre = C_ocr_sentences[s][i - 1]; If it is a character in the middle of a sentence, extract both the previous character C_pre and the next character C_post.

[0029] Step A5: After extracting the context characters, perform co-occurrence statistical analysis using the external reference text ReferentText, count the adjacent characters of the context characters and construct adjacent character sets respectively, and generate a context recommended character set after merging, de-duplicating, and sorting by frequency.

[0030] Specifically, the following steps are included: When C_pre exists, count the frequencies of the characters following it and construct the character set Cand_pre[]; When C_post exists, count the frequencies of its preceding characters and construct the preceding character set Cand_post[].

[0031] Merge Cand_pre[] and Cand_post[] to remove duplicates, sort by character frequency, and generate the context recommendation character set ContextCandidates[].

[0032] Step A6: Traverse all candidate characters in the candidate character set CandidateSet_sentences[s][i]. When a candidate character appears in the context recommendation character set ContextCandidates[], update the character to the character C_ocr_sentences[s][i] at the same position in the character sequence, and terminate this round of traversal. If it does not appear, keep the character at the same position in the character sequence unchanged and terminate this round of traversal. After this round of traversal, return to step A304 to execute traversal of the next position character i=i+1.

[0033] In this embodiment, during the process of traversing the candidate character set, the traversal is performed in order of priority sequence.

[0034] Step A7: Loop through steps A304 to A6 until all sentences are processed, concatenate each sentence in the last updated character sequence C_ocr_sentences into a string, and assign it to the optimized output result FinalText as the final optimized recognition result.

[0035] Specifically, FinalText is the final OCR optimized output result after correction by the reference text context, and its type is str.

[0036] Based on OCR recognition results, this method introduces a pre-generated set of candidate characters. It then leverages the co-occurrence relationships of characters in real-world contexts within external reference texts. By counting the high-frequency collocations of characters in the context surrounding the suspected character, the method constructs the most semantically probable replacement character. Ultimately, the optimal replacement character is selected from the intersection of the candidate priority ranking and the contextual co-occurrence statistics, enabling efficient correction of character set recognition errors.

[0037] This invention automatically replaces typos for characters with similar structures and easily confused semantics, combining a co-occurrence analysis mechanism with reference text context, effectively reducing the risk of misidentification caused by character confusion. It also significantly reduces the need for manual review and intervention, improves the automation and processing efficiency of the recognition process, and enhances the system's usability and intelligence in practical applications.

[0038] The above description is merely a preferred embodiment of the present invention and does not constitute any form of limitation to the present invention. Although the present invention has been disclosed as a preferred embodiment as above, it is not intended to limit the present invention. Any person skilled in the art can make some changes or modifications to equivalent embodiments using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any indirect modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.

Claims

1. The OCR recognition result optimization method based on reference text comparison is characterized by: It includes the following steps: Step A1: Establish a candidate character set storing a number of candidate replacement characters; Step A2: Receive the OCR recognition result and the external reference text, perform sentence segmentation on the OCR recognition result to obtain a character sequence, where the character sequence includes a sentence index divided by layer and a position index divided by the character sequence of the belonging sentence; Step A3: Traverse all characters of all sentences obtained after segmentation, find the characters to be optimized in the candidate character set, directly perform optimization and then enter Step A7 for result output. For the characters to be optimized not recorded in the candidate character set, enter Step A4. For the sentences that do not need optimization, directly enter Step A7 for result output; Step A4: Receive the character to be optimized and extract the context characters at the current position of the character to be optimized; Step A5: Use the external reference text for co-occurrence statistical analysis to obtain the adjacent characters of the context characters and construct adjacent character sets respectively. After merging, de-duplicating and sorting by frequency, generate a context recommended character set; Step A6: Traverse all candidate characters in the candidate character set. When a candidate character appears in the context recommended character set, update the character to the character at the same position in the character sequence and terminate this round of traversal. If not, keep the character at the same position in the character sequence unchanged and terminate this round of traversal. After this round of traversal, return to Step A3 to perform traversal of the next position character; Step A7: Loop through Steps A3 to A6 until all sentences are processed. Concatenate each sentence in the finally updated character sequence into a string, assign it to the optimized output result as the final optimized recognition result.

2. The method for optimizing OCR recognition results based on reference text comparison according to claim 1, characterized in that: In Step A1, the candidate character set CandidateSet_sentences is a nested dictionary structure, including an outer dictionary and an inner dictionary, which is expressed as follows: The key of the outer dictionary is the sentence index, denoted as s, representing the s-th sentence, s = 0, 1, 2...; The key of the inner dictionary is the character index, denoted as i, representing the i-th character in sentence s, i = 0, 1, 2...

3. The method for optimizing OCR recognition results based on reference text comparison according to claim 2, wherein: In Step A2, the character sequence obtained after sentence segmentation is expressed as C_ocr_sentences. Among them, for the s-th sentence after segmentation, it is expressed as C_ocr_sentences[s], and the i-th character of the s-th sentence is expressed as C_ocr_sentences[s][i]. s is the sentence index same as the key of the outer dictionary, and i is the position index of the character in the sentence same as the key of the inner dictionary.

4. The method for optimizing OCR recognition results based on reference text comparison according to claim 3, wherein: In Step A3, the process of finding the required sentences includes the following steps: Step A301: Initialize the sentence index of the current character sequence, and set s = 0; Step A302: When s < len(C_ocr_sentences), enter Step A303, otherwise enter Step A308; Step A303: Initialize the character index i = 0 of the current sentence; Step A304: When i < len(C_ocr_sentences[s]), enter Step A305 to process each character in turn; otherwise enter Step A306; Step A305: Determine whether the position (s, i) exists in the candidate character set CandidateSet_sentences and the corresponding candidate list is not empty: If not, keep the original character C_ocr_sentences[s][i] in the character sequence unchanged, execute i=i+1, and return to step A304 to continue processing the next character; If yes, proceed to step A4 for context extraction and processing; Step A306: When i≥len(C_ocr_sentences[s]), proceed to step A307; Step A307: Execute s=s+1 and return to step A303 to process the next sentence; Step A308: until s≥len(C_ocr_sentences), it means that all sentences have been processed, and then go to step A7 to output the results.

5. The method for optimizing OCR recognition results based on reference text comparison according to claim 1, wherein: In step A4, during the process of extracting context characters, the following rules are followed: When the character is at the beginning of the sentence, extract the next character; If the character is at the end of the sentence, extract the previous character; Otherwise, extract both the previous and next characters.

6. The method for optimizing OCR recognition results based on reference text comparison according to claim 5, characterized in that: The implementation of step A5 includes the following steps: When there is a subsequent character, the frequency of the subsequent characters is counted to construct a subsequent character set; When there is a previous character, count the frequencies of its preceding characters and construct a preceding character set; The following character set is combined with the preceding character set to remove duplicates, and then sorted by the frequency of occurrence of the characters to generate a contextually recommended character set.

7. The method for optimizing OCR recognition results based on reference text comparison according to claim 2, wherein: The value of the inner dictionary is a pre-generated string list List[str], which represents candidate replacement characters. They are arranged in a priority sequence from high to low according to the similarity of the characters. The higher the similarity of the characters, the higher the priority sequence. In step A6, during the process of traversing the candidate character set, the traversal is performed in order of priority sequence.

Citation Information

Patent Citations

  • Text error correction method and device

    CN111126045A

  • Single-template workflow optimization method

    CN113011406A

  • Medical OCR (Optical Character Recognition) error correction method

    CN116306594A

  • Identification result error correction method and device, computer equipment and medium

    CN118072323A