Method and system for correcting OCR (Optical Character Recognition) result
By constructing a search agent and a large language model that are linked to data sources, and combining enhanced contextual information for multiple rounds of correction and verification, the problem of insufficient accuracy and reliability of OCR text correction is solved, and an efficient and flexible text correction and verification mechanism is achieved.
Patent Information
- Application Number
- CN202511925136.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-05-05
AI Technical Summary
Existing OCR text correction methods lack the ability to actively and accurately retrieve relevant information from external multi-source databases, making it difficult to handle complex contexts and professional domain texts. The correction results lack an effective verification loop, resulting in insufficient accuracy and reliability.
A search agent is constructed that connects different private and public data sources. Through a large language model combined with enhanced contextual information, multiple rounds of correction and verification are performed. The search agent dynamically retrieves and verifies the corrected text to ensure that the correction results meet the preset output requirements.
It improves the accuracy and reliability of OCR text correction, adapts to different professional fields, reduces error correction, provides multi-dimensional verification to ensure the rationality and consistency of the corrected text, and generates conflict reports to facilitate problem location and adjustment.
Smart Images

Figure CN121982733A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text processing technology, and in particular to a method and system for correcting OCR recognition results. Background Technology
[0002] Currently, OCR (Optical Character Recognition) technology is widely used. However, traditional OCR text correction methods mainly rely on the generation capabilities of rule engines, dictionary matching, or single language models, which have significant limitations. On the one hand, they lack the ability to actively and accurately retrieve relevant information from external multi-source databases, making it difficult to handle complex contexts and professional domain texts, especially when processing professional documents, ambiguous characters, or new terms, as it is difficult to obtain the necessary context for decision-making. On the other hand, the correction process is usually a one-way, single operation, and the correction result lacks an effective verification loop, which may introduce new semantic conflicts or contradict the original reliable recognition content, resulting in insufficient accuracy and reliability of the correction, and failing to meet the growing demand for high-precision OCR text. Summary of the Invention
[0003] To address the technical problem of insufficient accuracy and reliability in OCR text correction using existing technologies, this invention provides a method and system for correcting OCR recognition results.
[0004] The solution to the technical problem of this invention is to provide a method for correcting OCR recognition results, comprising the following steps: Obtain the OCR-recognized text to be corrected and preprocess it to obtain the corresponding confidence information; Construct one or more search agents, each of which is associated with a different private or public data source; The search agent retrieves search results related to the OCR-recognized text from its associated data source, and fuses different search results to obtain enhanced contextual information related to the OCR-recognized text. The OCR-recognized text is corrected using a large language model based on the enhanced context information to obtain corrected text; Based on the corrected text, the search agent performs another search and verifies whether the corrected text meets the preset output requirements based on the current search results. If it does not meet the requirements, the corrected text is updated based on the verification results until the corrected text meets the preset termination conditions, and the final corrected text is output.
[0005] Preferably, the OCR-recognized text is corrected using a large language model based on the enhanced contextual information to obtain corrected text, including the following steps: The OCR-recognized text is analyzed in conjunction with the enhanced context information, and all suspected errors in the OCR-recognized text and the reasons for these errors are output. For each suspected error, one or more correction schemes are proposed based on the enhanced context information, and the reasons for the corrections are given. According to the preset evaluation strategy, the correction scheme with the highest evaluation score is selected as the candidate correction scheme, and the candidate correction scheme is applied to the OCR-recognized text to generate the corrected text.
[0006] Preferably, retrieving search results related to the OCR-recognized text from the associated data source by the search agent includes the following steps: The OCR-recognized text is parsed to extract the parsing results containing keywords, low-confidence segments, and text topics; Based on the analysis results, at least one query scheme containing a clear retrieval intent is constructed; Each query scheme is retrieved by at least one of the search agents, and each of the search agents performs semantic retrieval and keyword retrieval on the query scheme simultaneously to obtain multiple different search results.
[0007] Preferably, before forming the enhanced context information, the following steps are further included: Determine whether the current search results are relevant to and have sufficient information sufficiency with the OCR-recognized text; If the query is deemed insufficient, a new query plan is generated based on the current query plan and the search results. The search is repeated based on the new query scheme until the current search results are sufficient to form enhanced contextual information.
[0008] Preferably, fusing different search results to obtain enhanced contextual information related to the OCR-recognized text includes the following steps: The returned search results are deduplicated, sorted, and formatted to form a coherent piece of enhanced context information.
[0009] Preferably, verifying whether the corrected text meets the preset output requirements based on the search results includes the following steps: Obtain the verification context information related to the corrected text; Verify whether the correction content in the correction text is consistent with the verification context information; Verify whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text.
[0010] Preferably, when verifying the corrected text based on the current search results, if the preset output requirements are not met, the following steps are also included: Generate a conflict report, which includes at least: The revised content that caused the conflict; An identifier indicating the type of conflict, including: inconsistency with the verification context information, or inconsistency with the high-confidence portion of the OCR-recognized text; Sources of corroborating information that led to the conflict.
[0011] Preferably, the process of acquiring and preprocessing the OCR-recognized text to be corrected includes the following steps: The OCR-recognized text is structured and segmented to output logical blocks; Extract the confidence level of the logic block and associate it with the corresponding logic block; Mark the coordinate position of each logical block on the original scanned image and establish a mapping relationship; Based on preset rules, the logic block is initially checked, and text content that conforms to preset error rules is marked.
[0012] Preferably, the termination conditions include the corrected text satisfying the preset output requirements, reaching the preset maximum number of cycles, and the corrected content of the corrected text causing an uncorrectable conflict.
[0013] To solve the above-mentioned technical problems, the present invention provides another technical solution as follows: an OCR recognition result correction system, including an input module for acquiring an original scanned image, an OCR recognition text to be corrected, and preprocessing the OCR recognition text to obtain corresponding confidence information; The context enhancement module includes a query builder, multiple search agents that associate different private or public data sources, and a result fusion unit. The query builder is used to extract key query terms from the OCR-recognized text. The search agents are used to perform search tasks based on the key query terms. The result fusion unit is used to deduplicate, sort, and format the search results output by different search agents to form a coherent enhanced context information. The multi-round reasoning and correction engine includes a potential error identifyer, a repair proposal generator, and a text synthesizer. The potential error identifyer analyzes the OCR-recognized text in conjunction with the enhanced context information and outputs all suspected errors in the OCR-recognized text and their reasons. The repair proposal generator proposes one or more correction schemes for each suspected error based on the enhanced context information and provides reasons for the correction. The text synthesizer selects the correction scheme with the highest evaluation score as a candidate correction scheme according to a preset evaluation strategy and applies the candidate correction scheme to the OCR-recognized text to generate corrected text. The iterative verification module includes a secondary searcher, a conflict detector, a consistency detector, and a decision module. The secondary searcher is used to send the corrected text back to the context enhancement module to obtain verification context information based on the corrected text. The conflict detector verifies whether the corrected content of the corrected text conflicts with the unmodified high-confidence portion of the OCR-recognized text. The consistency detector is used to verify whether the corrected content in the corrected text is consistent with the verification context information. The decision module is used to output the verification results of the conflict detector and the consistency detector. If one of the verifications fails, the corrected text is updated according to the verification result, and the updated corrected text is sent back to the multi-round inference correction engine until the verification passes, and the final corrected text is output.
[0014] Compared with the prior art, the OCR recognition result correction method and system provided by the present invention have the following beneficial effects: 1. The OCR recognition result correction method of this invention constructs a search agent that is associated with different private domain data sources and public data sources. Private domain data sources, such as internal enterprise knowledge bases, can provide information related to specific fields and businesses, while public data sources, such as the Internet and professional databases, can supplement general knowledge and cutting-edge industry information. The search agent can dynamically and accurately search for relevant domain knowledge based on different OCR-recognized texts, fundamentally making up for the knowledge shortcomings of existing large language models, making its correction decisions based on evidence, and significantly reducing error correction. At the same time, this method searches again through the search agent based on the corrected text, and verifies whether the corrected text meets the preset output requirements based on the search results. If it does not meet the requirements, the corrected text is updated until the preset termination condition is met. This iterative verification mechanism provides a quality control closed loop, ensuring that each correction is cross-validated, and the output results are more reliable. Moreover, the correction method of this embodiment does not rely on fixed rules or model parameters. It can be quickly adapted to new professional fields simply by changing or expanding the data source connected to the search agent, making it highly versatile and flexible in deployment.
[0015] 2. The OCR recognition result correction method of this invention utilizes a large language model combined with enhanced contextual information to analyze the OCR-recognized text, outputting all suspected errors and their causes. This effectively improves the accuracy of error detection, avoids overlooking potentially ignored errors, and provides more precise guidance for correction schemes. For each suspected error, one or more correction schemes are proposed based on enhanced contextual information, along with reasons for the correction. This fully considers the diversity and complexity of text, ensuring that the correction schemes better meet the needs of real-world scenarios and avoiding the risk of incorrect corrections from a single scheme. Enhanced context provides strong support for the generation of correction schemes, making the proposed correction schemes more consistent with actual contexts and professional requirements. Using a preset evaluation strategy to select the correction scheme with the highest evaluation score, such as evaluating the confidence, consistency with enhanced contextual information, and semantic fluency of all correction schemes, ensures that the final output corrected text has high quality.
[0016] 3. The OCR recognition result correction method of the present invention, by simultaneously performing semantic retrieval and keyword retrieval on the query scheme through a search agent, can obtain different types of search results from multiple perspectives, providing a richer data foundation for subsequent generation of enhanced contextual information. Semantic retrieval focuses on understanding the deeper meaning of the text, helping to solve errors caused by unclear context or ambiguous word meanings; while keyword retrieval focuses on accurately matching keywords in the text, helping to quickly locate relevant content.
[0017] 4. The OCR recognition result correction method of the present invention ensures the quality of search results used to generate enhanced contextual information by judging the relevance and information sufficiency of the search results with the OCR-recognized text. If the information is insufficient, a new query scheme is generated and executed cyclically, making the search process more intelligent and adaptive. This avoids incomplete or inaccurate contextual information caused by poor initial search results, thereby ensuring that subsequent text correction based on enhanced context is more targeted and reliable, and improving the effectiveness of the entire correction process.
[0018] 5. The OCR recognition result correction method of the present invention performs deduplication, sorting, and formatting processing on multiple search results, which can effectively integrate information from different data sources. Deduplication avoids interference from repetitive information and improves information purity; sorting can prioritize results based on factors such as relevance and reliability, facilitating subsequent use; formatting unifies search results of different formats, forming coherent enhanced contextual information.
[0019] 6. The OCR recognition result correction method of the present invention verifies whether the corrected content is consistent with the verification context information, ensuring that the corrected content conforms to the relevant knowledge background and context. Verifying whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text maintains the consistency of the original accurate content. Multi-dimensional verification of the corrected text comprehensively checks its accuracy and rationality, promptly identifies potential problems, ensures the rationality and consistency of the corrected text, and thus improves the reliability of the text correction results.
[0020] 7. The OCR recognition result correction method of the present invention generates a conflict report when the corrected text does not meet the preset output requirements. The report records in detail the correction content, conflict type, and source of supporting information for the conflict. This provides clear guidance for further analysis and resolution of conflicts. Developers or users can quickly locate the problem, understand the cause of the conflict, and adjust the correction strategy or reprocess the corrected text accordingly based on this detailed information.
[0021] 8. The OCR recognition result correction method of the present invention performs structuring and block processing on the OCR-recognized text, dividing the text into logical blocks. This helps to better understand the hierarchical structure and organizational relationships of the text, facilitating subsequent targeted processing of different parts. Extracting the confidence level of each logical block and associating it with annotations clarifies the reliability of each part's recognition, providing a basis for focusing on potentially erroneous areas. Marking the coordinate positions of the logical blocks on the original scanned image establishes a mapping relationship, facilitating backtracking to the original image for further analysis or verification when needed. Based on preset rules, the logical blocks are initially checked and potentially erroneous text content is marked, pre-screening potentially problematic parts and improving the efficiency of subsequent correction work, making the correction process more targeted.
[0022] 9. The OCR recognition result correction method of the present invention clearly defines the termination conditions as follows: the corrected text meets preset output requirements, a preset maximum number of iterations is reached, and the corrected content of the corrected text causes an uncorrectable conflict, providing a clear end standard for the correction process. Meeting preset output requirements ensures that the quality of the correction result meets expectations; reaching the preset maximum number of iterations prevents resource waste due to infinite loops and ensures that the system completes the task within a reasonable time; using the uncorrectable conflict caused by the corrected content as a termination condition avoids excessive resource consumption on unsolvable problems.
[0023] 10. This embodiment of the invention also provides an OCR recognition result correction system, which has the same beneficial effects as the OCR recognition result correction method described above, and will not be repeated here. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of steps S1-S5 of the OCR recognition result correction method provided in the first embodiment of the present invention.
[0026] Figure 2 This is a flowchart of steps S11-S14 of the OCR recognition result correction method provided in the first embodiment of the present invention.
[0027] Figure 3 This is a flowchart of steps S31-S36 of the OCR recognition result correction method provided in the first embodiment of the present invention.
[0028] Figure 4 This is a flowchart of steps S41-S43 of the OCR recognition result correction method provided in the first embodiment of the present invention.
[0029] Figure 5 This is a flowchart of steps S51-S54 of the OCR recognition result correction method provided in the first embodiment of the present invention.
[0030] Figure 6 This is a schematic diagram of the framework of the OCR recognition result correction system provided in the second embodiment of the present invention.
[0031] Figure 7 This is a schematic diagram of the framework of the OCR recognition result correction system provided in the second embodiment of the present invention. Figure 2 .
[0032] Explanation of reference numerals in the attached diagram: 1. System correction; 10. Input Module; 20. Context Enhancement Module; 30. Multi-turn Inference Correction Engine; 40. Iterative Verification Module; 201. Query Builder; 202. Search Agent; 203. Result Fuder; 301. Potential Error Detector; 302. Repair Proposal Generator; 303. Text Synthesizer; 401. Quadratic Searcher; 402. Conflict Detector; 403. Consistency Detector; 404. Decision Module. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0034] The terms “vertical,” “horizontal,” “left,” “right,” “up,” “down,” “upper left,” “upper right,” “lower left,” “lower right,” “lower left,” “lower right,” and similar expressions used in this article are for illustrative purposes only.
[0035] Please see Figure 1 The first embodiment of the present invention provides a method for correcting OCR recognition results, comprising the following steps: Step S1: Obtain the OCR-recognized text to be corrected and preprocess it to obtain the corresponding confidence information; Step S2: Construct one or more search agents, each of which is associated with a different private or public data source; Step S3: The search agent retrieves search results related to the OCR-recognized text from its associated data sources, merges different search results, and obtains enhanced contextual information related to the OCR-recognized text. Step S4: Using a large language model to correct the OCR-recognized text based on enhanced contextual information, the corrected text is obtained; Step S5: Based on the corrected text, perform another search using the search agent, and verify whether the corrected text meets the preset output requirements based on the current search results. If it does not meet the requirements, update the corrected text based on the verification results until the corrected text meets the preset termination conditions.
[0036] Understandably, the search agent in step S2 is essentially a software module or component capable of retrieving relevant information from a specific data source based on a given query scheme and preliminarily organizing the retrieval results. It possesses the ability to understand query intent, interact with different data sources, and process retrieval results. In step S2, the search agent dynamically and accurately searches for relevant domain knowledge based on different OCR-recognized texts and different characters or phrases within those texts. This fundamentally compensates for the knowledge limitations of existing large language models, providing a basis for their correction decisions and significantly reducing error correction.
[0037] Understandably, the correction method in this embodiment constructs a search agent that is associated with different private domain data sources and public data sources respectively. Private domain data sources can provide information related to specific fields and businesses, as well as some highly time-sensitive information; public data sources can retrieve general knowledge and cutting-edge industry information. Optionally, private domain data sources can be internal enterprise knowledge bases, product databases, etc., while public data sources can be the Internet, professional databases, etc.
[0038] Understandably, the correction method in this embodiment uses a large language model as an inference engine, dynamically equipping it with multiple search agents and a cyclical verification mechanism. By introducing dynamic and accurate domain knowledge and context, it fundamentally compensates for the knowledge limitations of the large model, making its correction decisions evidence-based and significantly reducing erroneous corrections. The cyclical verification mechanism ensures that each correction undergoes cross-validation, making the output results more reliable. Furthermore, the correction method in this embodiment does not rely on fixed rules or model parameters; it can be quickly adapted to new professional domains simply by changing or expanding the data source connected to the search agents, demonstrating strong versatility and flexible deployment.
[0039] Furthermore, please participate Figure 2 In step S1, the OCR-recognized text to be corrected is obtained and preprocessed, including the following steps: Step S11: Perform structuring and block-based processing on the OCR-recognized text, and output logical blocks; Step S12: Extract the confidence level of the logic block and associate it with the corresponding logic block; Step S13: Mark the coordinate position of each logic block on the original scanned image and establish a mapping relationship; Step S14: Based on preset rules, perform a preliminary check on the logic block and mark the text content that conforms to the preset error rules.
[0040] Understandably, in step S11, the OCR-recognized text is structured and segmented. This involves logically reorganizing the text—whether arranged arbitrarily or only in rows—based on layout analysis results, identifying and dividing it into logical blocks such as titles, paragraphs, and tables. This helps to better understand the hierarchical structure and organizational relationships of the text, facilitating targeted processing of different parts later. In step S12, the confidence level of each logical block is extracted and associated with annotations, clarifying the reliability of each part's recognition and providing a basis for focusing on potentially erroneous areas. In step S13, the coordinate positions of the marked logical blocks on the original scanned image are established to create a mapping relationship, facilitating backtracking to the original image for further analysis or verification when needed. In step S14, the preset rules should be a set of fast-executable, lightweight rules to initially screen for obvious anomalies in the OCR-recognized text, such as non-numeric characters in date fields or incorrect formatting in amount fields. Early screening of potentially problematic parts serves as high-priority clues in the subsequent correction process, improving efficiency and making the correction process more targeted.
[0041] Please refer to further information. Figure 3 In step S3, the search agent retrieves search results related to the OCR-recognized text from its associated data source, including the following steps: Step S31: Parse the OCR-recognized text and extract the parsing results containing keywords, low-confidence segments, and text topics; Step S32: Based on the parsing results, construct at least one query scheme containing a clear retrieval intent; Step S33: Each query solution is retrieved through at least one search agent, and each search agent performs semantic retrieval and keyword retrieval on the query solution simultaneously to obtain multiple different search results.
[0042] Understandably, in step S32, a query scheme is constructed based on the parsing results of step S31, and different query schemes can be triggered according to the specific OCR text. Specifically, this dynamic retrieval process can be implemented through a large language model, mimicking the human cognitive process of understanding first and then making a decision, to determine a reasonable query scheme.
[0043] For example, when OCR recognizes text containing "the 2023 Nobel Prize in Physics laureate is XX", the search agent will generate the following thought: "The user needs to verify a fact. To verify 'the Nobel Prize in Physics laureate,' my internal knowledge may be outdated or inaccurate. I should use the 'search tool,' and the keyword can be set to 'the 2023 Nobel Prize in Physics laureate.'" Optionally, in step S32, the low-confidence parsing results can be used as the priority query terms in the query scheme.
[0044] Understandably, in step S33, multiple search agents can be selected to search for the same query, and each search agent simultaneously performs semantic retrieval and keyword retrieval on the query. This allows for the acquisition of different types of search results from multiple perspectives, providing a richer data foundation for subsequently generating enhanced contextual information. Semantic retrieval converts both the query and the OCR-recognized text into vectors, finding semantically similar content within the relevant vector space. This focuses on understanding the deeper meaning of the text and helps resolve errors caused by unclear context or semantic ambiguity. Keyword retrieval, on the other hand, focuses on accurately matching keywords in the text, facilitating the rapid location of relevant content.
[0045] Optionally, the search agent can rewrite or expand the query before issuing a search instruction to improve retrieval accuracy. For example, the colloquial phrase "new Apple products" can be expanded to "the latest iPhone models released by Apple".
[0046] For further information, please refer to [link / reference]. Figure 3 In step S3, before forming the enhanced context information, the following steps are also included: Step S34: Determine whether the current search results are relevant to the OCR-recognized text and whether the information sufficiency is sufficient; Step S35: If the query is deemed insufficient, a new query plan is generated based on the current query plan and search results. Step S36: Repeat steps S33-S35 above, and search again based on the new query scheme until the current search results are sufficient to form enhanced contextual information.
[0047] Understandably, steps S34-S36 provide a process for deepening the search, making the search process more intelligent and adaptive. This avoids incomplete or inaccurate contextual information caused by a poor search result, thus ensuring that subsequent text correction based on enhanced context is more targeted and reliable, and improving the effectiveness of the entire correction process.
[0048] Furthermore, in step S3, the different search results are fused to obtain enhanced contextual information related to the OCR-recognized text, including the following steps: Step S37: Deduplicate, sort, and format the returned multiple search results to form a coherent enhanced contextual information.
[0049] Understandably, deduplication avoids interference from duplicate information and improves information purity; sorting prioritizes results based on factors such as relevance and reliability, making them easier to use later; and formatting unifies search results from different formats, forming coherent and enhanced contextual information.
[0050] Understandably, when performing step S37, priority can be given to content from authoritative sources, such as official websites and academic sites, or to content with higher timeliness. Simultaneously, cross-validation of search results from multiple sources can be performed to ensure that the enhanced contextual information has a higher relevance to the OCR-recognized text. Specifically, the fusion process in step S37 can be implemented using an algorithm, such as the RRF (Reciprocal Rank Fusion) algorithm, to ensure recall and accuracy.
[0051] Please refer to further information. Figure 4 In step S4, the OCR-recognized text is corrected using a large language model based on enhanced contextual information to obtain the corrected text, including the following steps: Step S41: Analyze the OCR-recognized text by combining enhanced contextual information, and output all suspected errors in the OCR-recognized text and the reasons for these errors; Step S42: For each suspected error, propose one or more correction schemes based on enhanced contextual information, and provide reasons for the corrections; Step S43: According to the preset evaluation strategy, select the correction scheme with the highest evaluation score as the candidate correction scheme, apply the candidate correction scheme to the OCR recognition text, and generate the corrected text.
[0052] Understandably, in step S41, outputting all suspected errors and their causes during the analysis can effectively improve the accuracy of error detection, avoid missing errors that may be overlooked, and provide more precise guidance for generating subsequent correction plans.
[0053] Understandably, in step S42, proposing one or more correction schemes for each suspected error and providing reasons for the corrections fully considers the diversity and complexity of OCR-recognized text, ensuring that the correction schemes better meet the needs of real-world scenarios and avoid the risk of incorrect corrections caused by a single scheme. Furthermore, enhanced context provides strong support for the generation of correction schemes, making the proposed correction schemes more consistent with the actual context and professional requirements.
[0054] Optionally, in step S43, the preset evaluation strategy can be one or more of the following: evaluating the confidence of all correction schemes, the degree of fit with the enhanced context information, and semantic fluency. This ensures that the final output corrected text has high quality. Please refer to further information. Figure 5 In step S5, the process of verifying whether the corrected text meets the preset output requirements based on the search results includes the following steps: Step S51: Obtain the verification context information related to the corrected text; Step S52: Verify whether the correction content in the correction text is consistent with the verification context information; Step S53: Verify whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text.
[0055] Understandably, in steps S51-S52, verifying whether the corrected content is consistent with the verification context information ensures that the corrected content conforms to the relevant knowledge background and context. In step S53, verifying whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text maintains the consistency of the original accurate content.
[0056] Understandably, multi-dimensional verification of the revised text can comprehensively check its accuracy and rationality, promptly identify potential problems, ensure the rationality and consistency of the revised text, and thus improve the reliability of the text revision results.
[0057] Understandably, step S5 can be specifically defined as follows: Step S501: Based on the corrected text, perform another search using the search agent to obtain the verification context information related to the corrected text; Step S502: Determine whether the corrected content in the corrected text is consistent with the verification context information, and detect whether the corrected content conflicts with the unmodified high-confidence part of the OCR-recognized text; Step S503: If it is determined that there is an inconsistency or conflict, the corrected text is updated according to the judgment and detection results to obtain the updated OCR text. Then, the subsequent steps since the generation of the corrected text are re-executed based on the updated OCR text until the corrected text meets the preset termination conditions.
[0058] For further information, please refer to [link / reference]. Figure 5 In step S5, if the text correction does not meet the preset output requirements when verifying it based on the current search results, the following steps are also included: Step S54: Generate a conflict report, which includes at least: the corrections for the conflict, an identifier indicating the type of conflict, and the source of supporting information that caused the conflict; wherein, the conflict type includes: inconsistency with the verification context information, or inconsistency with the high-confidence portion of the OCR-recognized text.
[0059] Understandably, conflict reports provide clear guidance for further analysis and resolution of conflicts. Based on the detailed information in the conflict report, personnel or users can quickly locate the problem, understand the cause of the conflict, and adjust correction strategies or reprocess the corrected text accordingly.
[0060] Furthermore, in step S5, the termination conditions include the corrected text meeting the preset output requirements, reaching the preset maximum number of loops, and the corrected content of the corrected text causing an uncorrectable conflict.
[0061] Understandably, the termination condition is meeting the preset output requirements, i.e., successful termination upon successful verification of the corrected text, ensuring that the quality of the corrected result meets expectations. The termination condition is reaching the preset maximum number of loop iterations, preventing resource waste due to infinite loops and ensuring the system completes the task within a reasonable timeframe. The correction termination condition is when the content triggers an uncorrectable conflict, avoiding excessive resource consumption on unsolvable problems.
[0062] Optionally, a validation pass can be defined as two consecutive rounds of verification without finding any new potential errors. If the validation terminates due to reaching the preset maximum number of iterations or when the corrected text causes uncorrectable conflicts, a marker requiring manual review can be added to the output for easier subsequent manual verification.
[0063] Please see Figure 6 and Figure 7The second embodiment of the present invention provides an OCR recognition result correction system 1 for implementing the above-mentioned method for OCR recognition result, including an input module 10, a context enhancement module 20, a multi-round inference correction engine 30, and an iterative verification module 40.
[0064] The input module 10 is used to acquire the original scanned image, the OCR recognition text to be corrected, and to preprocess the OCR recognition text to obtain the corresponding confidence information.
[0065] The context enhancement module 20 includes a query builder 201, multiple search agents 202 associated with different private or public data sources, and a result fusion unit 203. The query builder 201 extracts key query terms from the OCR-recognized text; the search agents 202 execute search tasks based on the key query terms; and the result fusion unit 203 deduplicates, sorts, and formats the search results output by different search agents 202 to form a coherent enhanced contextual information.
[0066] The multi-round reasoning correction engine 30 includes a potential error detector 301, a repair proposal generator 302, and a text synthesizer 303. The potential error detector 301 analyzes the OCR-recognized text using enhanced contextual information, outputting all suspected errors in the OCR-recognized text and their reasons. The repair proposal generator 302 proposes one or more correction schemes for each suspected error based on enhanced contextual information, providing reasons for the correction. The text synthesizer 303 selects the correction scheme with the highest evaluation score as a candidate correction scheme according to a preset evaluation strategy, applies the candidate correction scheme to the OCR-recognized text, and generates the corrected text.
[0067] The iterative verification module 40 includes a secondary searcher 401, a conflict detector 402, a consistency detector 403, and a decision module 404. The secondary searcher 401 re-enters the corrected text into the context enhancement module 20 to obtain verification context information based on the corrected text. The conflict detector 402 verifies whether the corrected content of the corrected text conflicts with the unmodified high-confidence portion of the OCR-recognized text. The consistency detector 403 verifies whether the corrected content in the corrected text is consistent with the verification context information. The decision module 404 outputs the verification results of the conflict detector 402 and the consistency detector 403. If either verification fails, the corrected text is updated based on the verification result, and the updated corrected text is re-entered into the multi-round inference correction engine 30 until verification passes, at which point the final corrected text is output.
[0068] The following is a specific example of the correction process based on correction system 1 in this embodiment: The OCR-recognized text to be corrected obtained by input module 10 is as follows: "Banker's Acceptance Bill" Full name of the drawer: **** Intelligent Manufacturing Co., Ltd. Drawer's account number: 310********8888 Full name of the paying bank: **** Bank **** Sub-branch Full name of the payee: **** Semiconductor Co., Ltd. Bill amount (in lowercase): ¥1,000,000.00 Bill amount (in uppercase): One million yuan in total Issuance date: September 15, 2023 Bill maturity date: September 15, 2024 Bill number: AB2023*******B".
[0069] The query constructor 201 of the context enhancement module 20 extracts key query terms, such as "**** Bank" (obviously suspicious), "**** Intelligent Manufacturing", "**** Semiconductor", and "Bill number AB2023*******B".
[0070] Retrieve the "Enterprise Customer Directory" from the private data source through different search agents 202 to confirm that "**** Intelligent Manufacturing Co., Ltd." and "**** Semiconductor Co., Ltd." are cooperative customers. Retrieve the "List of Cooperative Banks" to confirm that "**** Bank **** Sub-branch" is a cooperative bank. Search for the "Banker's Acceptance Bill Capital Amount Specification" from the public data source to confirm that the correct writing should be "whole" instead of "positive". Search for the official name of "**** Bank" to exclude the common OCR error of "Bank".
[0071] The result integrator 203 de-duplicates, sorts, and formats the search results output by different search agents 202, and outputs enhanced context: "Known information: 1. Both '**** Intelligent Manufacturing Co., Ltd.' and '**** Semiconductor Co., Ltd.' are valid cooperative customers. 2. The correct bank name is '**** Bank', and 'Bank' is a common OCR error. 3. The bill capital amount specification ends with 'whole'. 4. The bill date format is usually 'YYYY年MM月DD日'." The multi-round reasoning correction engine 30 performs the first round of reasoning correction. First, the potential error recognizer 301 inputs the above initial OCR text and enhanced context, and the recognition output is: "Bank" conflicts with the known correct name "Bank", suspected of misrecognition of "工".
[0072] According to the amount specification, "positive" is suspected of misrecognition of "whole".
[0073] "In" in the date field is unreasonable and is suspected to be a misrecognition of "year".
[0074] "Su" (in "person who issues su") should be the common word "ticket", suspected to be misrecognized due to similar glyphs.
[0075] "Zai" (in "person who receives zai") should be the common word "kuan", suspected to be misrecognized due to similar glyphs.
[0076] Then the repair proposal generator 302 proposes correction solutions based on the suspected errors and enhanced context as follows: Correct "hen xing" to "bank", because the enhanced context provides the correct name.
[0077] Correct "zheng" to "zheng", because the enhanced context provides the amount writing specification.
[0078] Correct "zai" to "year", because this is the standard format for the date field.
[0079] Correct "su" to "ticket" and "zai" to "kuan", based on the common sense of the fixed field names "drawer" and "payee".
[0080] Finally, the text synthesizer 303 outputs the corrected text: "Bank acceptance bill Full name of drawer: **** Intelligent Manufacturing Co., Ltd. Drawer's account number: 310********8888 Full name of paying bank: **** Bank **** Sub-branch Full name of payee: **** Semiconductor Co., Ltd. Bill amount (in lowercase): ¥1,000,000.00 Bill amount (in uppercase): One million yuan in total Issue date: September 15, 2023 <a Bill maturity date: September 15, 2024 Bill number: AB2023*******B".
[0081] The iterative verification module 40 activates the secondary searcher 401 and sends the current corrected text to the search agent 202 again. The search agent queries more precisely in the private domain bill system according to the corrected text: "Bill number AB2023*******B status", "**** Intelligent Manufacturing issues a bill to **** Semiconductor".
[0082] The conflict detector 402 is verified and confirms the following: 1. The private domain bill system returns that there is indeed a bill of exchange with the bill number AB2023*******B. The information of the drawer and the payee matches, but the recorded amount is 1,000,000.00 yuan. This is consistent with the lowercase amount recognized by OCR, and the corresponding capital amount is "One million yuan in total". 2. Check the alphanumeric characters in "AB2023*******B". 'B' at the end may be suspected, but the retrieved real bill number is a perfect match, so it is confirmed to be correct. 3. Check whether all corrections conflict with the high-confidence parts in the original OCR (such as the clear lowercase amount number "1,000,000.00"). That is, the conflict detector 402 does not find that the corrected text conflicts with the verification context information, nor does it find that the corrected text conflicts with the unmodified high-confidence parts, and outputs the verification result: Passed.
[0083] Finally, output the current corrected text as the final correction result.
[0084] Understandably, the OCR recognition result correction system 1 in this embodiment includes all the beneficial effects of the above OCR recognition result correction method, which will not be elaborated here.
[0085] In the embodiments provided by the present invention, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.
[0086] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present invention. Therefore, the "in one embodiment" or "in an embodiment" that appears throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to the present invention.
[0087] In various embodiments of the present invention, it should be understood that the size of the serial numbers of the above processes does not necessarily mean the inevitable sequence of execution. The execution sequence of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0088] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It is particularly important to note that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0089] Compared with the prior art, the OCR recognition result correction method and system provided by the present invention have the following beneficial effects: 1. The OCR recognition result correction method of this invention constructs a search agent that is associated with different private domain data sources and public data sources. Private domain data sources, such as internal enterprise knowledge bases, can provide information related to specific fields and businesses, while public data sources, such as the Internet and professional databases, can supplement general knowledge and cutting-edge industry information. The search agent can dynamically and accurately search for relevant domain knowledge based on different OCR-recognized texts, fundamentally making up for the knowledge shortcomings of existing large language models, making its correction decisions based on evidence, and significantly reducing error correction. At the same time, this method searches again through the search agent based on the corrected text, and verifies whether the corrected text meets the preset output requirements based on the search results. If it does not meet the requirements, the corrected text is updated until the preset termination condition is met. This iterative verification mechanism provides a quality control closed loop, ensuring that each correction is cross-validated, and the output results are more reliable. Moreover, the correction method of this embodiment does not rely on fixed rules or model parameters. It can be quickly adapted to new professional fields simply by changing or expanding the data source connected to the search agent, making it highly versatile and flexible in deployment.
[0090] 2. The OCR recognition result correction method of this invention utilizes a large language model combined with enhanced contextual information to analyze the OCR-recognized text, outputting all suspected errors and their causes. This effectively improves the accuracy of error detection, avoids overlooking potentially ignored errors, and provides more precise guidance for correction schemes. For each suspected error, one or more correction schemes are proposed based on enhanced contextual information, along with reasons for the correction. This fully considers the diversity and complexity of text, ensuring that the correction schemes better meet the needs of real-world scenarios and avoiding the risk of incorrect corrections from a single scheme. Enhanced context provides strong support for the generation of correction schemes, making the proposed correction schemes more consistent with actual contexts and professional requirements. Using a preset evaluation strategy to select the correction scheme with the highest evaluation score, such as evaluating the confidence, consistency with enhanced contextual information, and semantic fluency of all correction schemes, ensures that the final output corrected text has high quality.
[0091] 3. The OCR recognition result correction method of the present invention, by simultaneously performing semantic retrieval and keyword retrieval on the query scheme through a search agent, can obtain different types of search results from multiple perspectives, providing a richer data foundation for subsequent generation of enhanced contextual information. Semantic retrieval focuses on understanding the deeper meaning of the text, helping to solve errors caused by unclear context or ambiguous word meanings; while keyword retrieval focuses on accurately matching keywords in the text, helping to quickly locate relevant content.
[0092] 4. The OCR recognition result correction method of the present invention ensures the quality of search results used to generate enhanced contextual information by judging the relevance and information sufficiency of the search results with the OCR-recognized text. If the information is insufficient, a new query scheme is generated and executed cyclically, making the search process more intelligent and adaptive. This avoids incomplete or inaccurate contextual information caused by poor initial search results, thereby ensuring that subsequent text correction based on enhanced context is more targeted and reliable, and improving the effectiveness of the entire correction process.
[0093] 5. The OCR recognition result correction method of the present invention performs deduplication, sorting, and formatting processing on multiple search results, which can effectively integrate information from different data sources. Deduplication avoids interference from repetitive information and improves information purity; sorting can prioritize results based on factors such as relevance and reliability, facilitating subsequent use; formatting unifies search results of different formats, forming coherent enhanced contextual information.
[0094] 6. The OCR recognition result correction method of the present invention verifies whether the corrected content is consistent with the verification context information, ensuring that the corrected content conforms to the relevant knowledge background and context. Verifying whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text maintains the consistency of the original accurate content. Multi-dimensional verification of the corrected text comprehensively checks its accuracy and rationality, promptly identifies potential problems, ensures the rationality and consistency of the corrected text, and thus improves the reliability of the text correction results.
[0095] 7. The OCR recognition result correction method of the present invention generates a conflict report when the corrected text does not meet the preset output requirements. The report records in detail the correction content, conflict type, and source of supporting information for the conflict. This provides clear guidance for further analysis and resolution of conflicts. Developers or users can quickly locate the problem, understand the cause of the conflict, and adjust the correction strategy or reprocess the corrected text accordingly based on this detailed information.
[0096] 8. The OCR recognition result correction method of the present invention performs structuring and block processing on the OCR-recognized text, dividing the text into logical blocks. This helps to better understand the hierarchical structure and organizational relationships of the text, facilitating subsequent targeted processing of different parts. Extracting the confidence level of each logical block and associating it with annotations clarifies the reliability of each part's recognition, providing a basis for focusing on potentially erroneous areas. Marking the coordinate positions of the logical blocks on the original scanned image establishes a mapping relationship, facilitating backtracking to the original image for further analysis or verification when needed. Based on preset rules, the logical blocks are initially checked and potentially erroneous text content is marked, pre-screening potentially problematic parts and improving the efficiency of subsequent correction work, making the correction process more targeted.
[0097] 9. The OCR recognition result correction method of the present invention clearly defines the termination conditions as follows: the corrected text meets preset output requirements, a preset maximum number of iterations is reached, and the corrected content of the corrected text causes an uncorrectable conflict, providing a clear end standard for the correction process. Meeting preset output requirements ensures that the quality of the correction result meets expectations; reaching the preset maximum number of iterations prevents resource waste due to infinite loops and ensures that the system completes the task within a reasonable time; using the uncorrectable conflict caused by the corrected content as a termination condition avoids excessive resource consumption on unsolvable problems.
[0098] 10. This embodiment of the invention also provides an OCR recognition result correction system, which has the same beneficial effects as the OCR recognition result correction method described above, and will not be repeated here.
[0099] The above provides a detailed description of an OCR recognition result correction method and system disclosed in the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention. Any modifications, equivalent substitutions, and improvements made within the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for correcting OCR recognition results, characterized in that: Includes the following steps: Obtain the OCR-recognized text to be corrected and preprocess it to obtain the corresponding confidence information; Construct one or more search agents, each of which is associated with a different private or public data source; The search agent retrieves search results related to the OCR-recognized text from its associated data source, and fuses different search results to obtain enhanced contextual information related to the OCR-recognized text. The OCR-recognized text is corrected using a large language model based on the enhanced context information to obtain corrected text; Based on the corrected text, the search agent performs another search and verifies whether the corrected text meets the preset output requirements based on the current search results. If it does not meet the requirements, the corrected text is updated based on the verification results until the corrected text meets the preset termination conditions, and the final corrected text is output.
2. The method for correcting OCR recognition results as described in claim 1, characterized in that: Using a large language model to correct the OCR-recognized text based on the enhanced context information, the corrected text is obtained, including the following steps: The OCR-recognized text is analyzed in conjunction with the enhanced context information, and all suspected errors in the OCR-recognized text and the reasons for these errors are output. For each suspected error, one or more correction schemes are proposed based on the enhanced context information, and the reasons for the corrections are given. According to the preset evaluation strategy, the correction scheme with the highest evaluation score is selected as the candidate correction scheme, and the candidate correction scheme is applied to the OCR-recognized text to generate the corrected text.
3. The method for correcting OCR recognition results as described in claim 1, characterized in that: The search agent retrieves search results related to the OCR-recognized text from its associated data source, including the following steps: The OCR-recognized text is parsed to extract the parsing results containing keywords, low-confidence segments, and text topics; Based on the analysis results, at least one query scheme containing a clear retrieval intent is constructed; Each query scheme is retrieved by at least one of the search agents, and each of the search agents performs semantic retrieval and keyword retrieval on the query scheme simultaneously to obtain multiple different search results.
4. The method for correcting OCR recognition results as described in claim 3, characterized in that: Before forming the enhanced context information, the following steps are also included: Determine whether the current search results are relevant to and have sufficient information sufficiency with the OCR-recognized text; If the query is deemed insufficient, a new query plan is generated based on the current query plan and the search results. The search is repeated based on the new query scheme until the current search results are sufficient to form enhanced contextual information.
5. The method for correcting OCR recognition results as described in claim 1, characterized in that: The process of fusing different search results to obtain enhanced contextual information related to the OCR-recognized text includes the following steps: The returned search results are deduplicated, sorted, and formatted to form a coherent piece of enhanced context information.
6. The method for correcting OCR recognition results as described in claim 1, characterized in that: Verifying whether the corrected text meets the preset output requirements based on the search results includes the following steps: Obtain the verification context information related to the corrected text; Verify whether the correction content in the correction text is consistent with the verification context information; Verify whether the corrected content conflicts with the unmodified high-confidence portion of the OCR-recognized text.
7. The method for correcting OCR recognition results as described in claim 6, characterized in that: When verifying the corrected text based on the current search results, if the preset output requirements are not met, the following steps are also included: Generate a conflict report, which includes at least: The revised content that caused the conflict; An identifier indicating the type of conflict, including: inconsistency with the verification context information, or inconsistency with the high-confidence portion of the OCR-recognized text; Sources of corroborating information that led to the conflict.
8. The method for correcting OCR recognition results as described in claim 1, characterized in that: Obtain the OCR-recognized text to be corrected and preprocess it, including the following steps: The OCR-recognized text is structured and segmented to output logical blocks; Extract the confidence level of the logic block and associate it with the corresponding logic block; Mark the coordinate position of each logical block on the original scanned image and establish a mapping relationship; Based on preset rules, the logic block is initially checked, and text content that conforms to preset error rules is marked.
9. The method for correcting OCR recognition results as described in claim 1, characterized in that: The termination conditions include the corrected text meeting the preset output requirements, reaching the preset maximum number of loops, and the corrected content of the corrected text causing an uncorrectable conflict.
10. A system for correcting OCR recognition results, characterized in that: It includes an input module for acquiring the original scanned image, the OCR-recognized text to be corrected, and preprocessing the OCR-recognized text to obtain corresponding confidence information; The context enhancement module includes a query builder, multiple search agents that associate different private or public data sources, and a result fusion unit. The query builder is used to extract key query terms from the OCR-recognized text. The search agents are used to perform search tasks based on the key query terms. The result fusion unit is used to deduplicate, sort, and format the search results output by different search agents to form a coherent enhanced context information. The multi-round reasoning correction engine includes a potential error identifyer, a repair proposal generator, and a text synthesizer. The potential error identifyer is used to analyze the OCR-recognized text in conjunction with the enhanced context information and output all suspected errors in the OCR-recognized text and the reasons for the doubts. The repair proposal generator is used to propose one or more correction schemes for each suspected error based on the enhanced context information, and to provide reasons for the correction; The text synthesizer is used to select the correction scheme with the highest evaluation score as a candidate correction scheme according to a preset evaluation strategy, and apply the candidate correction scheme to the OCR-recognized text to generate corrected text; The iterative verification module includes a secondary searcher, a conflict detector, a consistency detector, and a decision module. The secondary searcher is used to send the corrected text back into the context enhancement module to obtain verification context information based on the corrected text. The conflict detector verifies whether the corrected content of the corrected text conflicts with the unmodified high-confidence portion of the OCR-recognized text; The consistency detector is used to verify whether the correction content in the correction text is consistent with the verification context information; The determination module is used to output the verification results of the conflict detector and the consistency detector. If one of them fails the verification, the corrected text is updated according to the verification result, and the updated corrected text is sent back to the multi-round inference correction engine until the verification passes, and the final corrected text is output.
