Bill identification method, electronic device, and storage medium
By combining table structure and text features for invoice template matching, the problem of low accuracy in invoice recognition in existing technologies has been solved, achieving efficient and accurate extraction of invoice content and data entry.
Patent Information
- Application Number
- CN202210959267.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-08-10
AI Technical Summary
Existing invoice recognition methods rely on text recognition results, resulting in low recognition accuracy, and manual data entry is inefficient and inaccurate.
By combining the table structure features and text features of the invoice for template matching, the target invoice template is determined, and the content is extracted based on the location information of the target field, reducing the reliance on text recognition.
It improves the accuracy and efficiency of invoice recognition, simplifies the content extraction process of target fields, and ensures the accuracy and efficiency of data entry.
Smart Images

Figure CN115273086B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text recognition technology, specifically to a method for recognizing invoices, electronic devices, and storage media. Background Technology
[0002] Paper invoices include a title and a form. Entering the contents of paper invoices into electronic devices typically requires manual input. For example, in a material handling system for the construction industry, accurate entry of material waybill information is crucial for cost management. However, manual entry not only leads to low efficiency but also affects accuracy.
[0003] Existing automatic data entry methods are based on automatic document recognition. This involves acquiring an image of a paper document, performing text recognition on the image, extracting the content of target fields, and then filling the recognized content into the corresponding positions in a spreadsheet. However, this document recognition method heavily relies on the text recognition results; if the text recognition is incorrect, the document recognition result will be incorrect. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a ticket recognition method, an electronic device, and a storage medium to solve the problem of low accuracy in ticket recognition.
[0005] According to a first aspect, embodiments of the present invention provide a ticket recognition method, comprising:
[0006] Obtain the ticket to be identified;
[0007] Feature extraction is performed on the ticket to be identified to determine the table structure features and text features of the ticket;
[0008] The table structure features and text features are used to match the invoice template to determine the target invoice template, which includes the location information of the target field.
[0009] Based on the location information of the target field, the content of the corresponding location of the ticket to be identified is extracted, and the content of the target field in the ticket to be identified is determined.
[0010] The invoice recognition method provided in this invention combines the table structure features and text features of the invoice to be recognized to match invoice templates. This avoids strong dependence on text recognition results. Since the differences between different templates come from two aspects—different table styles and different header distribution positions—combining table structure features and text features to match invoice templates can improve the accuracy of invoice template matching, thereby improving the accuracy of invoice recognition.
[0011] In some implementations, the step of extracting features from the document to be identified, and determining the table structure features and text features of the document to be identified, includes:
[0012] The position of the ticket to be identified is corrected;
[0013] The corrected document to be identified is subjected to table recognition to determine the table structure features, which include cell position information;
[0014] Based on the corrected document to be identified, the features of the text within the cell are extracted, and the text features are determined.
[0015] The invoice recognition method provided in this invention performs table recognition and text feature extraction on the invoice after position correction, further improving the accuracy of the invoice recognition results. Furthermore, both table structure features and text features are applied to individual cells, which are the smallest units of a table. Therefore, feature extraction based on these smallest units ensures the comprehensiveness and reliability of the obtained table structure features and text features, providing a basis for subsequent invoice template matching.
[0016] In some implementations, the step of matching invoice templates using the table structure features and text features to determine the target invoice template includes:
[0017] The table structure features are concatenated with the text features to obtain the vector to be matched;
[0018] The similarity between the vector to be matched and the target vector of each invoice template is calculated to determine the target invoice template. The target vector is the concatenation of the template table structure features and template text features of the invoice template.
[0019] The invoice recognition method provided in this invention concatenates table structure features and text features, treats them as a whole, and calculates their similarity with the target vector of the invoice template. This reduces the amount of similarity calculation and improves the matching efficiency of the invoice template.
[0020] In some implementations, the step of matching invoice templates using the table structure features and text features to determine the target invoice template includes:
[0021] The similarity between the table structure features and the template structure features of the invoice template is calculated to obtain the table structure similarity.
[0022] The text similarity is calculated by comparing the text features with the template text features of the invoice template to obtain the text similarity.
[0023] Obtain the first weight of the table structure and the second weight of the text features;
[0024] Based on the first weight, the table structure similarity, the second weight, and the text similarity, the target similarity corresponding to the invoice template is determined;
[0025] The target invoice template is determined by using the magnitude of the target similarity.
[0026] The invoice recognition method provided in this invention calculates similarity for table structure and text features respectively, and then determines the target similarity by combining their respective weights. Since the introduction of weights allows for targeted similarity calculation, the accuracy of the calculated target similarity is improved.
[0027] In some implementations, extracting the content of the corresponding location of the document to be identified based on the location information of the target field, and determining the content of the target field in the document to be identified, includes:
[0028] Align the ticket to be identified with the target ticket template;
[0029] Based on the location information of the target field, the content of the corresponding position is extracted from the aligned document to be identified, and the content of the target field in the document to be identified is determined.
[0030] The invoice recognition method provided in this invention aligns the invoice to be recognized with a target invoice template, thereby enabling direct extraction of content from the corresponding position on the aligned invoice by utilizing the position information of the target field in the target invoice template. This simplifies the extraction process of the target field and improves extraction efficiency.
[0031] In some implementations, the method for determining the invoice template includes:
[0032] Obtain sample tickets;
[0033] Feature extraction is performed on the sample ticket to determine the template table structure features and template text features of the sample ticket, so as to determine the target vector of the sample ticket;
[0034] Obtain the location information of the target field in the sample document;
[0035] Based on the location information of the target field and the target vector, the ticket template of the sample ticket is determined.
[0036] The invoice recognition method provided in this embodiment of the invention provides the location information of the target field when determining the invoice template, avoiding the need to re-identify the target field after template matching. By enriching the information of the invoice template, the data processing of subsequent applications is reduced, and the efficiency of invoice recognition is improved.
[0037] In some implementations, the step of extracting features from the sample ticket to determine the template table structure features and template text features of the sample ticket, in order to determine the target vector of the sample ticket, includes:
[0038] The sample document is subjected to table recognition to determine the template position information and cell text features of the cells in the sample document;
[0039] Obtain the preset arrangement order of the cells;
[0040] Based on the preset arrangement order, the template position information and the cell text features are arranged respectively to obtain the template structure features and template text features of the sample ticket, so as to determine the target vector of the sample ticket.
[0041] The invoice recognition method provided in this invention uses a preset arrangement order of cells to arrange the template position information and cell text features of the cells, which can ensure the accuracy of the obtained template structure features and template text features.
[0042] In some embodiments, the method further includes:
[0043] Write the contents of the target field in the ticket to be identified into the target table to determine the target table.
[0044] The invoice recognition method provided in this invention, based on the accuracy of the recognition of the target field content, writes it into the target table, which can ensure the accuracy of the content entered into the target table and improve the efficiency and accuracy of data entry.
[0045] According to a second aspect, embodiments of the present invention also provide a ticket recognition device, comprising:
[0046] The acquisition module is used to acquire the ticket to be identified;
[0047] The feature extraction module is used to extract features from the ticket to be identified, and to determine the table structure features and text features of the ticket to be identified;
[0048] The matching module is used to match the invoice template using the table structure features and text features to determine the target invoice template, wherein the target invoice template includes the position information of the target field;
[0049] The content extraction module is used to extract the content at the corresponding position of the ticket to be identified based on the location information of the target field, and to determine the content of the target field in the ticket to be identified.
[0050] According to a third aspect, embodiments of the present invention provide an electronic device, including: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the ticket recognition method described in the first aspect or any embodiment of the first aspect.
[0051] According to a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer instructions for causing the computer to perform the ticket recognition method described in the first aspect or any embodiment of the first aspect.
[0052] It should be noted that the corresponding beneficial effects of the ticket recognition device, electronic device and computer-readable storage medium provided in the embodiments of the present invention can be found in the description of the corresponding beneficial effects of the ticket recognition method above, and will not be repeated here. Attached Figure Description
[0053] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0054] Figure 1 This is a flowchart of a ticket recognition method according to an embodiment of the present invention;
[0055] Figure 2 This is a flowchart of a ticket recognition method according to an embodiment of the present invention;
[0056] Figure 3 This is a flowchart of a ticket recognition method according to an embodiment of the present invention;
[0057] Figure 4 This is a schematic diagram of a table in a bill according to an embodiment of the present invention;
[0058] Figure 5 This is a structural block diagram of a ticket recognition device according to an embodiment of the present invention;
[0059] Figure 6 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0061] According to an embodiment of the present invention, a method for identifying invoices is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0062] This embodiment provides a ticket recognition method that can be used in electronic devices such as terminals and computers. Figure 1 This is a flowchart of a ticket recognition method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0063] S11, Obtain the ticket to be identified.
[0064] The image of the ticket to be identified can be acquired by an image acquisition device of an electronic device, or it can be obtained from other devices by the electronic device through a communication connection with other devices. There is no limitation on its source.
[0065] For example, an electronic device is a terminal with an image acquisition device. When it is necessary to recognize a ticket, the terminal's image acquisition device is used to acquire the ticket to be recognized, and the electronic device is used to recognize the ticket.
[0066] S12, extract features from the ticket to be identified, and determine the table structure features and text features of the ticket to be identified.
[0067] A document mainly consists of a header title and a table. The header title indicates the content of the document, such as "**Company Delivery Invoice**", "**Company**", etc.; the table contains the specific details of the document. The table structure and the text within the table differ depending on the type of document.
[0068] The table structure features of the document to be identified include, but are not limited to, the positional information of each cell in the document; the text features are the text features of the text within the cells. For example, the identification of table structure features can be achieved by using a table recognition model to identify table lines and determine the positional information of each cell; the identification of text features can be achieved by using a text recognition model to determine the text features.
[0069] Of course, in this embodiment, no restrictions are placed on the specific structure of the table recognition model and the text recognition model used. The specific structure can be set according to actual needs, and no limitations are imposed here.
[0070] S13. Use table structure features and text features to match invoice templates and determine the target invoice template.
[0071] The target ticket template includes the location information of the target field.
[0072] The invoice template includes the table structure features and text features of the corresponding invoice. The electronic device uses the table structure features and text features obtained in S12 above to match the table structure features and text features of each invoice template, and uses the matching degree to determine the target invoice template.
[0073] For example, the table structure features and text features are treated as a whole, and similarity is calculated with the corresponding features in the invoice template. The similarity calculation result is used as the matching degree to determine the target invoice template.
[0074] Alternatively, the similarity of table structure features and text features can be calculated separately, and then the two can be fused to determine the target similarity. The target similarity can then be used to determine the target invoice template.
[0075] After calculating the similarity scores, the electronic device extracts the highest similarity score from among the various similarity scores. This highest similarity score is then compared to a similarity threshold. If the highest similarity score is higher than the threshold, the ticket template corresponding to the highest similarity score is the target ticket template; if the highest similarity score is lower than the threshold, the ticket template matching fails. Subsequent identification of the target field requires field recognition on the ticket to be identified.
[0076] The specifics of this step will be described in detail below.
[0077] S14. Based on the location information of the target field, extract the content of the corresponding position of the ticket to be identified, and determine the content of the target field in the ticket to be identified.
[0078] After matching the target ticket template in S13 above, the position information of the target field in the target ticket template is extracted. Since the ticket to be identified matches the target ticket template, the ticket to be identified can be scaled to the size of the target ticket template. Based on this, the position information of the target field can be mapped to the corresponding position on the ticket to be identified. Accordingly, the content of the corresponding position on the ticket to be identified is extracted to determine the content of the target field in the ticket to be identified.
[0079] The specifics of this step will be described in detail below.
[0080] The invoice recognition method provided in this embodiment combines the table structure features and text features of the invoice to be recognized to match invoice templates. This avoids strong dependence on text recognition results. At the same time, since the differences between different templates come from two aspects, namely the different table styles and the different distribution positions of the table headers, combining table structure features and text features to match invoice templates can improve the accuracy of invoice template matching, thereby improving the accuracy of invoice recognition.
[0081] This embodiment provides a ticket recognition method that can be used in electronic devices such as terminals and computers. Figure 2 This is a flowchart of a ticket recognition method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0082] S21, Obtain the ticket to be identified.
[0083] Please see details Figure 1 S11 of the illustrated embodiment will not be described again here.
[0084] S22, extract features from the ticket to be identified, and determine the table structure features and text features of the ticket to be identified.
[0085] Specifically, S22 includes:
[0086] S221, Position correction is performed on the ticket to be identified.
[0087] The collected tickets to be identified may have a positional offset, therefore, positional correction is required. Since tickets to be identified are generally rectangular, the four corner points are identified during positional correction. These four corner points are then used to form a rectangle. Based on the offset of this rectangle relative to the horizontal and vertical directions, its position is corrected to obtain the corrected ticket to be identified.
[0088] S222, perform table recognition on the corrected document to be identified, and determine the table structure features.
[0089] The table structure features include cell position information.
[0090] Electronic devices utilize a table recognition model for table recognition. The corrected document to be recognized is input into the model to determine the table's structural features. Specifically, the model outputs the positional information of each cell in the table, including the coordinates of the cell's top-left corner, height, and width; or, alternatively, the coordinates of the cell's top-left and bottom-right corners. The representation of the cell's positional information is not limited here; it can be set according to actual needs.
[0091] S223, Based on the corrected document to be identified, extract the features of the text within the cell and determine the text features.
[0092] Electronic devices then utilize a text recognition model to determine text features; that is, the corrected document to be recognized is input into the text recognition model for text feature extraction.
[0093] Alternatively, the table recognition model and the text recognition model can be integrated into a feature extraction model. First, the table recognition module in the feature extraction model is used to identify the position information of each cell. Then, the position information of each cell and the corrected document to be recognized are used as input to the text recognition module to extract the text features of each cell.
[0094] S23. Use table structure features and text features to match invoice templates and determine the target invoice template.
[0095] The target ticket template includes the location information of the target field.
[0096] As mentioned above, for matching invoice templates, one approach is to concatenate the table structure features and text features into a single vector to be matched, and then match this vector as a whole with the invoice template; alternatively, one approach is to match the table structure features and text features separately.
[0097] In some embodiments, S23 includes:
[0098] (1) Concatenate the table structure features with the text features to obtain the vector to be matched.
[0099] (2) Calculate the similarity between the vector to be matched and the target vector of each invoice template to determine the target invoice template. The target vector is the concatenation of the template table structure features and the template text features of the invoice template.
[0100] The table structure features are represented as V_table, and the text features are represented as V_text. These two are concatenated to obtain the matching vector V = [V_table, V_text]. For ticket template i, its target vector is Vi_template = [Vi_table, Vi_text]. The similarity between the matching vector V and each target vector Vi_template is calculated, and the ticket template with the highest similarity is taken as the target ticket template.
[0101] By concatenating the table structure features with the text features and treating them as a whole for similarity calculation with the target vector of the invoice template, the amount of similarity calculation can be reduced and the matching efficiency of the invoice template can be improved.
[0102] In other embodiments, S23 includes:
[0103] (1) Calculate the similarity between the table structure features and the template structure features of the invoice template to obtain the table structure similarity.
[0104] (2) Calculate the similarity between the text features and the template text features of the invoice template to obtain the text similarity.
[0105] (3) Obtain the first weight of the table structure and the second weight of the text features.
[0106] (4) Based on the first weight, table structure similarity, second weight and text similarity, determine the target similarity corresponding to the invoice template.
[0107] (5) Determine the target invoice template by using the target similarity.
[0108] Continuing with the example above, the table structure feature is represented by V_table, and the text feature is represented by V_text; for document template i, its template structure feature is Vi_table, and its template text feature is Vi_text. The first weight is w1, and the second weight is w2, where w1 + w2 = 1.
[0109] Based on this, the target similarity corresponding to the invoice template i is represented as: Similarity = w1 * Table_similarity + w2 * Text_similarity, where Table_similarity is the table structure similarity, i.e., the similarity between V_table and Vi_table; and Text_similarity is the text similarity, i.e., the similarity between V_text and Vi_text.
[0110] After obtaining the target similarity, the invoice template corresponding to the highest target similarity is determined as the target invoice template. Similarity is calculated separately for table structure and text features, and then the target similarity is determined by combining their respective weights. The introduction of weights allows for a more focused calculation of similarity, improving the accuracy of the calculated target similarity.
[0111] S24. Based on the location information of the target field, extract the content of the corresponding position of the ticket to be identified, and determine the content of the target field in the ticket to be identified.
[0112] Please see details Figure 1 S14 of the illustrated embodiment will not be described again here.
[0113] The invoice recognition method provided in this embodiment performs table recognition and text feature extraction on the invoice after position correction, which further improves the accuracy of the invoice recognition results. At the same time, both the table structure features and text features are based on cells, and the cell is the smallest unit of the table. Therefore, feature extraction based on the smallest unit can ensure the comprehensiveness and reliability of the obtained table structure features and text features, providing conditions for subsequent invoice template matching.
[0114] This embodiment provides a ticket recognition method that can be used in electronic devices such as terminals and computers. Figure 3 This is a flowchart of a ticket recognition method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0115] S31, Obtain the ticket to be identified.
[0116] Please see details Figure 1 S11 of the illustrated embodiment will not be described again here.
[0117] S32, extract features from the ticket to be identified, and determine the table structure features and text features of the ticket to be identified.
[0118] Please see details Figure 2 S22 of the illustrated embodiment will not be described again here.
[0119] S33. Use table structure features and text features to match invoice templates and determine the target invoice template.
[0120] The target ticket template includes the location information of the target field.
[0121] For details on matching invoice templates, please refer to [link / reference]. Figure 2 S23 of the illustrated embodiment will not be described again here.
[0122] In some implementation methods, the method for determining the invoice template includes:
[0123] (1) Obtain sample tickets.
[0124] (2) Extract features from the sample tickets to determine the template table structure features and template text features of the sample tickets in order to determine the target vector of the sample tickets.
[0125] (3) Obtain the location information of the target field in the sample document.
[0126] (4) Determine the sample ticket template based on the location information of the target field and the target vector.
[0127] Specifically, the sample tickets used to form the ticket template include various types of tickets. To enrich the types of ticket templates, as many different types of tickets as possible can be collected. The feature extraction process for the sample tickets is similar to the feature extraction process for the tickets to be identified described above, and will not be repeated here. After feature extraction from the sample tickets, the template table structure features and template text features of the sample tickets are obtained. Furthermore, to facilitate subsequent ticket template matching, the target table structure features and template text features can be concatenated to obtain the target vector of the sample tickets.
[0128] The location information in the target field can be obtained by the user interacting with the electronic device and selecting the target field; it can also be determined by keyword recognition of the sample ticket, and so on.
[0129] For each sample ticket, after the above processing, the location information of the target field and the target vector are obtained. Based on this, a ticket template for the sample ticket can be formed. Since the location information of the target field is also given when determining the ticket template, the target field recognition is avoided again after template matching. By enriching the information of the ticket template, the data processing of subsequent applications is reduced, and the efficiency of ticket recognition is improved.
[0130] In some implementations, step (2) above includes:
[0131] 2.1) Perform table recognition on the sample documents to determine the template location information and cell text features of the cells in the sample documents.
[0132] 2.2) Obtain the preset arrangement order of cells.
[0133] 2.3) Based on the preset arrangement order, the template position information and cell text features are arranged respectively to obtain the template structure features and template text features of the sample ticket, so as to determine the target vector of the sample ticket.
[0134] As mentioned above, a cell is the smallest unit that forms a table. Table recognition of a sample document involves identifying the template location information and text features of each cell. For example, Figure 4 The diagram shows the cell layout of a sample document containing 45 cells. The cells are arranged from left to right and top to bottom, as shown in the diagram. Figure 4 The numbers 1 to 45 are shown.
[0135] After obtaining the template position information and cell text features of the cells, they are arranged sequentially according to the cell layout order to obtain the template structure features and template text features of the sample document. For example, the template structure feature Vi_table of sample document i is represented as: [template position information of cell 1, target position information of cell 2, ..., template position information of cell 45], and the template text feature Vi_text of sample document i is represented as: [text features of cell 1, text features of cell 2, ..., text features of cell 45]. The template structure feature Vi_table and the template text feature Vi_text of sample document i are concatenated to obtain the target vector Vi_template of document template i.
[0136] By using the preset cell layout order to arrange the template position information and cell text features, the accuracy of the obtained template structure features and template text features can be guaranteed.
[0137] S34, Based on the location information of the target field, extract the content of the corresponding position of the ticket to be identified, and determine the content of the target field in the ticket to be identified.
[0138] Specifically, S34 includes:
[0139] S341, Align the document to be identified with the target document template.
[0140] S342, Based on the location information of the target field, extract the content of the corresponding position in the aligned document to be identified, and determine the content of the target field in the document to be identified.
[0141] Using the dimensions of the target document template as a reference, align the document to be identified to the target document template. For example, identify the four corner points of the document to be identified and the four corner points of the target document template, and align the document to be identified with the target document template by aligning the corner points.
[0142] After alignment, the position information of the target field in the target document template can be used directly to extract the corresponding content from the corresponding position in the document to be identified, thereby obtaining the content of the target field in the document to be identified.
[0143] The invoice recognition method provided in this embodiment aligns the invoice to be recognized with the target invoice template. This allows for direct extraction of content from the corresponding position on the aligned invoice by utilizing the position information of the target field in the target invoice template. This simplifies the extraction process of the target field and improves extraction efficiency.
[0144] In some implementations, the method further includes writing the content of the target field in the document to be identified into a target table to determine the target table. Based on document recognition, the electronic device can also automatically input content, writing the extracted content into the corresponding position in the target table, thereby updating the target table. By accurately identifying the content of the target field and writing it into the target table, the accuracy of the content entered into the target table can be guaranteed, improving the efficiency and accuracy of data entry.
[0145] In the template construction stage, this embodiment uses a method that fuses the positional information of all cells with the text recognition feature vectors within the cells as the identifier for the invoice template. The final saved style is represented as follows:
[0146] Template folder 1: Coordinate information of the target field in template 1, vector file of template 1;
[0147] Template folder 2: Coordinate information of the target field in template 2, vector file of template 2; ......
[0149] Template folder n: Coordinate information of the target field in template n, and vector file of template n.
[0150] In the recognition phase, a table recognition model is used to extract the table lines of the invoice to be recognized. Using a model consistent with the text recognition model used to generate the invoice template, the text features of the invoice to be recognized are extracted. The table structure features and text features of the invoice to be recognized are matched with the corresponding features of the invoice template to determine the target invoice template. Based on the retrieved target invoice template, the location of the target field is parsed, and the corresponding region in the invoice to be recognized is extracted for recognition to determine the content of the target field in the invoice to be recognized.
[0151] As a specific application example of this invention, in the construction industry, the shipper typically provides a document that is sent with the shipment. When the delivery truck arrives at the recipient's location, the details of the document need to be entered into a spreadsheet. This requires using the document recognition method described in this embodiment to identify the target fields on the document and then writing the identified content into the spreadsheet to obtain the target spreadsheet. Through automatic document recognition and automatic content entry, the entire process is automated, improving the efficiency and accuracy of data entry.
[0152] This embodiment also provides a ticket recognition device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0153] This embodiment provides a ticket recognition device, such as... Figure 5 As shown, it includes:
[0154] Module 41 is used to acquire the ticket to be identified;
[0155] Feature extraction module 42 is used to extract features from the ticket to be identified, and determine the table structure features and text features of the ticket to be identified;
[0156] The matching module 43 is used to match the invoice template using the table structure features and text features to determine the target invoice template, wherein the target invoice template includes the position information of the target field;
[0157] The content extraction module 44 is used to extract the content of the corresponding position of the ticket to be identified based on the location information of the target field, and to determine the content of the target field in the ticket to be identified.
[0158] In some implementations, the feature extraction module 42 includes:
[0159] The correction unit is used to correct the position of the ticket to be identified;
[0160] The identification unit is used to perform table recognition on the corrected document to be identified, and to determine the table structure features, the table structure features including cell position information;
[0161] The first extraction unit is used to extract the features of the text within the cell based on the corrected document to be identified, and to determine the text features.
[0162] In some implementations, the matching module 43 includes:
[0163] The concatenation unit is used to concatenate the table structure features with the text features to obtain the vector to be matched;
[0164] The first calculation unit is used to calculate the similarity between the vector to be matched and the target vector of each invoice template, and to determine the target invoice template. The target vector is the concatenation of the template table structure features and template text features of the invoice template.
[0165] In some implementations, the matching module 43 includes:
[0166] The second calculation unit is used to calculate the similarity between the table structure features and the template structure features of the invoice template to obtain the table structure similarity.
[0167] The third calculation unit is used to calculate the similarity between the text features and the template text features of the invoice template to obtain the text similarity.
[0168] The first acquisition unit is used to acquire the first weight of the table structure and the second weight of the text features;
[0169] The first determining unit is configured to determine the target similarity corresponding to the invoice template based on the first weight, the table structure similarity, the second weight, and the text similarity.
[0170] The second determining unit is used to determine the target invoice template by utilizing the magnitude of the target similarity.
[0171] In some implementations, the content extraction module 44 includes:
[0172] An alignment unit is used to align the ticket to be identified with the target ticket template;
[0173] The second extraction unit is used to extract the content of the corresponding position in the aligned document to be identified based on the position information of the target field, and to determine the content of the target field in the document to be identified.
[0174] In some implementations, the module for determining the invoice template includes:
[0175] The second acquisition unit is used to acquire sample tickets;
[0176] The third extraction unit is used to extract features from the sample ticket, determine the template table structure features and template text features of the sample ticket, and determine the target vector of the sample ticket.
[0177] The third acquisition unit is used to acquire the location information of the target field in the sample document;
[0178] The third determining unit is used to determine the ticket template of the sample ticket based on the location information of the target field and the target vector.
[0179] In some implementations, the third extraction unit includes:
[0180] The identification subunit is used to perform table recognition on the sample document and determine the template position information and cell text features of the cells in the sample document.
[0181] Get sub-units, used to obtain the preset arrangement order of the cells;
[0182] The arrangement sub-unit is used to arrange the template position information and the cell text features according to the preset arrangement order, so as to obtain the template structure features and the template text features of the sample ticket, and to determine the target vector of the sample ticket.
[0183] In some embodiments, the apparatus further includes:
[0184] The writing unit is used to write the content of the target field in the ticket to be identified into a target table to determine the target table.
[0185] In this embodiment, the ticket recognition device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.
[0186] Further functional descriptions of the above modules are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0187] This invention also provides an electronic device having the above-described features. Figure 5 The ticket recognition device shown.
[0188] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention, such as... Figure 6 As shown, the electronic device may include: at least one processor 51, such as a CPU (Central Processing Unit), at least one communication interface 53, memory 54, and at least one communication bus 52. The communication bus 52 is used to enable communication between these components. The communication interface 53 may include a display screen or a keyboard; optionally, the communication interface 53 may also include a standard wired interface or a wireless interface. The memory 54 may be high-speed RAM (Random Access Memory) or non-volatile memory, such as at least one disk storage device. Optionally, the memory 54 may also be at least one storage device located remotely from the aforementioned processor 51. The processor 51 may be combined with... Figure 5 The described apparatus has an application program stored in memory 54, and the processor 51 calls the program code stored in memory 54 to perform any of the above method steps.
[0189] The communication bus 52 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus 52 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0190] The memory 54 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 54 may also include a combination of the above types of memory.
[0191] The processor 51 can be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.
[0192] The processor 51 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0193] Optionally, the memory 54 is also used to store program instructions. The processor 51 can invoke the program instructions to implement the ticket recognition method as shown in any embodiment of this application.
[0194] This invention also provides a non-transitory computer storage medium storing computer-executable instructions that can execute the ticket recognition method in any of the above method embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.
[0195] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for recognizing invoices, characterized in that, include: Obtain the ticket to be identified; Feature extraction is performed on the ticket to be identified to determine the table structure features and text features of the ticket; The table structure features and text features are used to match the invoice template to determine the target invoice template, which includes the location information of the target field. Based on the location information of the target field, extract the content of the corresponding location of the ticket to be identified, and determine the content of the target field in the ticket to be identified; The step of matching invoice templates using the table structure features and text features to determine the target invoice template includes: The table structure features are concatenated with the text features to obtain the vector to be matched; The similarity between the vector to be matched and the target vector of each invoice template is calculated to determine the target invoice template. The target vector is the concatenation of the template table structure features and template text features of the invoice template.
2. The method according to claim 1, characterized in that, The step of extracting features from the document to be identified, and determining the table structure features and text features of the document to be identified, includes: The position of the ticket to be identified is corrected; The corrected document to be identified is subjected to table recognition to determine the table structure features, which include cell position information; Based on the corrected document to be identified, the features of the text within the cell are extracted, and the text features are determined.
3. The method according to claim 1, characterized in that, The step of matching invoice templates using the table structure features and text features to determine the target invoice template includes: The similarity between the table structure features and the template structure features of the invoice template is calculated to obtain the table structure similarity. The text similarity is calculated by comparing the text features with the template text features of the invoice template to obtain the text similarity. Obtain the first weight of the table structure and the second weight of the text features; Based on the first weight, the table structure similarity, the second weight, and the text similarity, the target similarity corresponding to the invoice template is determined; The target invoice template is determined by using the magnitude of the target similarity.
4. The method according to claim 1, characterized in that, The step of extracting the content of the corresponding position of the ticket to be identified based on the location information of the target field, and determining the content of the target field in the ticket to be identified, includes: Align the ticket to be identified with the target ticket template; Based on the location information of the target field, the content of the corresponding position is extracted from the aligned document to be identified, and the content of the target field in the document to be identified is determined.
5. The method according to claim 1, characterized in that, The method for determining the invoice template includes: Obtain sample tickets; Feature extraction is performed on the sample ticket to determine the template table structure features and template text features of the sample ticket, so as to determine the target vector of the sample ticket; Obtain the location information of the target field in the sample document; Based on the location information of the target field and the target vector, the ticket template of the sample ticket is determined.
6. The method according to claim 5, characterized in that, The step of extracting features from the sample ticket to determine the template table structure features and template text features of the sample ticket, in order to determine the target vector of the sample ticket, includes: The sample document is subjected to table recognition to determine the template position information and cell text features of the cells in the sample document; Obtain the preset arrangement order of the cells; Based on the preset arrangement order, the template position information and the cell text features are arranged respectively to obtain the template structure features and template text features of the sample ticket, so as to determine the target vector of the sample ticket.
7. The method according to claim 1, characterized in that, The method further includes: Write the contents of the target field in the ticket to be identified into the target table to determine the target table.
8. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the ticket recognition method according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the ticket recognition method according to any one of claims 1-7.
Citation Information
Patent Citations
Template matching-based merged cell table segmentation and identification method
CN111626146A
Bill identification method, apparatus and device, computer storage medium and program product
CN114550189A