A bank receipt identification method, related device and storage medium
By identifying and splicing text blocks in the bank reply image, and using natural language processing technology to determine the payment direction, the problem of customizing templates for different bank reply formats in the traditional method is solved, and the efficiency and efficiency of bank reply recognition are improved. Adaptability.
Patent Information
- Application Number
- CN202110706242.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-24
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-06-24
AI Technical Summary
The traditional bank reply OCR identification method requires customized templates according to the reply formats of different banks, resulting in low identification efficiency and inability to adapt to changes in the reply formats of different banks.
By obtaining bank receipt images, identifying text blocks and splicing them, using natural language processing technology to identify fixed field information and payment field information, determine the payment direction of the receipt and payment field information, and avoid customizing the format of each bank receipt. Template requirements.
It has improved the efficiency of bank receipt identification, is suitable for various bank receipt formats, simplified the identification process, and improved identification accuracy and management efficiency.
Smart Images

Figure CN113469005B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a bank receipt recognition method, related devices and storage media. Background Art
[0002] The bank receipt is the original basis for the company to prepare accounting vouchers. The company will have a corresponding receipt as proof when receiving or paying. The content of the receipt mainly includes detailed information such as date, number, account name, account number, currency and amount. Each transaction is recorded in the receipt. Therefore, a large number of bank receipts will be processed in the company's fund management.
[0003] In recent years, with the rapid update and iteration of mobile devices and the rapid development of mobile Internet, OCR has a wider range of application scenarios, such as text recognition of scanned bank receipts. In application scenarios such as bank receipts, it can automatically recognize key information such as the date and account number of the bank receipt by uploading pictures, making it convenient for corporate cashiers to check and enter receipt information and improve work efficiency.
[0004] Traditional bank receipt OCR recognition methods often rely on the characteristics of the object to be recognized, and require customized templates for bank receipts. However, the receipt formats of different banks are not uniform, and even the same bank may have inconsistent receipt formats, which requires the customization of a large number of bank receipt templates. Therefore, each different type of bank receipt requires a corresponding customized template to recognize text information, and the recognition efficiency is low. Summary of the invention
[0005] In view of this, the present application provides a bank receipt recognition method for improving the recognition efficiency of bank receipts.
[0006] On one hand, the present application provides a method for identifying a bank receipt, comprising:
[0007] Obtain the bank receipt image to be identified;
[0008] Recognize the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information;
[0009] splicing the N text blocks according to the indexes and position information of the N text blocks to obtain a target text block;
[0010] The target text block is identified by using natural language processing technology to obtain fixed field information and payment field information, and the payment direction of the payment field information is determined.
[0011] In a possible implementation, after determining the payment direction of the payment field information, the method further includes:
[0012] Obtaining the field information of the payment direction to be identified in the payment field information;
[0013] Obtaining target location information corresponding to the field information of the payment direction to be identified;
[0014] Obtaining the field information of the payment and receipt field information, in which the payment and receipt direction has been identified;
[0015] Obtaining, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction;
[0016] The target location information, the first location information, and the second location information are processed to obtain the payment direction corresponding to the field information of the payment direction to be identified.
[0017] In a possible implementation, the processing of the target location information, the first location information, and the second location information to obtain the payment direction corresponding to the target text includes:
[0018] Calculating the minimum distance between the target location information and the first location information to obtain a first distance;
[0019] Calculating the minimum distance between the target location information and the second location information to obtain a second distance;
[0020] comparing the first distance and the second distance;
[0021] If the first distance is less than the second distance, determining the first distance as the target distance;
[0022] Determine whether the target distance is less than a preset threshold;
[0023] If so, determining that the target text belongs to the collection direction;
[0024] If the second distance is smaller than the first distance, determining the second distance as the target distance;
[0025] Determining whether the target distance is less than the preset threshold;
[0026] If so, it is determined that the target text belongs to the payment direction.
[0027] In a possible implementation, after determining the payment direction of the payment field information, the method further includes:
[0028] Acquire the field information of the payment and receipt field information, in which the payment and receipt direction is not identified, to obtain the target text;
[0029] Obtain target position information of target text;
[0030] Obtaining the first position information corresponding to the payment direction and the second position information corresponding to the payment direction in the payment direction of the payment field information;
[0031] The target location information, the first location information and the second location information are processed to obtain the payment direction corresponding to the target text.
[0032] In a possible implementation, the step of splicing the N text blocks according to the indexes and position information of the N text blocks includes:
[0033] Obtain text blocks with negative left index values from the N text blocks to obtain M first text blocks;
[0034] Determine a text block whose right index value is not a negative number in the first text block as the current text block;
[0035] 1) determining whether a left index value of a second text block is the same as a current index value of the current text block, and whether the current index value of the second text block is the same as a right index value of the current text block, wherein the second text block is a text block other than the M first text blocks among the N text blocks;
[0036] 2) If yes, determine that the second text block is the new current text block, and re-execute steps 1) to 2);
[0037] The current text block in step 1) is concatenated with the new current text block in step 2) to obtain a third text block;
[0038] Acquire a fourth text block, where the fourth text block is a text block other than the third text block among the N text blocks;
[0039] According to the position information of the fourth text block, the fourth text block is spliced with the third text block to obtain a target text block.
[0040] On the other hand, the present application provides a bank receipt recognition device, comprising:
[0041] An acquisition unit, used for acquiring a bank receipt image to be identified;
[0042] A recognition unit, used for recognizing the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information;
[0043] A splicing unit, used for splicing the N text blocks according to the indexes and position information of the N text blocks to obtain a target text block;
[0044] The recognition unit is further used to recognize the target text block using natural language processing technology to obtain fixed field information and payment field information, and determine the payment direction of the payment field information.
[0045] In a possible implementation, the bank receipt recognition device further includes a processing unit;
[0046] The acquisition unit is further used to acquire the field information of the payment direction to be identified in the payment field information;
[0047] The acquisition unit is further used to acquire the target location information corresponding to the field information of the to-be-identified payment and receipt direction;
[0048] The acquisition unit is further used to acquire the field information of the payment and receipt field information, which has identified the payment and receipt direction;
[0049] The acquisition unit is further used to acquire, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction;
[0050] The processing unit is used to process the target location information, the first location information and the second location information to obtain the payment direction corresponding to the field information of the payment direction to be identified.
[0051] In a possible implementation manner, the processing unit is specifically configured to:
[0052] Calculating the minimum distance between the target location information and the first location information to obtain a first distance;
[0053] Calculating the minimum distance between the target location information and the second location information to obtain a second distance;
[0054] comparing the first distance and the second distance;
[0055] If the first distance is less than the second distance, determining the first distance as the target distance;
[0056] Determine whether the target distance is less than a preset threshold;
[0057] If yes, it is determined that the field information of the to-be-identified payment and receipt direction belongs to the payment receipt direction;
[0058] If the second distance is smaller than the first distance, determining the second distance as the target distance;
[0059] Determining whether the target distance is less than the preset threshold;
[0060] If so, it is determined that the field information of the payment direction to be identified belongs to the payment direction.
[0061] On the other hand, the present application provides a computer device, including: a memory, a processor and a bus system; the memory is used to store program code; the processor is used to execute the bank receipt identification method described in any of the above aspects according to the instructions in the program code.
[0062] On the other hand, the present application provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the bank receipt recognition method described in any of the above aspects.
[0063] According to another aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the bank receipt recognition method described in any one of the above aspects.
[0064] It can be seen from the above technical scheme that the embodiment of the present application has the following advantages: obtaining a bank receipt image to be identified; identifying the bank receipt image to obtain N text blocks, each text block including corresponding text content, index and location information; splicing the N text blocks according to the index and location information of the N text blocks to obtain a target text block; using natural language processing technology to identify the target text block, obtaining fixed field information and payment field information, and determining the payment direction of the payment field information. In the above manner, in the process of identifying the bank receipt image, there is no need to customize the recognition template for each different bank receipt format. The recognition method can be applied to various different bank receipt formats, thereby improving the recognition efficiency of the bank receipt. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0066] Figure 1 A flow chart of a bank receipt recognition method provided in an embodiment of the present application;
[0067] Figure 2 A flowchart of recognizing a bank receipt image and obtaining N text blocks in an embodiment of the present application;
[0068] Figure 3 A schematic diagram of the process of splicing N text blocks to obtain a target text block in an embodiment of the present application
[0069] Figure 4 This is an example diagram of a bank receipt image in an embodiment of the present application;
[0070] Figure 5A A schematic diagram of a text block in an embodiment of the present application;
[0071] Figure 5B A schematic diagram of another text block in an embodiment of the present application;
[0072] Fig. 6A This is a schematic diagram of the processing process of the DATA1 part of the data block in the embodiment of the present application;
[0073] Figure 6B This is a schematic diagram of the processing process of the DATA2 part of the data block in the embodiment of the present application;
[0074] Figure 7 This is a schematic diagram of a scenario in which field information of the payment direction to be identified exists in an embodiment of the present application;
[0075] Figure 8 A schematic diagram of the structure of a bank receipt recognition device provided in an embodiment of the present application;
[0076] Fig. 9 A schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The embodiment of the present application provides a bank receipt recognition method for improving the recognition efficiency of bank receipts.
[0078] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0079] This application proposes an access control method, see Figure 1 , Figure 1 A flowchart of a bank receipt recognition method provided in an embodiment of the present application, the embodiment of the present application includes the following steps:
[0080] 101. Obtain a bank receipt image to be identified;
[0081] In the embodiment of the present application, the specific format of the bank receipt is not limited. For each bank receipt in a different format, the corresponding bank receipt image can be obtained and the bank receipt recognition method provided in the present application can be executed.
[0082] Optionally, after obtaining the bank receipt image to be identified, in order to facilitate the subsequent identification process, the bank receipt image may be preprocessed, for example, the resolution and light saturation of the bank receipt image may be optimized.
[0083] 102. Recognize the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information;
[0084] The bank receipt image obtained by step 101 includes the complete image information of the bank receipt. Since the bank receipt image includes a lot of text information, it is necessary to identify the bank receipt image and split it into N text blocks, wherein each text block includes corresponding text content, index and position information, the index of each text block indicates the relative position of the text block to other text blocks in the original bank receipt image, and the position information of each text block indicates the absolute position of the text block in the original bank receipt image.
[0085] For easier understanding, see Figure 2 , Figure 2 In the embodiment of the present application, a bank receipt image is recognized to obtain a flowchart of N text blocks, such as Figure 2As shown, the process of recognizing the bank receipt image and obtaining N text blocks may specifically include:
[0086] A1. Identify the direction of the bank receipt image;
[0087] The acquired bank receipts often contain the following situations: random photography, complex background, text background interference, multiple bank receipts in one image or incomplete receipts. The bank receipt image can be segmented, and the segmented bank receipt image can be identified in direction. Specifically, the convolutional network model can be used to identify the direction of the segmented image. If the direction of the bank receipt image is 0°, 90°, 180° or 270°, the recognition results are 0, 1, 2, and 3 respectively. If the recognition result is 0, the direction of the bank receipt image is determined to be positive. If its direction is not positive, the image is rotated and corrected.
[0088] A2. Detecting a single line of text in a bank receipt image;
[0089] The color image in the bank receipt image is transformed into a grayscale image, and then the grayscale is normalized. The image length and width are configured as multiples of 32. The detection network uses resnet50 as the backbone network. In order to obtain the classification of pixels, four UpSamples can be performed to obtain an output image size of 1 / 2 of the original image size. In order to avoid the adhesion of text images in adjacent rows, three branches are predicted and output, namely the text branch, the text boundary branch and the text center branch. The text enclosed rectangular frame is extracted through these three branches. The enclosed rectangular frame can be affine transformed to segment N single-line text images, where N is an integer greater than or equal to 1.
[0090] A3. Recognize single-line text images;
[0091] Using the resnet50+bilstm+ctc network structure algorithm, the height of the cut N single-line text images is configured to 32 and the width is scaled proportionally, and then input into the recognition network to obtain the recognition results and obtain N text contents.
[0092] Draw each text content in sequence on the original image system size 0 map marked as image M, and the text content fill pixel value is the sequence number of the text content. The left index of the text is, calculate the slope of the text content and the text height, extend the text height to the left by T times, and get the text box B. Extract the pixel value of the text content B in the image M, and count the pixel value with the largest number of pixel values as its index value. Finally, output the text content, index and position information corresponding to the single-line text image, which is the text block in this application.
[0093] Specifically, after the above recognition process, the bank receipt image can generate a list DATA=[item_1, item_2,…, item_n] consisting of the following data structure. The list DATA includes N text blocks, each of which can be represented by item_i. The index idx starts from 0, and the format of item_i is:
[0094]
[0095]
[0096] The following is an explanation of the various fields in the item_i structure:
[0097] text: the recognized text content
[0098] up_idx: the index corresponding to the upper data block of item_i data block;
[0099] down_idx: the index of the data block below item_i data block;
[0100] left_idx: the index corresponding to the data block to the left of item_i data block;
[0101] right_idx: the index of the data block to the right of item_i data block;
[0102] current_idx: current index of item_i data block;
[0103] point: The location information of item_i data block.
[0104] When the up_idx, down_idx, left_idx or right_idx index value is negative, it means that the distance interval exceeds the specified threshold. For example, when the left_idx in an item data block structure is negative, it means that there is no corresponding data block on the left of the data block or the interval is too large, and no connection is required.
[0105] 103. According to the index and position information of the N text blocks, the N text blocks are spliced to obtain a target text block;
[0106] After the index and position information of each text block is known, all N text blocks can be spliced according to the index and position information of each text block to obtain the target text block.
[0107] For example, the existing text block A is "payment", the text block B is "1234567890123456 (bank card number)", and the text block C is "account number". Then, according to the index and position information of each of the above text blocks, the text blocks A, B and C can be spliced to obtain the target text block after splicing, which is "payment account number 1234567890123456".
[0108] For easier understanding, see Figure 3 , Figure 3 This is a flow chart of splicing N text blocks to obtain a target text block in the embodiment of the present application, as shown in FIG. Figure 3 As shown, the specific steps include:
[0109] 1031. According to the data blocks in the DATA list, filter out the data block list DATA1 whose left_idx is a negative number, and sort DATA1 according to the order of DATA. Set a text information list text_list and a position information list point_list respectively.
[0110] 1032. Cycle through each data block in the DATA1 list;
[0111] Specifically, cyclically processing each data block in the DATA1 list includes the following steps:
[0112] (a) Assume that the current data block is item, record the item’s current index current_idx, text content text, and location information point.
[0113] (b) Cyclic treatment steps (b1) to (b3):
[0114] (b1) Conditional judgment: If the right_idx of item is not negative, and the left_idx in the data block item_1 indexed by right_idx is the same as the current_idx of item, and the current_idx in item_1 is equal to the right_idx of item, jump to (b2), otherwise jump to (b3);
[0115] (b2): Record the current index current_idx, text content text and location information point of item_1; and set item_1 as the current data block item, that is, item = item_1; continue with the (b) loop;
[0116] (b3) Exit (b) loop.
[0117] (c): Concatenate the text content text of each item recorded in steps (a) and (b) to form a complete string text_c, and set the position information corresponding to text_c to the position information point recorded in step (a) as point_c.
[0118] (d) Add the character string text_c to text_list and the position information point_c to point_list.
[0119] 1033. Filter out the unprocessed data blocks DATA2, that is, the remaining data blocks obtained by subtracting the data blocks recorded in step (2) from the DATA list, and sort them by DATA index.
[0120] 1034. Loop through each data block in the DATA2 list;
[0121] Assume that the current data block is item, record the current index current_idx, text content text and location information point of item. Add the text content text to text_list and the location information point to point_list.
[0122] 1035. Connect the text information list text_list;
[0123] Construct a splicing format S, using the index index of a text information in the text information list text_list and a special character T to form a splicing format T_index_T. Splice the text information list text_list according to the splicing format S to form a complete bank receipt text information string text_global, which is the target text block in this application.
[0124] For example, see Figure 4 , Figure 4 This is an example of a bank receipt image in the embodiment of the present application. After the bank receipt image is recognized, the following is obtained: Figure 5A and 5B After the N text blocks shown, execute each text block as follows Fig. 6A The DATA1 data block processing process shown in the figure and Figure 6BThe processing process of the DATA2 data block shown is spliced according to the processing results of DATA1 and DATA2, and it can be known that text_list = ['payment account 3602xxxxxxxxxxxxxxx', 'person'], point_list = [[144.0, 124.0], [148.0, 140.0]]. Construct the splicing format: for example, if T is $, then the text information string text_global of a DATA data block with an index between 12 and 16 is "$0$payment account 3602xxxxxxxxxxxxxxx$1$person", which is the target text block corresponding to the bank receipt image.
[0125] 104. Use natural language processing technology to identify the target text block, obtain fixed field information and payment field information, and determine the payment direction of the payment field information;
[0126] After the target text block is obtained by splicing in step 103, the target text block can be identified by natural language processing (NLP) technology, fixed field information and payment field information, and the payment direction of the payment field information can be determined. Among them, for the bank receipt, at least the payee information and the payee information are required, such as bank account number, account name and bank opening information. This type of information needs to be clearly identified as belonging to the payee or payer, which is the payment field information in this application. For the receipt number and transaction date in the bank receipt, there is no information about the payment direction, which is the fixed field information in this application. After the payment field information is identified in step 104, the payment direction corresponding to the payment field information can also be determined, so as to determine which of the bank account number, account name and bank opening information belongs to the payee and which belongs to the payee.
[0127] Specifically, in an embodiment of the present application, a regular expression can be used to identify the target text block to obtain field information and the payment direction corresponding to the field information. Specifically, it is necessary to pre-design corresponding regular expressions for each content of the bank receipt. For example, the form of the regular expression for identifying the account number may include but is not limited to: payment account number (\d{1,}). Taking the target text block whose field information is "payment account number 1234567890123456" as an example, it is determined that the target text block satisfies the regular expression matching the identification account number, and the corresponding recognition result can be obtained. The information belongs to the payment information, that is, the field information obtained is "payment account number 1234567890123456", and the payment direction is the payment direction.
[0128] In actual applications, after step 104 identifies the fixed field information, the payment and receipt field information, and the payment and receipt direction corresponding to the payment and receipt field information, this information can be output as feedback or entered into the bank receipt database to improve the management efficiency of the bank receipt.
[0129] It should be understood that in addition to the above example of identifying the target text block by using regular expressions, in actual applications, other NLP technologies can also be used to identify the target text block, which is not specifically limited here.
[0130] In an embodiment of the present application, a bank receipt image to be identified is obtained; the bank receipt image is identified to obtain N text blocks, each of which includes corresponding text content, index and location information; the N text blocks are spliced according to the index and location information of the N text blocks to obtain a target text block; the target text block is identified using natural language processing technology to obtain fixed field information and payment field information, and the payment direction of the payment field information is determined. In the above manner, in the process of identifying a bank receipt image, there is no need to customize the identification template for each different bank receipt format. The identification method can be applied to various bank receipt formats, thereby improving the recognition efficiency of bank receipts.
[0131] Furthermore, in actual applications, for information such as bank account number, account name and bank, in some cases, due to the format differences of receipts from different banks, it is impossible to match the specific payment direction. For example, for ease of understanding, please refer to Figure 7 , Figure 7 This is a schematic diagram of a scenario in which field information of the payment direction to be identified exists in an embodiment of the present application, such as Figure 7 As shown, the target text block can match the regular expression of the account name or the bank where an account is opened, but since there are no relevant words for the payment and receipt information at "Account Name" 701 and "Bank Where An Account Is Opened" 702, such as "Payment Account Name" or "Payment Bank Where An Account Is Opened", it is not possible to determine whether it is a payment or receipt direction. In this application, the bank account number, account name and bank where the payment and receipt direction cannot be identified after step 104 are defined as "field information for the payment and receipt direction to be identified", while the receipt number and transaction date in the bank receipt do not contain information on the payment and receipt direction (i.e., fixed field information), and do not belong to the "field information for the payment and receipt direction to be identified" in this application.
[0132] In view of the above problem that there is field information of the payment direction to be identified, in this application, after determining the payment direction of the payment field information, it is also possible to
[0133] Obtaining the field information of the payment direction to be identified in the payment field information;
[0134] Obtaining target location information corresponding to the field information of the payment direction to be identified;
[0135] Obtaining the field information of the payment and receipt field information, in which the payment and receipt direction has been identified;
[0136] Obtaining, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction;
[0137] The target location information, the first location information, and the second location information are processed to obtain the payment direction corresponding to the field information of the payment direction to be identified.
[0138] In this embodiment, the field information of the payment direction to be identified in the payment field information is first obtained to obtain the target text, and the position information of the target text, that is, the target position information, is obtained. However, generally speaking, even if there is field information in the current payment field information that cannot determine the payment direction, after step 104, there must be some field information that has been identified for the payment direction, such as Figure 7 The "payment direction" 703 and "receipt direction" 704 are shown. Therefore, it is also necessary to obtain the first position information corresponding to the receipt direction (e.g., "receipt direction" 704) and the second position information corresponding to the payment direction (e.g., "payment direction" 703) from the receipt and payment direction information identified in step 104. Then, the target position information, the first position information, and the second position information are processed to obtain the receipt and payment direction corresponding to the field information of the receipt and payment direction to be identified.
[0139] In the present application, the target location information, the first location information, and the second location information are processed to obtain the payment direction corresponding to the target text, which may specifically include the following steps:
[0140] Calculate the minimum distance between the target position information and the first position information to obtain a first distance;
[0141] Calculating the minimum distance between the target position information and the second position information to obtain a second distance;
[0142] Compare the first distance and the second distance;
[0143] If the first distance is smaller than the second distance, it means that the target location information is highly correlated with the first location information, that is, the target text is highly correlated with the payment direction, and the first distance can be determined as the target distance;
[0144] Determine whether the target distance is less than a preset threshold;
[0145] If so, it is determined that the field information of the payment direction to be identified belongs to the payment direction;
[0146] If the second distance is smaller than the first distance, it means that the target position information is highly correlated with the second position information, that is, the target text is highly correlated with the payment direction, and the second distance can be determined as the target distance;
[0147] Determine whether the target distance is less than a preset threshold;
[0148] If so, it is determined that the field information of the payment direction to be identified belongs to the payment direction.
[0149] Specifically, in order to improve the accuracy of identifying the payment direction of the field information of the payment direction to be identified, illustratively, in the embodiment of the present application, the following takes the calculation of the minimum Euclidean distance between the first location information, the second location information and the target location information, and the first distance and the second distance are obtained as an example for explanation. It should be understood that in actual applications, other distance calculation methods can be used, which are not specifically limited here.
[0150] Assume that the location information of the receiving direction is: first location information = [[x1, y1], [x2, y2], ...], the location information of the payment direction is: second location information = [[a1, b1], [a2, b2], ...], and the location information corresponding to the target text is: target location information = [x, y]. The specific steps to determine the direction of receiving and paying are:
[0151] The Euclidean distance between the target position information [x, y] and each position coordinate in the first position information [[x1, y1], [x2, y2], ...] is calculated respectively, and the shortest distance (first distance) therebetween is calculated.
[0152] The Euclidean distance between the target position information [x, y] and each position coordinate in the second position information [[a1, b1], [a2, b2], ...] is calculated respectively, and the shortest distance (second distance) therebetween is calculated.
[0153] The smaller of the first distance and the second distance is selected as the target distance.
[0154] If the target distance is less than a preset threshold, it can be determined whether the direction of the account name is a receiving direction or a paying direction.
[0155] In this embodiment, when there is field information of the payment direction to be identified, auxiliary judgment can be performed in combination with the position information of the field information, so as to identify the specific payment direction, thereby improving the accuracy of the solution.
[0156] Further, after identifying the fixed field information and the payment and receipt field information, further post-processing can be performed on the fixed field information and the payment and receipt field information. For example: perform selective stop word removal according to the characteristics of each field in the bank receipt, such as punctuation marks or spaces; perform error correction on the field information, such as the field information of the opening bank. The text obtained by OCR recognition may have Chinese recognition errors. To reduce the probability of recognition errors, text similarity algorithms, edit distance, or length difference processing can be used.
[0157] Exemplarily, it is known that the given correct list of opening banks List contains the following opening banks:
[0158] "Industrial and Commercial Bank of China, Victoria Square Sub-branch"
[0159] "Industrial and Commercial Bank of China, Sports West Road Sub-branch"
[0160] "China Merchants Bank, High-tech Sub-branch"
[0161] The content text of the field value to be corrected is "Industrial and Commercial Bank of China, Yongduolichang Sub-branch".
[0162] The specific error correction process is as follows:
[0163] (a) If the content text of the field value to be corrected text is in the given correct list of opening banks List, return the content of the field value; otherwise, jump to (b);
[0164] (b) For the content text of the field value to be corrected text, after obtaining N candidate texts through the lexical inverted index, use the text similarity method to calculate the k candidate texts that are most similar to text, where k < N. The text similarity calculation method can be one of TFIDF, BM25 algorithm, and elasticsearch retrieval.
[0165] (c) Screen out the common character sequence text1 of the text to be corrected text and the k candidate texts; find the candidate text list n that contains all the characters or t characters in text1 (the larger t is, the lower the probability of incorrect error correction) among the k candidate texts, where n < k. If n is empty, return the content text of the field value to be corrected text, otherwise jump to (d).
[0166] (d) Calculate the edit distance similarity between the content text of the field value to be corrected and the n candidate texts respectively, and obtain a list of n edit distance similarities. The edit distance, also known as the Levenshtein distance, is a measure of the degree of difference between two strings. The edit distance can be considered as the minimum number of times a single character is edited when modifying from one string to another. Generally, it is done through operations such as replacement, insertion, and deletion. Mathematically, the edit distance between two strings A and B is defined as Levenshtein distance. A,B (a,b), where a and b are the lengths of A and B respectively,
[0167]
[0168] Edit distance similarity: simliarity = 1-lev A,B (a,b) / max(a,b)
[0169] For example: A = "ICBC Yongduoli Branch", B = "ICBC Victoria Square Branch". The edit distance between A and B is calculated as follows:
[0170] Replacement: ICBC Wei (Yong->Wei)
[0171] Replacement: ICBC Victoria (Li->Li)
[0172] Insert: ICBC Victoria (_-> Asia)
[0173] Replacement: ICBC Victoria Guang (Industry->Guang)
[0174] Therefore, it only takes 4 editing operations to change from A to B, so the edit distance is 4. The similarity is: 1-4 / max(9,10)=0.6.
[0175] The maximum similarity p is selected from a list of n edit distance similarities. If p is greater than a preset threshold, the candidate text with the index corresponding to the maximum similarity p is selected from the n candidate texts as the text content after error correction to be replaced; otherwise, no replacement is performed.
[0176] In this embodiment, the obtained field information may be further subjected to error correction processing, thereby improving the accuracy of the solution implementation.
[0177] In order to better implement the above solution of the embodiment of the present application, the following also provides related devices for implementing the above solution. Figure 8 , Figure 8 A schematic diagram of the structure of a bank receipt recognition device provided in an embodiment of the present application, the bank receipt recognition device includes:
[0178] An acquisition unit 801 is used to acquire a bank receipt image to be identified;
[0179] The recognition unit 802 is used to recognize the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information;
[0180] A splicing unit 803 is used to splice the N text blocks according to the indexes and position information of the N text blocks to obtain a target text block;
[0181] The recognition unit 802 is further used to recognize the target text block using natural language processing technology to obtain fixed field information and payment field information, and determine the payment direction of the payment field information.
[0182] Optionally, in the above Figure 8 On the basis of the corresponding embodiment, the bank receipt recognition device further includes a processing unit 804;
[0183] The acquisition unit 801 is further used to acquire the field information of the payment direction to be identified in the payment field information;
[0184] The acquisition unit 801 is further used to acquire the target location information corresponding to the field information of the to-be-identified payment and receipt direction;
[0185] The acquisition unit 801 is further used to acquire the field information of the payment direction identified in the payment field information;
[0186] The acquisition unit 801 is further configured to acquire, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction;
[0187] The processing unit 804 is used to process the target location information, the first location information, and the second location information to obtain the payment direction corresponding to the field information of the payment direction to be identified.
[0188] Optionally, in the above Figure 8 Based on the corresponding embodiment, the processing unit 804 is specifically used for:
[0189] Calculating the minimum distance between the target location information and the first location information to obtain a first distance;
[0190] Calculating the minimum distance between the target location information and the second location information to obtain a second distance;
[0191] comparing the first distance and the second distance;
[0192] If the first distance is less than the second distance, determining the first distance as the target distance;
[0193] Determine whether the target distance is less than a preset threshold;
[0194] If yes, it is determined that the field information of the to-be-identified payment and receipt direction belongs to the payment receipt direction;
[0195] If the second distance is smaller than the first distance, determining the second distance as the target distance;
[0196] Determining whether the target distance is less than the preset threshold;
[0197] If so, it is determined that the field information of the payment direction to be identified belongs to the payment direction.
[0198] In this embodiment, the bank receipt recognition device can perform the above Figures 1 to 6B The operation of any of the embodiments shown in the description will not be described in detail here.
[0199] The present application also provides a computer device for executing Figures 1 to 6B The operation of any of the embodiments shown in the corresponding embodiments. Fig. 9 , Fig. 9 It is a structural diagram of a computer device 900 in an embodiment of the present application. As shown in the figure, the computer device 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 922 (for example, one or more processors) and memory 932, and one or more storage media 930 (for example, one or more mass storage devices) storing application programs 942 or data 944. Among them, the memory 932 and the storage medium 930 can be short-term storage or permanent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the computer device. Furthermore, the central processing unit 922 can be configured to communicate with the storage medium 930 to execute a series of instruction operations in the storage medium 930 on the computer device 900.
[0200] The computer device 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input and output interfaces 958, and / or one or more operating systems 941, such as Windows Server 2008, ... TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM etc.
[0201] The steps performed in the above embodiments can be based on the Fig. 9 The structure of the computer device shown.
[0202] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the methods described in the aforementioned embodiments.
[0203] The present application also provides a computer program product including a program, which, when executed on a computer, enables the computer to execute the methods described in the above embodiments. Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the above-described method embodiments, and will not be repeated here.
[0204] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0205] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0206] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0207] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, an interactive video management device, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0208] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for identifying a bank receipt. It is characterized in that include: Obtain the bank receipt image to be identified; Recognize the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information; splicing the N text blocks according to the indexes and position information of the N text blocks to obtain a target text block; Using natural language processing technology to identify the target text block, obtain fixed field information and payment field information, and determine the payment direction of the payment field information; Obtaining the field information of the payment direction to be identified in the payment field information; Obtaining target location information corresponding to the field information of the payment direction to be identified; Obtaining the field information of the payment and receipt field information, in which the payment and receipt direction has been identified; Obtaining, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction; Calculating the minimum distance between the target location information and the first location information to obtain a first distance; Calculating the minimum distance between the target location information and the second location information to obtain a second distance; comparing the first distance and the second distance; If the first distance is less than the second distance, determining the first distance as the target distance; Determine whether the target distance is less than a preset threshold; If yes, it is determined that the field information of the to-be-identified payment and receipt direction belongs to the payment receipt direction; If the second distance is smaller than the first distance, determining the second distance as the target distance; Determining whether the target distance is less than the preset threshold; If so, it is determined that the field information of the payment direction to be identified belongs to the payment direction.
2. The method according to claim 1, It is characterized in that The bank receipt image is recognized to obtain N text blocks including: Segmenting the bank receipt image into N single-line text images; Using an image recognition network to recognize the N single-line text images to obtain N text contents; According to the position information of each text content on the bank receipt image, determine the index and position information corresponding to each text block, and obtain the index and position information corresponding to the N text contents; The N text contents and indexes and position information corresponding to the N text contents are output to obtain N text blocks.
3. The method according to claim 1, It is characterized in that The step of splicing the N text blocks according to the indexes and position information of the N text blocks includes: Obtain text blocks with negative left index values from the N text blocks to obtain M first text blocks; Determine a text block whose right index value is not a negative number in the first text block as the current text block; 1) determining whether a left index value of a second text block is the same as a current index value of the current text block, and whether the current index value of the second text block is the same as a right index value of the current text block, wherein the second text block is a text block other than the M first text blocks among the N text blocks; 2) If yes, determine that the second text block is the new current text block, and re-execute steps 1) to 2); The current text block in step 1) is concatenated with the new current text block in step 2) to obtain a third text block; Acquire a fourth text block, where the fourth text block is a text block other than the third text block among the N text blocks; According to the position information of the fourth text block, the fourth text block is spliced with the third text block to obtain a target text block.
4. A bank receipt recognition device, It is characterized in that include: An acquisition unit, used for acquiring a bank receipt image to be identified; A recognition unit, used for recognizing the bank receipt image to obtain N text blocks, each of which includes corresponding text content, index and position information; A splicing unit, used for splicing the N text blocks according to the indexes and position information of the N text blocks to obtain a target text block; The recognition unit is further used to recognize the target text block using natural language processing technology to obtain fixed field information and payment field information, and determine the payment direction of the payment field information; The acquisition unit is further used to acquire the field information of the payment direction to be identified in the payment field information; The acquisition unit is further used to acquire the target location information corresponding to the field information of the to-be-identified payment and receipt direction; The acquisition unit is further used to acquire the field information of the payment and receipt field information, which has identified the payment and receipt direction; The acquisition unit is further used to acquire, in the field information of the identified payment and receipt directions, first position information corresponding to the payment direction and second position information corresponding to the payment direction; A processing unit, configured to calculate a minimum distance between the target location information and the first location information to obtain a first distance; The processing unit is further used to calculate the minimum distance between the target position information and the second position information to obtain the second distance; The processing unit is further configured to compare the first distance with the second distance; The processing unit is further configured to determine that the first distance is a target distance when the first distance is smaller than the second distance; The processing unit is further used to determine whether the target distance is less than a preset threshold; If yes, the processing unit is further used to determine that the field information of the to-be-identified payment and receipt direction belongs to the payment receipt direction; The processing unit is further configured to determine that the second distance is the target distance when the second distance is smaller than the first distance; The processing unit is further configured to determine whether the target distance is less than the preset threshold; If so, the processing unit is further used to determine that the field information of the to-be-identified payment and receipt direction belongs to the payment direction.
5. A computer device, It is characterized in that The computer device comprises a processor and a memory: The memory is used to store program codes; the processor is used to execute the bank receipt identification method described in any one of claims 1 to 3 according to the instructions in the program codes.
6. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the bank receipt recognition method described in any one of claims 1 to 3.
7. A computer program product comprising a program which, when executed on a computer, causes the computer to execute the method according to any one of the preceding claims 1 to 3.
Citation Information
Patent Citations
Key information extraction method and device based on bank receipts, equipment and medium
CN112784720A
