Electronic bill analysis, marking method, system, equipment and medium
By obtaining and calculating the position and relative position relationship of the target field in the electronic bill, the problem of difficult determination of the correspondence relationship between keywords and values in non-standard bills is solved, and efficient analysis and applicability of the electronic bills is achieved.
Patent Information
- Application Number
- CN202310310384.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-24
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2043-03-24
AI Technical Summary
It is difficult for the prior art to efficiently determine the correspondence between keywords and values in non-standard bills, especially in non-standard bills from different sources. Due to the large differences in content formats, it is difficult to parse.
By obtaining the field name and position coordinates of the target field from the electronic bill, combining the field name and relative position relationship of the pre-stored electronic bill field, the position coordinates of the target value corresponding to the target keyword are calculated, so as to quickly determine the target value in the electronic bill that meets the target value in the electronic bill The value of the position coordinate.
It realizes efficient analysis of electronic bills, and can quickly determine the correspondence between keywords and values in non-standard bills, which is suitable for non-standard bills from different sources.
Smart Images

Figure CN116469118B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer natural language processing, and in particular to a method, system, device and medium for parsing and marking electronic invoices. Background Art
[0002] Electronic receipts are documents obtained by digitizing physical receipts (such as ID cards, invoices, expense settlement sheets, etc.).
[0003] Generally, electronic receipts contain data used to express the information in physical receipts, and the data is carried in the fields contained in the electronic receipts. The information expressed by the data in the fields can be divided into keywords and values. For example, for an expense settlement form, the data in the fields include: name Zhang San; date of birth 2020-01-01; personnel number 001, etc. Among them, name, date of birth and personnel number are keywords, and Zhang San, 2020-01-01 and 001 are the values corresponding to the keywords.
[0004] At present, the requirements for parsing electronic receipts generally include: determining the correspondence between keywords and values in the fields contained in the electronic receipts. For standard receipts (such as train tickets and ID cards), since the relative positions of keywords and values in standard receipts are fixed, it is relatively easy to determine the correspondence between keywords and corresponding values when parsing the electronic receipts corresponding to the standard receipts; however, for non-standard receipts from different sources (such as medical records from different hospitals), it is difficult to determine the correspondence between keywords and values from the corresponding electronic receipts because their content formats vary greatly.
[0005] For electronic invoices corresponding to non-standard invoices, how to efficiently determine the correspondence between keywords and values is an urgent problem to be solved. Summary of the invention
[0006] The embodiments of the present application provide a method, system, device and medium for parsing and marking electronic bills, so as to solve the problem existing in the prior art of how to efficiently determine the correspondence between keywords and values in non-standard bills.
[0007] The present application embodiment adopts the following technical solutions:
[0008] A method for parsing an electronic bill, comprising:
[0009] From the electronic bill, obtain the field name of the target field contained in the electronic bill and the position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill;
[0010] According to the field name of the target field, a relative position relationship corresponding to the field name of the target field is obtained from the field names and relative position relationships of the fields contained in the electronic bill that match the bill type of the electronic bill and that are stored in advance; the relative position relationship represents: the position relationship between the keyword in the field at the first position in the original bill and the value corresponding to the keyword at the second position in the original bill;
[0011] According to the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, determine the position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates;
[0012] From the electronic ticket, a value corresponding to the target position coordinates is determined as a target value corresponding to the target keyword.
[0013] A method for marking an electronic bill, comprising:
[0014] Obtaining, from the electronic bill, a field name of a target field contained in the electronic bill, and position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent: a first position of a target keyword in the target field in the original bill, and a second position of a target value in the target field in the original bill;
[0015] Determine the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value;
[0016] The target keyword, the relative position relationship, and the bill type matching the electronic bill are stored correspondingly.
[0017] An electronic bill parsing system, comprising:
[0018] The first field information acquisition unit is used to acquire, from the electronic bill, the field name of the target field contained in the electronic bill and the position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill;
[0019] The relative position information acquisition unit acquires, according to the field name of the target field, the relative position relationship corresponding to the field name of the target field from the field names and relative position relationships of the fields contained in the electronic bill that match the bill type of the electronic bill and are stored in advance; the relative position relationship represents: the position relationship between the keyword in the field at the first position in the original bill and the value corresponding to the keyword at the second position in the original bill;
[0020] A target position determination unit, based on the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, determines the position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates;
[0021] The target value determination unit is used to determine the value corresponding to the target position coordinates from the electronic ticket as the target value corresponding to the target keyword.
[0022] An electronic invoice marking system, comprising:
[0023] The second field information acquisition unit acquires, from the electronic bill, a field name of a target field contained in the electronic bill and position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent: a first position of a target keyword in the target field in the original bill, and a second position of a target value in the target field in the original bill;
[0024] A relative position determination unit, which determines the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value;
[0025] The marking storage unit is used to store the relative position relationship and the bill type that matches the electronic bill in a corresponding manner.
[0026] An electronic bill parsing device includes: a memory and a processor, wherein:
[0027] The memory is used to store computer programs;
[0028] The processor is coupled to the memory and is used to execute the computer program stored in the memory to execute the above-mentioned electronic bill parsing method.
[0029] An electronic bill marking device includes: a memory and a processor, wherein:
[0030] The memory is used to store computer programs;
[0031] The processor is coupled to the memory and is used to execute the computer program stored in the memory for use in the above-mentioned electronic bill marking method.
[0032] A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer, can implement the above-mentioned electronic bill parsing method, or can implement the above-mentioned electronic bill marking method.
[0033] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0034] After obtaining the field name and corresponding position coordinates of the target field contained in the current electronic invoice, the embodiment of the present application calculates the position coordinates of the target value corresponding to the target keyword based on the field name and relative position relationship in the field contained in the pre-stored electronic invoice, thereby quickly determining the value of the position coordinates in the electronic invoice that meets the target value, thereby achieving efficient parsing of the electronic invoice. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0036] Figure 1 A specific implementation flow chart of an electronic bill parsing method provided in Example 1 of the present application;
[0037] Figure 2 A specific implementation flow chart of an electronic bill parsing method provided in Example 2 of the present application;
[0038] Figure 3 This is a specific implementation flow chart of electronic invoice parsing through the constraint conditions of the attributes of the target value in Example 2 of the present application;
[0039] Figure 4 This is an example diagram of an electronic receipt where all fields are in cells;
[0040] Figure 5 Example image of an electronic receipt where the fields are not in the cell;
[0041] Figure 6 A specific implementation flow chart of a method for marking an electronic bill provided in Example 3 of the present application;
[0042] Figure 7 Part 1 of the specific implementation flow chart of a method for marking an electronic bill provided in Example 4 of the present application;
[0043] Figure 8 Part 2 of the specific implementation flow chart of a method for marking an electronic bill provided in Example 4 of the present application;
[0044] Fig. 9 A schematic diagram of the structure of an electronic bill parsing system provided in Example 5 of the present application;
[0045] Fig.10 A schematic diagram of the structure of an electronic invoice marking system provided in Example 6 of the present application;
[0046] Fig.11 A schematic diagram of the specific structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0048] Those skilled in the art may appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0049] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0050] Example 1
[0051] Embodiment 1 of the present application provides a method for parsing an electronic bill, so as to solve the problem existing in the prior art of how to efficiently determine the correspondence between keywords and values in a non-standard bill.
[0052] The executor of the method may be any computing device that can implement the method, such as a server, a mobile phone, a personal computer, a smart wearable device, a smart robot, and the like.
[0053] The different steps of the method may be implemented by the same execution subject or by different execution subjects. The embodiment of the present application does not limit the execution subject used to implement the method.
[0054] In addition, the execution order of different steps is not limited in the embodiment of the present application. When using the method provided in the embodiment of the present application, the execution order of different steps can be adjusted according to actual needs.
[0055] For ease of description, the method provided in the embodiment of the present application is described in detail below by taking an electronic invoice parsing device as the executor of the method as an example.
[0056] like Figure 1 As shown, a method for parsing an electronic bill provided in an embodiment of the present application includes:
[0057] Step 101, obtaining the field name of the target field contained in the electronic bill and the position coordinates corresponding to the target field from the electronic bill; the position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill.
[0058] In one implementation, non-standard bills from different sources are identified by OCR (Optical Character Recognition) to obtain an electronic bill corresponding to the original bill. The message returned by the OCR non-standard identification interface includes the field name of the target field contained in the electronic bill, and the position coordinates of the target field located by the row identifier and column identifier.
[0059] In one implementation, the information obtained by OCR recognition is stored in the bill OCR recognition information table shown in Table 1 below. Table 1 stores the original information recognized by the OCR non-standard interface, wherein the template id represents the annotation template information matched by the current electronic bill; the bill id represents the identity recognition information of the electronic bill; the content information is the information to be parsed into keywords (key) and values (value); the row identifier, row placeholder, column identifier and column placeholder jointly determine the position coordinates of the field; the enumerated field name represents the possible naming method corresponding to the content information of the current row of Table 1, such as the corresponding content information is name, the enumerated field name is name, name, etc.; the standard field name represents the standard naming method corresponding to the content information of the current row of Table 1, and the standard field name can be set manually. In addition, the corresponding information of the enumerated field name and the standard field name in Table 1 can quickly determine the matching relationship between the original recognition information of the electronic bill and the existing fields of the bill dictionary table below.
[0060] Table 1:
[0061]
[0062] In one implementation, the bill type corresponding to the current electronic bill is determined based on the field name of the target field contained in the acquired electronic bill.
[0063] This embodiment takes the Bayesian classifier as an example to introduce the process of determining the bill type corresponding to the electronic bill.
[0064] First, some technical terms involved in the Bayesian classifier are explained as follows:
[0065] 1. Prior probability refers to the probability obtained based on past experience and analysis, such as the total probability formula. It is often used as the probability of the "cause" in the problem of "seeking the effect from the cause".
[0066] 2. Posterior probability P(c i |x) refers to the probability that is revised after obtaining the information of the "result", which is the "result" in the problem of "finding the cause from the result". The prior probability and the posterior probability are inseparable, and the calculation of the posterior probability must be based on the prior probability.
[0067] 3. Expected loss (conditional risk) R(c i |x), based on the posterior probability, the sample x is classified as c i The expected loss generated, that is, the conditional risk on sample x, is expressed as: In the formula, N represents the possible categories of bills, λ ij Indicates that a real category is c j The sample is judged as c x loss.
[0068] 4. Classification condition risk R(h), the expression is: R(h)=E x
R(h(x)|x)
[0069] The theoretical basis for determining the bill type based on the Bayesian classifier is:
[0070] Based on the posterior probability P(c i |x) can be obtained by classifying sample x into c i The expected loss generated is the conditional risk R(c i |x);
[0071] The expected loss is equal to the conditional risk, so finding a criterion h:X→Y that can minimize the overall risk is the goal of machine learning. The Bayesian criterion is to minimize the overall risk, and it only needs to select the category label that minimizes the risk R(c|x) on each sample, that is: h * (x) = argmin c R(c|x);
[0072] 1-R(h * ) reflects the best performance that the classifier can achieve, that is, the theoretical upper limit of the model progress that can be produced by machine learning. Based on Bayes' theorem, it can be written as: Where P(c|x) represents the probability of event c occurring when event x occurs, and P(x|c) represents the probability of event x occurring when event c occurs.
[0073] Using the naive Bayes classifier and the attribute conditional independence assumption, the Bayesian formula based on the attribute conditional independence assumption can be written as: In the formula, d represents the number of attributes, x i Indicates that x belongs to the value of the i-th attribute;
[0074] Since P(x) is the same for all classes, based on h * (x) = argmax c R(c|x), the Bayesian decision criterion is:
[0075] The training of Naive Bayes is to estimate the class prior probability P(x) based on the data set D and estimate the conditional probability P(x) for each attribute. i |c), let D C Represents the set of samples of category c in the training set D. If there are sufficient independent and identically distributed samples, it is easy to estimate the class prior probability.
[0076] The samples in this embodiment are all discrete awakenings, let x i Indicates D C The value of the i-th attribute is x i The conditional probability P(x i |c) can be estimated as:
[0077] In a scenario involving the determination of the bill type in this embodiment, the bill type of the original bill collected in a specific business scenario and the prior probability corresponding to the bill type, the probability of each bill being collected, and the probability of each bill containing each field can be determined through data volume statistics. Taking the social security insurance claim business scenario as an example, if the field names contained in the unknown category bill to be judged include name, medical institution name, total medical expenses, basic pooling fund payment amount, self-paid amount, etc., the bill type is determined in this way.
[0078] 1) Calculate the prior probability: the bill type and the statistical prior probability, such as P(invoice) = 0.7, which means that the probability that the bill type is invoice is 0.7.
[0079] 2) Estimate the conditional probability P(x) for each bill type i |c): Taking invoice as an example, P(name / invoice) = 1 (indicates that when the bill type is invoice, the probability of containing the field name "name" is 1), P(name of medical institution / invoice) = 1, P(total medical expenses / invoice) = 1, P(basic pooling fund payment amount / invoice) = 0.7, P(self-paid amount / invoice) = 0.9... The calculation method for other bill types is the same.
[0080] 3) According to the formula Multiply and determine the result: For example, when the recognized field names are name, ID card, name of medical institution, total medical expenses, amount paid by basic pooling fund, and amount paid out of pocket, the probability that this bill type is an invoice is P(invoice / (name, ID card, name of medical institution, total medical expenses, amount paid by basic pooling fund, and amount paid out of pocket)) =
[0081] P(invoice)*P(name / invoice)*P(ID card / invoice)*P(name of medical institution / invoice)*P(total medical expenses / invoice)*P(amount paid by basic pooling fund / invoice)*P(self-paid amount / invoice)=0.441
[0082] The calculation method for other bill types is the same: medical settlement bill: 0.432; medical expense list: 0.72......
[0083] The results show that the probability of "Medical Expense List" is higher, so the final judgment result is "Medical Expense List".
[0084] The above introduces an implementation method of determining the bill type based on the field name of the target field contained in the electronic bill.
[0085] The target field of the electronic invoice includes a target keyword and a target value. When parsing the electronic invoice, it is necessary to distinguish between the target keyword and the target value.
[0086] In one implementation, a bill dictionary table as shown in Table 2 is established:
[0087] Table 2:
[0088]
[0089] The field names of the fields in the bill dictionary table include bill type, bill id, standard field name, enumeration field name, whether the template is divided into dimension fields, field type and field attributes, etc. Among them, the bill id represents the identity identification information of the bill; the standard field name is the target keyword for parsing electronic bills in this embodiment; the enumeration field name refers to the possible corresponding naming method of the standard field name in different bills (such as for the target keyword "name", the corresponding enumeration field name can be "name", "name", "name"), which is usually initialized based on summary and experience, and added when annotating new pictures; whether to divide the dimension field is a special field set in this embodiment based on actual practice to speed up the parsing efficiency of electronic bills: since the bills issued by the same institution have the same format, for example, the medical settlement forms issued by the same medical institution have the same style, in order to make full use of this feature, the medical institution can be used as the template division dimension, that is, each medical settlement form of the medical institution is configured with a template, and the advantage of this is that if the settlement form of the same medical institution can be parsed using "configured annotation template accurate parsing", it is more accurate and efficient. The field type is obtained based on the statistics of the annotations in the annotation template table. If it is set that more than 80% of the standard templates have this attribute, it is determined that the document type has this attribute. The attribute of the field type can be a string or a number; other attributes are also obtained based on the statistics of the annotations in the annotation template table. If it is set that more than 80% of the standard templates have this attribute, it is determined that the document type has this attribute. The other attributes here can be that the target value corresponding to the current target keyword is the maximum value of all target values (marked with l), or the target value corresponding to the current target keyword is the farthest target value among the target values in the same industry (marked with f).
[0090] Step 102, based on the field name of the target field, obtain the relative position relationship corresponding to the field name of the target field from the field names and relative position relationships of the fields contained in the electronic bill that match the bill type of the electronic bill that are pre-stored; the relative position relationship represents: the positional relationship between the keyword in the field at the first position in the original bill and the value corresponding to the keyword at the second position in the original bill.
[0091] In one implementation, the relative position relationship corresponding to the field name of the target field is stored in a preset annotation template table, as shown in Table 3.
[0092] Table 3:
[0093]
[0094] It should be noted that one invoice type has multiple templates (for example, for the medical expense settlement invoice type, the First Hospital and the People's Hospital each have a template), and each "template division dimension" has a template. You can find the appropriate template based on the preset field name identified on the target electronic invoice - the template division dimension field, such as the First Hospital.
[0095] The positional relationship and relative distance in the annotation template table together constitute the relative positional relationship described in this embodiment. The positional relationship in the annotation template table has four values: r, u, cr, and cu: r means that the value is to the right of the keyword; u means that the value is below the keyword; cr means that the value and the keyword are in the same cell and to the right; cu means that the value and the keyword are in the same cell and below. The relative distance in the annotation template table is determined as follows: to the right or below, the relative distance is 1; across n grids, the relative distance is n; in the case of the same cell, the positional relationship is cr, there is no space, and the relative distance is 0; there are n spaces, and the relative distance is n; the positional relationship is cu, there are n line breaks, and the relative distance is n.
[0096] It should be noted that the above-mentioned positional relationship and relative distance all refer to the vertical direction. In a new scenario, technical personnel in this field may easily think that the relative positional relationship between the keyword and the value is not in the vertical direction. The corresponding positional relationship value may include angle information, and the relative distance may include relevant descriptive information such as Euclidean distance.
[0097] Step 103, according to the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, determine the position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates;
[0098] Step 104: Determine, from the electronic ticket, a value corresponding to the target position coordinates as a target value corresponding to the target keyword.
[0099] In one implementation, the correspondence between the target keyword and the target value obtained through parsing is stored in a bill key information parsing table as shown in Table 4 below.
[0100] Table 4:
[0101] Template id Ticket ID Standard field name (key) Enumeration field name (key) value
[0102] In one implementation, according to the constraint conditions of the attributes of the target value stored in the annotation template table, the value corresponding to the target position coordinates is determined from the electronic ticket as the target value corresponding to the target keyword. The constraint conditions of the target value correspond to the field type and other attribute parts of the annotation template table in Table 3, wherein the attributes of the target value include the field type corresponding to the target value, the numerical value of the target value, the distance between the target value and the target keyword, and the semantic similarity between the target value and the historical target value corresponding to the target keyword.
[0103] Determine from the electronic ticket the value corresponding to the target position coordinates as the target value corresponding to the target keyword, including: determining from the electronic ticket the value corresponding to the target position coordinates; if there are multiple values corresponding to the target position coordinates, then according to the constraint condition, select the value that meets the constraint condition from the multiple values corresponding to the target position coordinates as the target value corresponding to the target keyword.
[0104] In this implementation, the target value corresponding to the current target keyword can be quickly selected from multiple target values through the attributes of the target value.
[0105] Example 2
[0106] Embodiment 2 of the present application provides a method for parsing an electronic bill to solve the problem in the prior art of how to efficiently determine the correspondence between keywords and values in non-standard bills.
[0107] The executor of the method may be any computing device that can implement the method, such as a server, a mobile phone, a personal computer, a smart wearable device, a smart robot, and the like.
[0108] The different steps of the method may be implemented by the same execution subject or by different execution subjects. The embodiment of the present application does not limit the execution subject used to implement the method.
[0109] In addition, the execution order of different steps is not limited in the embodiment of the present application. When using the method provided in the embodiment of the present application, the execution order of different steps can be adjusted according to actual needs.
[0110] For ease of description, the method provided in the embodiment of the present application is described in detail below by taking an electronic invoice parsing device as the executor of the method as an example.
[0111] like Figure 2 As shown, a method for parsing an electronic bill provided in an embodiment of the present application includes:
[0112] Step 201, calling the OCR interface for identification, and storing the identification information of the electronic bill into the bill OCR identification information table, wherein the identification information includes the bill ID, content information (field name of the target field), row identifier, row placeholder, column identifier and column placeholder.
[0113] Step 202, parse the content information one by one, match it with the standard field name and enumeration field name in the bill dictionary table, and store the matching results in the bill OCR recognition information table. During the matching process, if an exact match is not possible, a word vector semantic match is used. If the word vector semantic match between the field name in the content information and the standard field name (enumeration field name) in the bill field table reaches a set threshold, the match is considered successful.
[0114] Step 203: Determine the bill type through a Bayesian classifier according to the standard field name in the bill OCR recognition information table.
[0115] Step 204, query the dimension division field of the current bill type in the bill dictionary table: if the value of the whether template division dimension field in the bill dictionary table is 1, the current bill type has a dimension division field, and the standard field name corresponding to the whether template division dimension field value is 1 is the dimension division field.
[0116] Step 205, determine whether the dimension division field is found on the current electronic receipt, if so, execute step 206, if not, execute step 209.
[0117] Step 206, searching the annotation template table for the field name corresponding to the dimension division field. As shown in Table 2 above, the field name corresponding to the dimension division field is medical institution.
[0118] Step 207, determine whether the field name of the current dimension division field is configured with a labeling template, that is, whether there is a record of the labeling template for the field name corresponding to the dimension division field of the current bill type in the labeling template table; if so, execute step 208, if not, execute step 209.
[0119] Step 208, obtain the position coordinates of the target keyword in the bill OCR recognition information table, calculate the position coordinates of the target value according to the position relationship and relative distance corresponding to the current target keyword in the annotation template table, match the value of the position coordinates from the bill OCR recognition information table, and record it in the bill key information analysis table.
[0120] Step 209, determine the target value corresponding to the target keyword through the constraint conditions of the attribute of the target value of the target keyword, and record it in the bill key information analysis table.
[0121] In one implementation, the specific implementation process of step 209 is as follows: Figure 3As shown in the figure (key represents the target keyword and value represents the target value), the target keywords mentioned in the following steps correspond to the standard field names. Implementation methods include:
[0122] Step 301, obtaining a target keyword, the position coordinates of the target keyword, and the position information of the cell where the target keyword is located from the bill OCR recognition information table.
[0123] Step 302 , determine whether the target value value exists in the cell where the target keyword key is located. If so, execute step 303 ; if not, execute step 310 .
[0124] Step 303 , check the bill dictionary table to see whether the target keyword (standard field name) corresponds to the longest distance attribute (f). If so, execute step 304 ; if not, execute step 307 .
[0125] Step 304, determine whether there is a line break between the target keyword and the target value, if so, execute step 305, if not, execute step 306.
[0126] Step 305, obtaining from the bill OCR recognition information table the target value in the same cell that is farthest from the target keyword in the same row, and the target value in the same cell that is farthest from the target keyword in the same column.
[0127] Step 306, obtaining the target value value that is farthest from the target keyword key in the same cell from the bill OCR recognition information table.
[0128] Step 307, determine whether there is a line break between the target keyword and the target value, if so, execute step 308, if not, execute step 309.
[0129] Step 308: Obtain the value immediately to the right of the target keyword key and the target value immediately below the key in the same cell from the bill OCR recognition information table.
[0130] Step 309: Obtain the target value value in the same cell immediately to the right of the target keyword key from the bill OCR recognition information table.
[0131] Step 310, check the bill dictionary table to determine whether the target keyword key corresponds to the longest distance attribute, if so, execute step 311, if not, execute step 312.
[0132] Step 311, obtaining the value in the cell farthest from the target keyword key in the same row and the target value value in the cell farthest from the key in the same column from the bill OCR recognition information table.
[0133] Step 312, from the bill OCR recognition information table, obtain the value in the cell to the right of the target keyword key and the target value value in the cell below the same column as key.
[0134] Step 313: For the target value obtained in steps 305, 308, 311 and 312, there may be more than one. Check the bill dictionary table to determine whether the target keyword corresponds to the maximum value attribute (l). If so, execute step 314. If not, execute step 316. The maximum value refers to the maximum value of the target value corresponding to the target keyword.
[0135] Step 314, determine whether the number of target values obtained is greater than 1, if so, execute step 316, if not, execute step 315.
[0136] Step 315, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table.
[0137] Step 316, determine whether the number of values that meet the field type in the bill dictionary table is greater than 1, if so, execute step 318, if not, execute step 317.
[0138] Step 317, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table.
[0139] Step 318, compare the semantic similarity between value and the historical value corresponding to the target keyword, select the value with the greatest similarity as the value corresponding to the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table.
[0140] It should be noted that the fields contained in the electronic receipt in this embodiment are all in cells, such as Figure 4 As shown, the location information of the cell can be returned through the basic OCR interface.
[0141] However, in actual situations, there are tickets where the fields are not in the cells, such as Figure 5As shown, except for the field name "General Prescription" in the cell, the other field names are not in the cell. For this electronic receipt, before obtaining the position coordinates corresponding to the target field from the electronic receipt, it also includes: obtaining the position information of the area boundary of the text area from the electronic receipt; the text area includes the text area where the field in the electronic receipt is located in the original receipt; according to the set position coordinate conversion method, the position information of the area boundary of the text area is converted into the position coordinates corresponding to the field in the electronic receipt; the converted field position coordinates are saved in the electronic receipt.
[0142] In one implementation, a basic OCR interface capable of returning text area block position information is used to recognize a bill, and the returned message information includes the position information of the area boundary of the text area. The area boundary position information includes the height, width, left boundary and top boundary of the text area; or the area boundary position information includes the width, height, right boundary and bottom boundary of the text area.
[0143] The position coordinate conversion method is specifically as follows (the position information of the region boundary includes the height and width of the text region, and the left boundary and the upper boundary of the text region as an example for explanation):
[0144] (1) Calculate the lower boundary of the text area according to the upper boundary and height, and calculate the left boundary of the text area according to the right boundary and width;
[0145] (2) Marking the line number. Since the lower boundary of the previous line must be below the upper boundary of the next line, it is possible to determine which text areas are in the same line, and thus mark the line number of each text area.
[0146] (3) Draw horizontal lines according to the upper and lower boundaries of the text area, and calculate the row identifier and row placeholder. Process each row one by one, and find the value with the smallest upper boundary in the same row as the row identifier of the row, which is equivalent to drawing a line next to the text at the top of a row. The row placeholder is the row identifier of the next row minus the row identifier of the previous row.
[0147] (4) Draw vertical lines according to the left and right borders of the text area, and calculate the column identifier and column placeholder. The column identifier is the left border of each field, which is equivalent to drawing a vertical line next to the left side of each text. The column placeholder is the left border of the right field minus the left border of the left field. The column placeholder of the last column is equal to its width.
[0148] According to the above steps (1) to (4), the row identifier, column identifier, row placeholder and column placeholder of each field in the electronic receipt are obtained, that is, the position coordinates of each field and the position information of the cell where each field is located are obtained.
[0149] For an electronic receipt in which fields do not completely exist in a cell, that is, an electronic receipt in which some fields exist in a cell and other fields do not exist in a cell, a basic OCR interface capable of returning text area block position information is called to obtain first text information, a basic OCR interface capable of returning cell position information is called to obtain second text information, a difference between the first text information and the second text information is taken to obtain third text information in which fields do not exist in the cell, and the third text information is used in correspondence with the above steps (1) to (4) to obtain the position coordinates of each field.
[0150] In this embodiment, for electronic receipts whose text information is not in a cell, the location information of the target field is obtained through a preset location coordinate conversion method, so that the electronic receipt parsing method of this embodiment can be applied to various forms of electronic receipts.
[0151] Example 3
[0152] Embodiment 3 of the present application provides a method for marking an electronic invoice, which is used to solve the problem in the prior art of how to efficiently determine the relative position relationship corresponding to keywords in a non-standard invoice.
[0153] The executor of the method may be any computing device that can implement the method, such as a server, a mobile phone, a personal computer, a smart wearable device, a smart robot, and the like.
[0154] The different steps of the method may be implemented by the same execution subject or by different execution subjects. The embodiment of the present application does not limit the execution subject used to implement the method.
[0155] In addition, the execution order of different steps is not limited in the embodiment of the present application. When using the method provided in the embodiment of the present application, the execution order of different steps can be adjusted according to actual needs.
[0156] For ease of description, the method provided in the embodiment of the present application is described in detail below by taking an electronic invoice parsing device as the executor of the method as an example.
[0157] like Figure 6 As shown, a method for marking an electronic invoice provided by an embodiment of the present application, the marking of an electronic invoice refers to determining the relative position relationship between a keyword and a corresponding value, and storing the target value and the corresponding relative position relationship in correspondence. The method for marking an electronic invoice includes:
[0158] Step 601, obtain the field name of the target field contained in the electronic invoice and the position coordinates corresponding to the target field from the electronic invoice; the position coordinates corresponding to the target field represent: the target keyword in the target field is at the first position in the original invoice, and the target value in the target field is at the second position in the original invoice.
[0159] In one implementation, non-standard bills from different sources are identified by OCR (Optical Character Recognition) to obtain the electronic bill corresponding to the original bill. The message returned by the OCR non-standard recognition interface includes the field name of the target field contained in the electronic bill, and the position coordinates of the target field located by the row identifier and column identifier. The target field includes a target keyword and a target value.
[0160] Step 602: Determine the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value.
[0161] The relative position relationship includes the position relationship (r, u, cr, cu) and relative distance between the target keyword and the target value (the target value is to the right or below the target keyword, the relative distance is 1; across n grids, the relative distance is n; in the same cell, the position relationship is cr, there is no space, the relative distance is 0; there are n spaces, the relative distance is n; the position relationship is Cu, there are n line breaks, the relative distance is n)
[0162] Step 603: Correspondingly store the target keyword, the relative position relationship, and the bill type matching the electronic bill.
[0163] In one implementation, the target keyword, relative position relationship, and the corresponding storage of the bill type matching the electronic bill include: if there is a preset name in the field name of the target field, the target field in the electronic bill containing the preset name and the relative position relationship corresponding to the target field are stored in the template table.
[0164] The preset name corresponds to the field name corresponding to the dimension division field in the above embodiment, and is used as a criterion for whether to configure the annotation template. The preset name is the medical institution mentioned above.
[0165] In one implementation, the target keyword, relative position relationship, and the bill type that matches the electronic bill are stored in correspondence, including: in the relative position relationship between the target keyword of the template table and the corresponding target value, if the target value meets the constraint conditions of the attributes of the preset target value, then the constraint conditions that the target value meets are stored in correspondence with the bill type that matches the electronic bill.
[0166] The attributes of the target value include the field type corresponding to the target value (the corresponding constraints are string and number); the numerical value of the target value (the corresponding constraints are maximum and minimum); the distance between the target value and the target keyword (the corresponding constraints are farthest and closest); the semantic similarity between the target value and the historical target value corresponding to the target keyword (the corresponding constraint is maximum semantic similarity).
[0167] Example 4
[0168] Embodiment 4 of the present application provides a method for marking an electronic invoice, which is used to solve the problem in the prior art of how to efficiently determine the relative position relationship corresponding to keywords in a non-standard invoice.
[0169] The executor of the method may be any computing device that can implement the method, such as a server, a mobile phone, a personal computer, a smart wearable device, a smart robot, and the like.
[0170] The different steps of the method may be implemented by the same execution subject or by different execution subjects. The embodiment of the present application does not limit the execution subject used to implement the method.
[0171] In addition, the execution order of different steps is not limited in the embodiment of the present application. When using the method provided in the embodiment of the present application, the execution order of different steps can be adjusted according to actual needs.
[0172] For ease of description, the method provided in the embodiment of the present application is described in detail below by taking an electronic invoice parsing device as the executor of the method as an example.
[0173] like Figure 7 , 8 As shown, a method for marking an electronic bill provided in an embodiment of the present application includes:
[0174] Step 700, calling the OCR interface for identification, and storing the identification information of the electronic bill into the bill OCR identification information table, wherein the identification information includes the bill ID, content information (field name of the target field), row identifier, row placeholder, column identifier and column placeholder.
[0175] Step 701, parse the content information one by one, match it with the standard field name and enumeration field name in the bill dictionary table, and store the matching results in the bill OCR recognition information table. During the matching process, if an exact match is not possible, a word vector semantic match is used. If the word vector semantic match of the field name in the content information and the standard field name (enumeration field name) in the bill field table reaches a set threshold, the match is considered successful.
[0176] Step 702: Determine the bill type through a Bayesian classifier based on the standard field name in the bill OCR recognition information table.
[0177] Step 703, query the dimension division field of the current bill type in the bill dictionary table: if the value of the whether template division dimension field in the bill dictionary table is 1, the current bill type has a dimension division field, and the standard field name corresponding to the whether template division dimension field value is 1 is the dimension division field.
[0178] Step 704, determine whether the dimension division field is found on the current electronic receipt, if so, execute step 705, if not, execute step 708.
[0179] Step 705, searching the annotation template table for the field name corresponding to the dimension division field. As shown in Table 2 above, the field name corresponding to the dimension division field is medical institution.
[0180] Step 706, determine whether the field name of the current dimension division field is configured with a marking template, that is, whether there is a record of the marking template for the field name corresponding to the dimension division field of the current invoice type in the marking template table; if yes (indicating that the current electronic invoice has been marked), end the marking, if not, execute step 707.
[0181] Step 707, adding a record to the annotation template table, that is, storing the annotation information of the current electronic receipt containing the dimension division field into the annotation template table.
[0182] Step 708, traverse the standard field names in the bill field table, if the field name corresponding to the current electronic bill does not exist in the bill dictionary table, then add an enumerated field name to the bill dictionary table.
[0183] Step 709, respectively obtain the position coordinates of the target keyword key and the corresponding target value value from the bill OCR recognition information table, and calculate the relative position relationship between the key and the value.
[0184] Step 710, determine whether the position coordinates of key and value are the same, if so (key and value are in the same cell), execute step 711, if not (key and value are not in the same cell), execute step 724.
[0185] Step 711, determine whether there is a line break between key and value, if so, execute step 712, if not, execute step 718.
[0186] Step 712: label the position relationship cu.
[0187] Step 713, according to the number n of line breaks between the key and the value, mark the relative distance n.
[0188] Step 714, determine whether value is farthest from key in the same cell by comparing the vertical values of the column where value is located. If so, execute step 715, if not, execute step 716.
[0189] Step 715, marking the distance size attribute f.
[0190] Step 716, determine whether value is the largest in the same cell by comparing the vertical values in the column where value is located. If so, execute step 717, if not, execute step 737.
[0191] Step 717, marking the numerical value attribute l.
[0192] Step 718, mark the position relationship cr.
[0193] Step 719, mark the relative distance n according to the number of spaces n.
[0194] Step 720, determine whether the value is farthest from the key in the same cell by comparing the horizontal values of the row where the value is located. If so, execute step 721, if not, execute step 722.
[0195] Step 721, marking the distance size attribute f.
[0196] Step 722, determine whether value is the largest in the horizontal value comparison of the row where value is located in the same cell. If so, execute step 723, if not, execute step 737.
[0197] Step 723, marking the numerical value attribute l.
[0198] Step 724, compare the row identifier and column identifier of key and value; that is, compare whether the row identifier of key and value are the same, and compare whether the column identifier of key and value are the same. If the row identifiers are the same, execute step 725; if the column identifiers are the same, execute step 731.
[0199] Step 725, mark the position relationship r.
[0200] Step 726, according to the number n of cells in the same row, mark the relative distance n.
[0201] Step 727, compare the values of all cells in the row where value is located to determine whether value is farthest from key. If so, execute step 728, if not, execute step 729.
[0202] Step 728, marking the distance size attribute f.
[0203] Step 729, compare the horizontal values of the row where value is located to determine whether value is the largest. If so, execute step 730, if not, execute step 737.
[0204] Step 730, marking the numerical value attribute l.
[0205] Step 731, mark the position relationship u.
[0206] Step 732, according to the number n of cells spaced in the same column, mark the relative distance n.
[0207] Step 733, compare the values of all cells in the column where value is located to determine whether value is farthest from key. If so, execute step 734, if not, execute step 735.
[0208] Step 734, marking the distance size attribute f.
[0209] Step 735, determine whether value is the largest by comparing the values of all cells in the row where value is located. If so, execute step 736, if not, execute step 737.
[0210] Step 736, marking the numerical value attribute l.
[0211] Step 737, marking the field type attribute according to the field type to which the value belongs.
[0212] Step 738, calculate the annotation attributes of all annotation templates corresponding to the same target keyword under the same bill type. If the annotation attributes exceed a preset threshold (such as 80%), then mark the attributes corresponding to the corresponding standard field names in the bill dictionary table.
[0213] In one implementation, the existing historical data is natural annotated data, that is, the data that has been entered and the original bill image. The original bill images are batch imported into the automatic annotation module, and the OCR non-standard interface is called one by one. Figure 7 , 8) to complete the automatic labeling. For example, in the social security claims business system, a large amount of bill data of medical institutions has been accumulated in the system. After the labeling is completed at one time, the bills of these medical institutions can be accurately analyzed. Historical data and pictures are existing labeled data. Import the pictures one by one into the labeling module to automatically generate labeling data.
[0214] In one implementation, you can actively annotate a template and upload an annotated document image on the annotation page. The system calls the adaptive learning rules to automatically parse the key and value, and manually checks and corrects the document type, key, and value to complete the annotation work.
[0215] In one implementation, every time a bill image is identified and analyzed, it is automatically labeled. The data in the database becomes increasingly rich, especially special attributes that can be fully mined. More and more document templates are covered by precise analysis, and the accuracy of analysis continues to improve.
[0216] Example 5
[0217] In order to solve the problem existing in the prior art of how to efficiently determine the correspondence between keywords and values in non-standard bills, based on the same inventive concept as the above-mentioned embodiment 1 of the present application, embodiment 5 of the present application provides an electronic bill parsing system.
[0218] The specific structural diagram of the analysis system is shown in the following figure. Fig. 9 As shown, it includes the following functional units:
[0219] The first field information acquisition unit 901 is used to acquire, from the electronic bill, the field name of the target field contained in the electronic bill and the position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill;
[0220] The relative position information acquisition unit 902 acquires, according to the field name of the target field, a relative position relationship corresponding to the field name of the target field from the field names and relative position relationships of the fields contained in the electronic receipt that match the receipt type of the electronic receipt and that are pre-stored in correspondence; the relative position relationship represents: a position relationship between a keyword in the field at a first position in the original receipt and a value corresponding to the keyword at a second position in the original receipt;
[0221] The target position determination unit 903 determines, according to the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates;
[0222] The target value determination unit 904 is used to determine the value corresponding to the target position coordinates from the electronic ticket as the target value corresponding to the target keyword.
[0223] Example 6
[0224] In order to solve the problem existing in the prior art of how to efficiently determine the corresponding relative position relationship, based on the same inventive concept as the above-mentioned embodiment 3 of the present application, embodiment 6 of the present application provides an electronic invoice marking system.
[0225] The specific structural diagram of the annotation system is as follows Fig.10 As shown, it includes the following functional units:
[0226] The second field information acquisition unit 1001 acquires, from the electronic bill, a field name of a target field contained in the electronic bill and position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent: the first position of the target keyword in the target field in the original bill, and the second position of the target value in the target field in the original bill;
[0227] The relative position determination unit 1002 determines the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value;
[0228] The annotation storage unit 1003 is used to store the relative position relationship and the bill type that matches the electronic bill in a corresponding manner.
[0229] Example 7
[0230] Based on the same inventive concept as the aforementioned embodiments of the present application, Embodiment 7 of the present application provides a computing device, which may include an electronic invoice parsing device and an electronic invoice marking device.
[0231] like Fig.11 As shown, the computing device includes: a memory 1101 and a processor 1102. The memory 1101 can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application or method for operating on the electronic device. The memory 1101 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk.
[0232] Processor 1102, coupled to memory 1101, is used to execute a computer program stored in memory 1101, so as to execute an electronic bill parsing method described in Example 1 of the present application, or an electronic bill classification method described in Example 3 of the present application.
[0233] When the processor 1102 executes the computer program in the memory 1101, in addition to the above functions, other functions may also be implemented, and details may be referred to the description of the previous embodiments.
[0234] Further, such as Fig.11 As shown, the computing device also includes: a display 1104, a communication component 1103, a power component 1105, an audio component 1106 and other components. Fig.11 Only some components are shown schematically, and it does not mean that the computing device only includes Fig.11 Components shown.
[0235] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a computer, the methods provided in the above embodiments can be implemented.
[0236] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0237] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
Claims
1. A method for parsing an electronic bill, characterized in that: include: Obtaining, from the electronic receipt, the field name of the target field contained in the electronic receipt and the position coordinates corresponding to the target field; The position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill; According to the field name of the target field, the relative position relationship corresponding to the field name of the target field is obtained from the field names and relative position relationships of the fields contained in the electronic receipt that match the receipt type of the electronic receipt and that are stored in advance; The relative position relationship represents: the position relationship between the keyword in the field at the first position in the original bill and the value corresponding to the keyword at the second position in the original bill; According to the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, determine the position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates; Determining, from the electronic ticket, a value corresponding to the coordinates of the target location as a target value corresponding to the target keyword; The pre-stored corresponding content also includes constraints on the attributes of the target value; then, The step of determining, from the electronic ticket, a value corresponding to the target position coordinates as a target value corresponding to the target keyword comprises: determining, from the electronic ticket, a value corresponding to the coordinates of the target location; If there are multiple values corresponding to the target position coordinates, then according to the constraint condition, from the multiple values corresponding to the target position coordinates, a value that meets the constraint condition is selected as the target value corresponding to the target keyword; The step of selecting a value that meets the constraint condition from the multiple values corresponding to the target position coordinates as the target value corresponding to the target keyword includes: Step 301, obtaining a target keyword, the position coordinates of the target keyword, and the position information of the cell where the target keyword is located from the bill OCR recognition information table; Step 302, determine whether the target value value exists in the cell where the target keyword key is located, if so, execute step 303, if not, execute step 310; Step 303, check the bill dictionary table to see if the target keyword corresponds to the longest distance attribute. If so, execute step 304; if not, execute step 307; Step 304, determine whether there is a line break between the target keyword and the target value, if yes, execute step 305, if no, execute step 306; Step 305, obtaining the target value with the longest distance from the target keyword in the same cell and the target value with the longest distance from the target keyword in the same column from the bill OCR recognition information table; Step 306, obtaining the target value value that is farthest from the target keyword key in the same cell from the bill OCR recognition information table; Step 307, determine whether there is a line break between the target keyword and the target value, if yes, execute step 308, if no, execute step 309; Step 308, obtaining the value immediately to the right of the target keyword key and the target value immediately below the key in the same cell from the bill OCR recognition information table; Step 309, obtaining the target value value in the same cell immediately to the right of the target keyword key from the bill OCR recognition information table; Step 310, check the bill dictionary table to determine whether the target keyword key corresponds to the longest distance attribute, if so, execute step 311, if not, execute step 312; Step 311, from the bill OCR recognition information table, obtain the value in the cell that is farthest from the target keyword key in the same row, and the target value value in the cell that is farthest from the key in the same column; Step 312, from the bill OCR recognition information table, obtain the value in the cell to the right of the target keyword key and the target value value in the cell below the same column as the key; Step 313: if there is more than one target value obtained in steps 305, 308, 311 and 312, check the bill dictionary table to determine whether the target keyword corresponds to a maximum value attribute. If so, execute step 314; if not, execute step 316, where the maximum value refers to the maximum value of the target value corresponding to the target keyword. Step 314, determine whether the number of the obtained target value value is greater than 1, if so, execute step 316, if not, execute step 315; Step 315, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table; Step 316, determine whether the number of values that meet the field type in the bill dictionary table is greater than 1, if so, execute step 318, if not, execute step 317; Step 317, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table; Step 318, compare the semantic similarity between value and the historical value corresponding to the target keyword, select the value with the greatest similarity as the value corresponding to the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table.
2. The method according to claim 1, characterized in that The attributes of the target value include at least one of the following: The field type corresponding to the target value; The numerical value of the target value; The distance between the target value and the target keyword; The semantic similarity between the target value and the historical target value corresponding to the target keyword.
3. The method according to claim 1, characterized in that Before obtaining the position coordinates corresponding to the target field from the electronic receipt, the method further includes: Acquire location information of a region boundary of a text region from the electronic bill; the text region includes the text region where the fields in the electronic bill are located in the original bill; According to a set position coordinate conversion method, the position information of the area boundary of the text area is converted into the position coordinates corresponding to the fields in the electronic receipt; The location coordinates of the converted fields are saved in the electronic receipt.
4. A method for marking an electronic bill, characterized in that: The electronic bill is parsed using the parsing method described in any one of claims 1 to 3, and the marking method includes: Obtaining, from the electronic bill, a field name of a target field contained in the electronic bill, and position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent: a first position of a target keyword in the target field in the original bill, and a second position of a target value in the target field in the original bill; Determine the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value; Correspondingly storing the target keyword, the relative position relationship, and the bill type matching the electronic bill; The corresponding storage of the target keyword, the relative position relationship, and the bill type matching the electronic bill includes: In the relative position relationship between the target keyword and the corresponding target value in the template table, if the target value meets the constraint conditions of the preset target value attribute, the constraint conditions met by the target value are stored correspondingly to the bill type matching the electronic bill.
5. The method according to claim 4, characterized in that The attributes of the target value include at least one of the following: The field type corresponding to the target value; The numerical value of the target value; The distance between the target value and the target keyword; The semantic similarity between the target value and the historical target value corresponding to the target keyword.
6. The method according to claim 4, characterized in that The corresponding storage of the target keyword, the relative position relationship, and the bill type matching the electronic bill includes: If there is a preset name in the field name of the target field, the target field in the electronic receipt containing the preset name and the relative position relationship corresponding to the target field are stored in the template table.
7. An electronic bill analysis system, characterized in that: include: The first field information acquisition unit is used to acquire, from the electronic bill, the field name of the target field contained in the electronic bill and the position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent the position of the target keyword in the target field in the original bill; A relative position information acquisition unit, based on the field name of the target field, acquires the relative position relationship corresponding to the field name of the target field from the field names and relative position relationships of the fields included in the electronic receipt that match the receipt type of the electronic receipt and are stored in advance; The relative position relationship represents: the position relationship between the keyword in the field at the first position in the original bill and the value corresponding to the keyword at the second position in the original bill; A target position determination unit determines, according to the position coordinates corresponding to the target field and the relative position relationship corresponding to the field name of the target field, position coordinates that meet the relative position relationship between the position coordinates corresponding to the target field as the target position coordinates; a target value determination unit, configured to determine, from the electronic ticket, a value corresponding to the target position coordinates as a target value corresponding to the target keyword; The pre-stored corresponding content also includes constraints on the attributes of the target value; then, The target value determination unit determines, from the electronic ticket, a value corresponding to the target position coordinate as the target value corresponding to the target keyword, including: determining, from the electronic ticket, a value corresponding to the coordinates of the target location; If there are multiple values corresponding to the target position coordinates, then according to the constraint condition, from the multiple values corresponding to the target position coordinates, a value that meets the constraint condition is selected as the target value corresponding to the target keyword; The step of selecting a value that meets the constraint condition from the multiple values corresponding to the target position coordinates as the target value corresponding to the target keyword includes: Step 301, obtaining a target keyword, the position coordinates of the target keyword, and the position information of the cell where the target keyword is located from the bill OCR recognition information table; Step 302, determine whether the target value value exists in the cell where the target keyword key is located, if so, execute step 303, if not, execute step 310; Step 303, check the bill dictionary table to see if the target keyword corresponds to the longest distance attribute. If so, execute step 304; if not, execute step 307; Step 304, determine whether there is a line break between the target keyword and the target value, if yes, execute step 305, if no, execute step 306; Step 305, obtaining the target value with the longest distance from the target keyword in the same cell and the target value with the longest distance from the target keyword in the same column from the bill OCR recognition information table; Step 306, obtaining the target value value that is farthest from the target keyword key in the same cell from the bill OCR recognition information table; Step 307, determine whether there is a line break between the target keyword and the target value, if yes, execute step 308, if no, execute step 309; Step 308, obtaining the value immediately to the right of the target keyword key and the target value immediately below the key in the same cell from the bill OCR recognition information table; Step 309, obtaining the target value value in the same cell immediately to the right of the target keyword key from the bill OCR recognition information table; Step 310, check the bill dictionary table to determine whether the target keyword key corresponds to the longest distance attribute, if so, execute step 311, if not, execute step 312; Step 311, from the bill OCR recognition information table, obtain the value in the cell that is farthest from the target keyword key in the same row, and the target value value in the cell that is farthest from the key in the same column; Step 312, from the bill OCR recognition information table, obtain the value in the cell to the right of the target keyword key and the target value value in the cell below the same column as the key; Step 313: if there is more than one target value obtained in steps 305, 308, 311 and 312, check the bill dictionary table to determine whether the target keyword corresponds to a maximum value attribute. If so, execute step 314; if not, execute step 316, where the maximum value refers to the maximum value of the target value corresponding to the target keyword. Step 314, determine whether the number of the obtained target value value is greater than 1, if so, execute step 316, if not, execute step 315; Step 315, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table; Step 316, determine whether the number of values that meet the field type in the bill dictionary table is greater than 1, if so, execute step 318, if not, execute step 317; Step 317, determine that the current target value value is the value of the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table; Step 318, compare the semantic similarity between value and the historical value corresponding to the target keyword, select the value with the greatest similarity as the value corresponding to the target keyword, and write the target keyword and the corresponding value into the bill key information parsing table.
8. An electronic invoice marking system, characterized in that: The electronic bill is parsed using the parsing system according to claim 7, and the annotation system includes: The second field information acquisition unit acquires, from the electronic bill, a field name of a target field contained in the electronic bill and position coordinates corresponding to the target field; the position coordinates corresponding to the target field represent: a first position of a target keyword in the target field in the original bill, and a second position of a target value in the target field in the original bill; A relative position determination unit, which determines the relative position relationship between the target keyword and the corresponding target value according to the position coordinates corresponding to the target field and the preset corresponding relationship between the target keyword and the target value; A marking storage unit, used for correspondingly storing the relative position relationship and the bill type matching the electronic bill; In the annotation storage unit, the target keyword, the relative position relationship, and the bill type matching the electronic bill are stored correspondingly, including: In the relative position relationship between the target keyword and the corresponding target value in the template table, if the target value meets the constraint conditions of the preset target value attribute, the constraint conditions met by the target value are stored correspondingly to the bill type matching the electronic bill.
9. An electronic bill parsing device, characterized in that: include: Memory and processor, wherein: The memory is used to store computer programs; The processor is coupled to the memory and is used to execute the computer program stored in the memory to execute the method described in any one of claims 1 to 3.
10. An electronic bill marking device, characterized in that: include: Memory and processor, wherein: The memory is used to store computer programs; The processor is coupled to the memory and is used to execute the computer program stored in the memory to execute the method according to any one of claims 4 to 6.
11. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer, can implement the electronic invoice parsing method described in any one of claims 1 to 3, or can implement the electronic invoice marking method described in any one of claims 4 to 6.
Citation Information
Patent Citations
Bill identification method, apparatus and device, computer storage medium and program product
CN114550189A