An OCR error correction method and device based on a knowledge base and a storage medium

By constructing a knowledge base R and a character matrix P, and combining word segmentation and character-by-character replacement techniques, the problems of low recognition accuracy and unreliability in existing OCR methods are solved, achieving higher recognition accuracy and fault tolerance.

CN116092083BActive Publication Date: 2026-02-06CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310030516.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-10
Publication Date
2026-02-06
Estimated Expiration
2043-01-10

AI Technical Summary

Technical Problem

Existing OCR recognition methods have shortcomings in accuracy and reliability. Especially in scenarios where high accuracy is required, character recognition errors can lead to serious consequences. Furthermore, existing error correction methods do not consider glyph search, resulting in unreliable matching results.

Method used

A knowledge-based OCR error correction method is constructed. This method involves building a character matrix P and performing word segmentation, then using the knowledge base R for matching and replacement. Characters are replaced one by one to correct errors, and the words with the smallest edit distance are used for matching to ensure recognition accuracy.

Benefits of technology

It improves the accuracy and fault tolerance of the recognition results, ensuring that the recognition results are more reliable, and solves the problem of low accuracy and unreliability of matching results in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116092083B_ABST
    Figure CN116092083B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on knowledge base's OCR error correction method, device and storage medium, it is related to computer vision and image text recognition technical field.The based on knowledge base's OCR error correction method includes the following steps: according to the object of optical character recognition application, constructs knowledge base R;Text picture is identified using optical character recognition technology, constructs character matrix P;The string of first row in character matrix P is tokenized;The tokenization obtained is matched with knowledge base R in turn, if tokenization is in knowledge base R, then it is correct, and no error correction is needed;If tokenization is not in knowledge base R, then tokenization is replaced according to the word in knowledge base R, when new word appears in knowledge base R, then error correction is completed.The application uses glyph search in the process of optical character recognition result, reaches more effectively and reliably to optical character recognition result is corrected, solves the problem that matching result accuracy is low and unreliable.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer vision and image text recognition, and particularly relates to an OCR error correction method and device based on a knowledge base and a storage medium. BACKGROUND

[0002] Optical Character Recognition (OCR) refers to a process of analyzing and recognizing an image file of text data to obtain text and layout information. OCR is widely used in scenarios such as certificate content recognition, bill content recognition, and book content recognition, and is one of the key technologies for computer automation.

[0003] The existing error correction of the recognition result is generally performed by sampling, photographing, or other optical input means to scan paper documents or historical documents into electronic images, obtaining text information therein, converting the text information into computer-operable text by using various pattern recognition algorithms, and performing dictionary matching on the recognition result to replace it with a similar word.

[0004] However, the present inventors have found that the above-mentioned technology has at least the following technical problems in the process of implementing the technical solutions of the embodiments of the present application.

[0005] The existing recognition effect is limited by the scanning effect, the quality of the printed matter (clarity, font, and text layout), and the accuracy of the recognition algorithm. However, the overall recognition rate of OCR is not always satisfactory. In some scenarios with high accuracy requirements, a recognition error of a single character will cause serious consequences. Moreover, the existing error correction method does not consider using a font search, resulting in unreliable matching results. In summary, the existing technology has the problem of low and unreliable accuracy of matching results. SUMMARY

[0006] The embodiments of the present application provide an OCR error correction method and device based on a knowledge base and a storage medium, which solve the technical problem of low and unreliable accuracy of matching results in the prior art, and achieve improved accuracy and fault tolerance of the recognition method.

[0007] The embodiments of the present application provide an OCR error correction method based on a knowledge base, which includes the following steps:

[0008] S1, constructing a knowledge base R according to the object of an optical character recognition application;

[0009] S2, recognizing a text picture using an optical character recognition technology to construct a character matrix P;

[0010] S3, performing word segmentation on a string in the first row of the character matrix P;

[0011] S4. Match the obtained word segments with the words in the knowledge base R in turn. If the word segment is in the knowledge base R, the recognition is correct and no error correction is needed.

[0012] If the word segment is not in the knowledge base R, then the word segment is matched and replaced according to the words in the knowledge base R. When the new word appears in the knowledge base R, the error correction is completed.

[0013] Furthermore, the objects of the identification application in S1 include ID cards, business licenses, and invoices.

[0014] Furthermore, in S1, the knowledge base R is constructed by using prior knowledge to build the possible words, phrases, and adverbs into the knowledge base R.

[0015] Furthermore, in S2, the size of the character matrix P is K*L, where K retains the K most probable characters at each position, and L is the length of the recognized text.

[0016] Furthermore, the process of obtaining the character matrix P is as follows: based on each character 'a' in the recognized text... i Given i = 1, ..., L, we obtain K possible characters sorted by probability from smallest to largest. Record the result as

[0017] Furthermore, the string in the first line of S3 is (P i 1 ), i = 1……L, the resulting word segments are w1, w2,……, w c , where c is the number of word segments.

[0018] Furthermore, the specific process of matching and replacing in S4 is as follows:

[0019] S41, Search for the word segmentation w in knowledge base R. n Find the word r with the smallest edit distance, where n = 1 ... c;

[0020] S42, compare w respectively n With each character of r, w n The characters in the middle that do not correspond to the position of r are replaced with the characters with the i-th highest probability, forming the new word w. ’ , where i = 2...K;

[0021] S43, Determine the new word w ’ Check if it is the same as r. If not, return to step two. If they are the same, the error correction is complete.

[0022] If new word w ’ If it is not the same as r, return to step two and continue the replacement. When the replacement reaches i = K, the new word w is... ’If r is not the same as r, then stop error correction, keep the original word, and report error correction failure.

[0023] Further, the word r with the minimum edit distance in step one includes one or more words with an edit distance of 1.

[0024] Embodiments of the present application provide an OCR error correction device based on a knowledge base, comprising a pre-modeling module, an identification module, a word segmentation module, and an error correction module:

[0025] The pre-modeling module is configured to construct a knowledge base R according to an object of an optical character recognition application.

[0026] The identification module is configured to identify a text picture using an optical character recognition technique to construct a character matrix P.

[0027] The word segmentation module is configured to segment a string in the first row of the character matrix P.

[0028] The error correction module is configured to sequentially match the obtained word segmentation with the knowledge base R, and if the word segmentation is in the knowledge base R, the identification is correct and no error correction is needed.

[0029] If the word segmentation is not in the knowledge base R, the word segmentation is matched and replaced according to the words in the knowledge base R, and when the new word appears in the knowledge base R, the error correction is completed.

[0030] Embodiments of the present application provide a computer-readable storage medium for storing a program, which is executed by a processor to implement an OCR error correction method based on a knowledge base.

[0031] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0032] 1. Since the words, phrases, adverbs, etc. that can appear in the scene are constructed into a knowledge base R according to the object of the optical character recognition application, and a character matrix P is constructed, and the words are segmented and then matched and replaced, the matching result is closer to the scene, and the original words can be replaced word by word, effectively solving the problem of low accuracy and unreliability of existing matching results, and thus improving the accuracy and fault tolerance of the identification result.

[0033] 2. Since the technology of retaining the top K characters with the highest probability at each position as candidate characters is adopted, the range of selectable characters for matching and replacing the word segmentation is expanded, effectively solving the problem of inaccurate identification result caused by directly selecting the character with the highest probability according to the dictionary in existing error correction methods, and thus making the identification result more accurate and reliable.

[0034] 3. Since the characters of w n and r are compared respectively, w nThe characters inconsistent with the position corresponding to r are replaced by the characters with the i-th (i=1…K) largest probability, respectively, to form a new word w ’ The technology enables replacement in the order of i=1 to i=K when performing word segmentation replacement, effectively solves the problem that the existing error correction method cannot well select when matching to multiple words with the same similarity, and further realizes more ordered selection of words when error correction matching. BRIEF DESCRIPTION OF DRAWINGS

[0035] Figure 1 A knowledge base-based OCR error correction method flowchart is provided for the first embodiment of the application;

[0036] Figure 2 A flowchart of a specific error correction process is provided for the first embodiment of the application;

[0037] Figure 3 An identity card example diagram is provided for the first embodiment of the application;

[0038] Figure 4 A recognition object diagram is provided for the first embodiment of the application;

[0039] Figure 5 A character matrix P diagram is provided for the first embodiment of the application;

[0040] Figure 6 A knowledge base-based OCR error correction device structure diagram is provided for the second embodiment of the application. DETAILED DESCRIPTION

[0041] The embodiments of the application provide a knowledge base-based OCR error correction method, device and storage medium, solve the problem of low accuracy and unreliability of matching results in the prior art, and use glyph search in an optical character recognition process to improve the accuracy of recognition results, so that the results are more reliable.

[0042] The technical solution in the embodiments of the application is to solve the problem of low accuracy and unreliability of matching results, and the general idea is as follows:

[0043] According to the object of the optical character recognition application, the prior knowledge is used to construct a knowledge base R for possible words, word groups, adverbs, etc., and then the OCR technology is used to recognize the text picture, the character matrix P is constructed according to the result of glyph search, then K possible matching successful characters are reserved in descending order of probability, then the first row of the character matrix P is segmented, and the obtained segmentation is compared with the words r in the knowledge base R with an edit distance of 1, if they are the same, the recognition is correct, that is, no error correction is needed, if they are not the same, the K reserved characters are replaced with the characters in the segmentation one by one to form a new word, if the obtained new word is the same as the word r, the error correction is successful.

[0044] The above process replaces each character in the word segmentation with one of the K reserved characters. If the new word formed after replacing all K reserved characters is still different from the word 'r', then the original word is retained and the error correction is declared a failure.

[0045] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0046] Example 1

[0047] like Figure 1 The diagram shown is a flowchart of a knowledge-based OCR error correction method provided in an embodiment of this application. This method is applied in a knowledge-based OCR error correction device and includes:

[0048] S1, construct a knowledge base R based on the objects of the optical character recognition application;

[0049] S2, uses optical character recognition technology to recognize text images and constructs a character matrix P;

[0050] S3, perform word segmentation on the string in the first row of the character matrix P;

[0051] S4. Match the obtained word segments with the words in the knowledge base R in turn. If the word segment is in the knowledge base R, the recognition is correct and no error correction is needed.

[0052] If the word segment is not in the knowledge base R, then the word segment is matched and replaced according to the words in the knowledge base R. When the new word appears in the knowledge base R, the error correction is completed.

[0053] Furthermore, the method provided in this application embodiment can utilize glyph search to achieve optical character recognition and error correction of the address field on the ID card during the ID card recognition process, such as... Figure 2 As shown, the specific steps are as follows:

[0054] Step 1, according to Figure 3 The objects shown in the optical character recognition application are used to construct a knowledge base;

[0055] Step two, identify the object as Figure 4 The text in the image has a length L = 12. Optical Character Recognition (OCR) technology is used to recognize the text in the image. The recognition results retain K = 3 characters with the highest probability, forming a matrix P of size 12*3. The constructed character matrix P is as follows. Figure 5 As shown;

[0056] Step 3: Segment the string “Xinba Village, Yiqiao Town, Sushan District, Hangzhou City” formed by the first row of matrix P to obtain w1 = Hangzhou City, w2 = Sushan District, w3 = Yiqiao Town, w4 = Xinba Village;

[0057] Step 4: Sequentially match w n , n = 1 …… 4 with the knowledge base. w1 = Hangzhou City is in the knowledge base, w2 = Qingshan District is not in the knowledge base. Select the word in the knowledge base with the smallest edit distance. There are 162 words such as "Fangshan District", "Hanshan District", "Qingshan District", "Hongshan District", "Xiaoshan District", …, "Suzhou District" with an edit distance of 1, namely r i , i = 1 …… 162. Replace the character "Su" in w2 with the second most probable character (Top2) "Xiao" to form a new word w ‘ = Xiaoshan District, w’ == r5, so the error correction is successful. Use w’ as the final result. Continue to perform the same operation on w3 = Yiqiao Town and w4 = Xinba Village to complete the overall error correction.

[0058] Furthermore, the objects recognized in S1 include ID cards, business licenses, and invoices.

[0059] In this embodiment, the object is the address in the ID card. According to the administrative divisions, a knowledge base is constructed using China's provincial, municipal, district / county-level, township-level, and village-level divisions and Chinese adverbs.

[0060] Furthermore, the construction of the knowledge base R in S1 utilizes prior knowledge to construct the knowledge base R with possible words, phrases, and adverbs.

[0061] In this embodiment, according to different prior knowledge, the scenarios adapted by the constructed knowledge base are also different.

[0062] Furthermore, the size of the character matrix P in S2 is K*L, where K is the number of characters with the highest probabilities reserved at each position, and L is the length of the recognized text.

[0063] In this embodiment, as shown in the character matrix P diagram Figure 5 , L is used as the row and K is used as the column.

[0064] Furthermore, the process of obtaining the character matrix P is as follows: For each character a in the recognized text i , i = 1, ……, L, obtain K possible characters sorted in ascending order of probability Record the result as

[0065] In this embodiment, search for the replacement characters with the most similar glyphs according to each character in the text and sort them in descending order of probability to K. Retain these replacement characters as candidate words for subsequent word segmentation and replacement.

[0066] Furthermore, the string in the first row of S3 is (P i 1), i = 1 ……L, the segmented words are w1, w2, …, w c , wherein c is the number of segmented words.

[0067] In this embodiment, the segmentation is performed according to the string in the first row, and the segmentation in the second and third rows is obtained by searching the closest value according to the character shape of the segmentation in the first row.

[0068] Further, the specific process of the matching and replacing in S4 is as follows:

[0069] S41, find the word r in the knowledge base R that is closest to the segmented word w n with the minimum edit distance, wherein n = 1 ……c;

[0070] S42, compare each character of w n with each character of r respectively, and replace the character in w n that is inconsistent with the corresponding character in r with the character with the i-th largest probability to form a new word w ’ , wherein i = 2 ……K;

[0071] S43, determine whether the new word w ’ is the same as r, if not, return to step two, and if yes, the error correction is completed.

[0072] If the new word w ’ is not the same as r, continue the replacing until i = K, if the new word w ’ is still not the same as r, stop the error correction, keep the original word, and report the error correction failure.

[0073] In this embodiment, if the value of K is too small, the number of the alternative words may be too small, resulting in the error correction failure.

[0074] Further, the word r with the minimum edit distance in step one includes one or more words with an edit distance of 1.

[0075] In this embodiment, the word r is equivalent to a word library, and generally, there are many values of r to facilitate the matching with the segmented words.

[0076] The technical solution in the embodiments of the present application has at least the following technical effects or advantages: the segmented words that are not the same as the words in the knowledge base R are corrected, the characters in the segmented words are replaced with the characters one by one according to the K reserved characters to form a new word, if the new word is the same as the word r, the error correction is successful, the accuracy and the fault tolerance of the recognition method are improved, and the result is more reliable.

[0077] Embodiment two

[0078] As Figure 6As shown, the structure diagram of the OCR correction device based on the knowledge base is provided in the embodiment of the present application, and the OCR correction device based on the knowledge base provided in the embodiment of the present application comprises a pre-modeling module, a recognition module, a word segmentation module and a correction module.

[0079] The pre-modeling module is used to construct the knowledge base R according to the object of the optical character recognition application.

[0080] The recognition module is used to recognize the text picture by using the optical character recognition technology to construct the character matrix P.

[0081] The word segmentation module is used to segment the string in the first row of the character matrix P.

[0082] The correction module is used to match the obtained segmented words with the knowledge base R in sequence, and if the segmented words are in the knowledge base R, the recognition is correct and no correction is needed.

[0083] If the segmented words are not in the knowledge base R, the segmented words are replaced according to the words in the knowledge base R, and when the new words appear in the knowledge base R, the correction is completed.

[0084] The embodiment of the present application further provides a computer readable storage medium for storing a program, and the program is executed by a processor to implement the OCR correction method based on the knowledge base.

[0085] In the embodiment, first, the pre-modeling module is used to construct the knowledge base R according to the object of the optical character recognition application, then the recognition module is used to recognize the text picture by using the optical character recognition technology to construct the character matrix P, then the word segmentation module is used to segment the string in the first row of the character matrix P, and finally the correction module is used to match the obtained segmented words with the knowledge base R in sequence, if the segmented words are in the knowledge base R, the recognition is correct and no correction is needed, if the segmented words are not in the knowledge base R, the segmented words are replaced according to the words in the knowledge base R, and when the new words appear in the knowledge base R, the correction is completed.

[0086] The technical solutions in the above embodiments of the present application have at least the following technical effects or advantages: the characters in the segmented words are replaced word by word according to the reserved K characters, the characters are replaced in the order from the maximum probability, and the candidate characters can be selected more orderly when multiple candidate results are recognized.

[0087] Those skilled in the art will appreciate that embodiments of the present application can be devised for a variety of applications. It is intended that the present application be limited only by the scope of the appended claims, and it is intended that various modifications and alterations made by those skilled in the art be considered as within the scope of the present application. The embodiments of the present application will be described with reference to the attached drawings, wherein:

[0088] The present application is described in reference to the drawings using a flowchart illustration and / or a block diagram of the method, apparatus (system) and computer program product according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing device or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0089] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0091] While the preferred embodiments of the application have been described, additional variations and modifications can be made to the embodiments by those skilled in the art once they learn of the basic inventive concepts. Therefore, the appended claims are intended to cover all such modifications and alterations as fall within the true spirit and scope of the application.

[0092] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A knowledge-based OCR error correction method, characterized in that, Includes the following steps: S1, construct a knowledge base R based on the objects of the optical character recognition application; S2, uses optical character recognition technology to recognize text images and constructs a character matrix P; S3, perform word segmentation on the string in the first row of the character matrix P; S4. Match the obtained word segments with the words in the knowledge base R in turn. If the word segment is in the knowledge base R, the recognition is correct and no error correction is needed. If the word segment is not in knowledge base R, then the word segment is matched and replaced according to the words in knowledge base R. When the new word appears in knowledge base R, the error correction is completed. The specific process of matching and replacing in S4 is as follows: S41, Search for and segment words in knowledge base R. Find the word r with the smallest edit distance, where n=1...c; S42, compare respectively With each character of r, Replace each character in the middle that does not correspond to the position of r with the character with the i-th highest probability to form a new word. , where i = 2...K; S43, Identify new words Check if it is the same as r. If not, return to step two. If they are the same, the error correction is complete. If new words If the word is not the same as r, return to step two and continue the replacement. When the replacement reaches i=K, a new word is generated. If the word is not the same as r, stop error correction, retain the original word, and report error correction failure.

2. The knowledge base-based OCR error correction method as described in claim 1, characterized in that: The objects of the identification application in S1 include ID cards, business licenses, and invoices.

3. The knowledge base-based OCR error correction method as described in claim 1, characterized in that: The construction of knowledge base R in S1 involves using prior knowledge to construct knowledge base R from possible words, phrases, and adverbs.

4. The knowledge base-based OCR error correction method as described in claim 1, characterized in that: In S2, the size of the character matrix P is K*L, where K is the K most probable characters retained at each position, and L is the length of the recognized text.

5. The knowledge base-based OCR error correction method as described in claim 4, characterized in that, The process of obtaining the character matrix P is as follows: based on each character in the recognized text... This yields K possible characters sorted by probability from smallest to largest. Record the result as .

6. The knowledge base-based OCR error correction method as described in claim 1, characterized in that: The string in the first line of S3 is The resulting word segmentation is , where c is the number of word segments.

7. The knowledge base-based OCR error correction method as described in claim 1, characterized in that: In step one, the word r with the smallest edit distance includes one or more words with an edit distance of 1.

8. A knowledge-based OCR error correction device, characterized in that, It includes a pre-built module, a recognition module, a word segmentation module, and an error correction module: Pre-built modules: used to build a knowledge base R based on objects in optical character recognition applications; Recognition module: Used to recognize text images using optical character recognition technology and construct a character matrix P; Word segmentation module: used to segment the string in the first row of the character matrix P into words; Error correction module: It is used to match the obtained word segments with the knowledge base R in turn. If the word segment is in the knowledge base R, the recognition is correct and no error correction is needed. If the word segment is not in knowledge base R, then the word segment is matched and replaced according to the words in knowledge base R. When the new word appears in knowledge base R, the error correction is completed. The specific process of the matching and replacement is as follows: Searching and segmenting words in knowledge base R Find the word r with the smallest edit distance, where n=1...c; Compare separately With each character of r, Replace each character in the middle that does not correspond to the position of r with the character with the i-th highest probability to form a new word. , where i = 2...K; Determine new words Check if it is the same as r. If not, return to step two. If they are the same, the error correction is complete. If new words If the word is not the same as r, return to step two and continue the replacement. When the replacement reaches i=K, a new word is generated. If the word is not the same as r, stop error correction, retain the original word, and report error correction failure.

9. A computer-readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the knowledge base-based OCR error correction method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Post-processing system and method for correcting machine recognized text

    US20040086179A1