Character array comparison method based on OCR image recognition
Through the character array comparison method based on OCR image recognition, the weight value calculation algorithm is used to match knowledge points, which solves the problem of matching small and medium-sized knowledge bases in the existing technology, and achieves efficient and low-cost knowledge retrieval and matching effects.
Patent Information
- Application Number
- CN202411561091.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-03-21
AI Technical Summary
The existing knowledge base matching algorithm needs to build an overall computing platform, which is difficult and costly to implement the technology, and is not suitable for the retrieval and matching of small knowledge bases.
A character array comparison method based on OCR image recognition is adopted, feature strings are extracted through OCR recognition, character strings are cleaned and filtered, and a weight value calculation algorithm is used to compare from two dimensions of length matching and position difference to realize the retrieval and matching of knowledge points.
It realizes efficient retrieval and matching of knowledge points in a small knowledge base, has the advantages of simplicity and high efficiency, and reduces cost and technical difficulty.
Smart Images

Figure CN119672724A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of knowledge base matching, and in particular to a character array comparison method based on OCR image recognition. Background Art
[0002] At present, the knowledge base matching algorithms on the market are mainly based on NLP (natural language processing), and the knowledge point matching is further optimized through algorithms such as DSL rewriting, text recall, and vector calculation. The above processing mechanism is a good combination of current AI capabilities, and through powerful platform computing and analysis capabilities, accurate knowledge point matching is achieved.
[0003] However, the mainstream knowledge base matching algorithms on the market require the construction of an overall computing platform, which is difficult and costly to implement, and is not very suitable for retrieval and matching of small knowledge bases. Summary of the invention
[0004] The present invention provides a character array comparison method based on OCR image recognition, which can better compare character arrays.
[0005] According to a character array comparison method based on OCR image recognition of the present invention, it comprises the following steps:
[0006] Step 1: Perform OCR recognition on the submitted error screenshot to extract the location and specific text information of the feature string in the screenshot;
[0007] Step 2: Clean the feature strings, filter out the strings that are short and contain many modal particles, numbers, and English characters, and store the cleaned strings into the string array to be compared;
[0008] Step 3: Traverse each piece of knowledge in the knowledge base, use OCR recognition to obtain the location and specific text information of the feature string corresponding to each piece of knowledge, and use the matching algorithm to compare the feature character array of the knowledge to be matched with the feature character array of the knowledge point to determine whether the knowledge is a possible solution;
[0009] Step 4: Display all possible solutions from high to low according to the weights calculated by the matching algorithm.
[0010] Preferably, in step 3, the matching algorithm is a weight value calculation algorithm, which considers the two dimensions of length matching and position difference. The longer the character matching length of the two strings to be compared, the smaller the relative position difference in the entire image, the greater the weight value obtained, and the greater the possibility of matching; the formula is as follows:
[0011] The weight value of a single piece of knowledge = Σ the matching weight value of a single string in the string array to be compared;
[0012] The matching weight value of a single string in the string array to be compared = Σ the matching value of the single string to be compared and the single string in the knowledge point feature character array;
[0013] The matching value between the single string to be compared and the single string in the knowledge point feature character array = length matching value - position difference value;
[0014] Length match value = length of matched string * weight factor. The longer the matched string, the higher the weight factor.
[0015] Position difference value = relative position of the single string to be compared - relative position of the single string in the knowledge point feature character array.
[0016] Preferably, the relative position is the coordinate value in the X / Y coordinate axis with the center of the picture as the origin. The smaller the position difference, the closer the relative positions of the two in the picture are, and the higher the possibility of matching. On the contrary, the larger the position difference value, the lower the possibility of matching. In terms of matching degree, the length matching value is positively correlated with the result, and the position difference value is negatively correlated with the result.
[0017] From the perspective of cost saving and simple implementation, the present invention considers adopting a simple and efficient string comparison algorithm to realize the retrieval and matching of knowledge points in a small knowledge base.
[0018] The present invention labels and weights character strings and adopts an improved character content comparison method to sort the matching degree between front-end image information and knowledge points in a back-end knowledge base, thereby screening out the most likely solution, which has the advantages of simple implementation and high efficiency.
[0019] The present invention utilizes a simple string comparison algorithm, introduces additional weight factors such as keywords and length, calculates the weights of the comparison results, and displays them on the front end from high to low weights, thereby realizing knowledge retrieval and matching of a small knowledge base. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flow chart of a character array comparison method based on OCR image recognition in Example 1. DETAILED DESCRIPTION
[0021] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments are only for explaining the present invention and are not intended to limit it.
[0022] Example 1
[0023] like Figure 1 As shown, this embodiment provides a character array comparison method based on OCR image recognition, which includes the following steps:
[0024] Step 1: Perform OCR recognition on the submitted error screenshot to extract the location and specific text information of the feature string in the screenshot.
[0025] Step 2: Clean the feature strings, filter out the strings that are too short, contain too many modal particles, numbers, and English characters, and store the cleaned strings into the string array to be compared.
[0026] Step 3: Traverse each piece of knowledge in the knowledge base, use OCR recognition to obtain the location and specific text information of the feature string corresponding to each piece of knowledge, and use the matching algorithm to compare the feature character array of the knowledge to be matched with the feature character array of the knowledge point to determine whether the knowledge is a possible solution;
[0027] The matching algorithm is a weighted value calculation algorithm. It considers the two dimensions of length matching and position difference. The longer the length of the character matching of the two strings to be compared, the smaller the relative position difference in the entire image, the greater the weight value obtained, and the greater the possibility of matching. The formula is as follows:
[0028] The weight value of a single piece of knowledge = Σ the matching weight value of a single string in the string array to be compared;
[0029] The matching weight value of a single string in the string array to be compared = Σ the matching value of the single string to be compared and the single string in the knowledge point feature character array;
[0030] The matching value between the single string to be compared and the single string in the knowledge point feature character array = length matching value - position difference value;
[0031] Length matching value = length of matched string * weight factor. The longer the matched string is, the higher the weight factor is, as shown in Table 1.
[0032] Table 1. Correspondence table of matching length and weight factor
[0033]
[0034]
[0035] Position difference value = relative position of the single string to be compared - relative position of the single string in the knowledge point feature character array.
[0036] The relative position is the coordinate value in the X / Y coordinate axis with the center of the picture as the origin. The smaller the position difference, the closer the relative positions of the two in the picture are, and the higher the possibility of matching. On the contrary, the larger the position difference value, the lower the possibility of matching. In terms of matching degree, the length matching value is positively correlated with the result, and the position difference value is negatively correlated with the result.
[0037] Step 4: Display all possible solutions from high to low according to the weights calculated by the matching algorithm.
[0038] OCR recognition (Optical Character Recognition) is optical character recognition. It is a technology that automatically converts and recognizes data such as text and images through digitization. Its principle uses computer vision technology to convert scanned paper documents or digital pictures into electronic text format. It mainly consists of three parts, including front-end processing, text recognition and back-end processing. Among them, front-end processing includes image preprocessing, region segmentation, character binarization, etc.; text recognition is to recognize characters as digital forms that can be recognized by computers; back-end processing is to verify, reconstruct and output the recognition results. In this embodiment, OCR recognition technology is mainly used for the conversion and analysis of digital images.
[0039] From the perspective of cost saving and simple implementation, this embodiment considers adopting a simple and efficient string comparison algorithm to achieve retrieval and matching of knowledge points in a small knowledge base.
[0040] Example 2
[0041] This embodiment provides a character array comparison method based on OCR image recognition, which specifically includes the following steps:
[0042] 1) Create knowledge points and expand the knowledge base;
[0043] 2) Use OCR technology to extract image text feature information;
[0044] The image is transmitted to the backend, and after the backend OCR recognizes the feature information, it is stored in JSON format. The feature information is as follows:
[0045] body":{"log_id":2517405234899390658,"words_result":[{"words":"Name of loan institution:"},{"words":"Maerkang Rural Credit Cooperative"},{"words":"Insurance code:"},{"words":"904"},{"words":"Main insurance coverage:"},{"words":"100,000.00"},{"words":"Policy trial Calculation failed"},{"words":"Error code:-1"},{"words":"Error message: China Life: Policy number 1439511900200451 is not"},{"words":"Available, please change"},{"words":"Confirm"},{"words":"Trial calculation"},{"words":"Return"},{"words":"Close"}],"words_result_num":14,"direction":0}
[0046] 3) Match the key feature information with the knowledge base information through a matching algorithm, and feedback the multiple pieces of information that are above the threshold according to the matching degree from high to low.
[0047] Example 3
[0048] This embodiment provides a character array comparison method based on OCR image recognition, which specifically includes the following steps:
[0049] (1) Search for knowledge points based on keywords and sort by the number of hits from high to low;
[0050] (2) Based on the information input by the user, intelligent word segmentation is performed to extract key elements. These key elements are used to search and filter in the knowledge base. According to the principle of string fuzzy matching, if a match is made, the hit number is increased by one. Finally, the information is sorted and displayed from high to low according to the hit number.
[0051] The present invention and its embodiments are described schematically above, and the description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by it and designs a structural method and an embodiment similar to the technical solution without creativity without departing from the purpose of the invention, they shall all fall within the protection scope of the present invention.
Claims
1. A character array comparison method based on OCR image recognition, characterized in that: The following steps are involved: Step 1: Perform OCR recognition on the submitted error screenshot to extract the location and specific text information of the feature string in the screenshot; Step 2: Clean the feature strings, filter out the strings that are short and contain many modal particles, numbers, and English characters, and store the cleaned strings into the string array to be compared; Step 3: Traverse each piece of knowledge in the knowledge base, use OCR recognition to obtain the location and specific text information of the feature string corresponding to each piece of knowledge, and use the matching algorithm to compare the feature character array of the knowledge to be matched with the feature character array of the knowledge point to determine whether the knowledge is a possible solution; Step 4: Display all possible solutions from high to low according to the weights calculated by the matching algorithm.
2. The character array comparison method based on OCR image recognition according to claim 1, characterized in that: In step 3, the matching algorithm is a weight value calculation algorithm. Considering the two dimensions of length matching and position difference, the longer the character matching length of the two strings to be compared, the smaller the relative position difference in the entire image, the greater the weight value obtained, and the greater the possibility of matching; the formula is as follows: The weight value of a single piece of knowledge = Σ the matching weight value of a single string in the string array to be compared; The matching weight value of a single string in the string array to be compared = Σ the matching value of the single string to be compared and the single string in the knowledge point feature character array; The matching value between the single string to be compared and the single string in the knowledge point feature character array = length matching value - position difference value; Length match value = length of matched string * weight factor. The longer the matched string, the higher the weight factor. Position difference value = relative position of the single string to be compared - relative position of the single string in the knowledge point feature character array.
3. The character array comparison method based on OCR image recognition according to claim 2, characterized in that: The relative position is the coordinate value in the X / Y coordinate axis with the center of the picture as the origin. The smaller the position difference, the closer the relative positions of the two in the picture are, and the higher the possibility of matching. On the contrary, the larger the position difference value, the lower the possibility of matching. In terms of matching degree, the length matching value is positively correlated with the result, and the position difference value is negatively correlated with the result.