Method, device and computer readable medium for extracting bill data

By constructing keyword charts and sub-graphs, the problem of insufficient withdrawal of shopping receipts is solved, and the withdrawal of ticket data with higher accuracy is achieved, and the reliability of business analysis is improved.

CN113920515BActive Publication Date: 2025-04-04SHANGHAI SUMI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111281487.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-01
Publication Date
2025-04-04
Estimated Expiration
2041-11-01

AI Technical Summary

Technical Problem

When withdrawing order amounts in shopping receipts, the prior art fails to fully consider the correlation between the amount-related keywords, resulting in a large difference between the withdrawn amount and the actual net operating income, affecting the accuracy of the mall operation analysis.

Method used

Build a keyword chart, including vertices and edges. Vertexes represent keywords and matching rules, and edges represent operational relationships between vertices. By comparing keywords in keyword graphs and target text in bills, a keyword sub-graph is constructed, and the longest path is selected from them to calculate the target data to improve extraction accuracy.

Benefits of technology

By constructing keyword charts and sub-graphs, the ticket data can be extracted more finely, reducing bias, and improving the reliability and accuracy of business analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113920515B_ABST
    Figure CN113920515B_ABST
Patent Text Reader

Abstract

The present invention relates to a method, device and computer-readable medium for extracting bill data. The method comprises constructing a keyword graph, the keyword graph comprises vertices and edges, the vertices comprise keywords and matching rules, and the edges comprise an operational relationship between two connected vertices; obtaining a target text in the bill, each target text comprises mutually corresponding text and data; comparing the keywords in each vertex in the keyword graph and the text in each target text according to the matching rules, obtaining a target vertex matching the target text, constructing a keyword subgraph of the bill according to the target vertex and the target edge corresponding to the target vertex; selecting the longest path among all paths including the target vertex and the target edge from the keyword subgraph; and calculating the target data according to the operational relationship between the data corresponding to the keyword of the target vertex in the longest path and the target edge. The method determines the calculation method of the target data through the keyword graph, thereby improving the accuracy of bill data extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the field of text processing, and in particular to a method, device and computer-readable medium for extracting bill data. Background Art

[0002] In recent years, artificial intelligence has gradually become an important driving force for global technological and industrial changes, promoting the rise and development of business intelligence. Merchant shopping receipt information analysis (referred to as receipt analysis) is a relatively important application in the field of business intelligence and has begun to receive widespread attention in recent years. Receipt analysis can summarize merchant orders and transaction information for various shopping malls, shopping streets and shopping centers, and plays an important role in mall operation analysis, mall business distribution, merchant rental plans, etc.

[0003] Receipt parsing refers to extracting the required order information or business information from the merchant's shopping receipt, such as order number, order time, order amount, etc. Take the extraction of order amount as an example. When extracting the order amount, the general receipt parsing system often roughly extracts a specific parsing keyword to obtain the net operating income. In actual application scenarios, a receipt may have multiple keywords related to the amount. Existing technologies do not fully consider the association between these keywords, so the amount extracted is often quite different from the net operating income. For example, the receipt parsing system uses the "total amount" as the key basis for extracting the order amount, but when the order has a special discount, the "discount amount" item will appear, and the actual net operating income should be subtracted from the total amount. If the receipt parsing system does not consider the "discount amount", the parsed amount will not match the actual income. If such data is directly used for shopping mall operation analysis, the analysis results will be biased.

[0004] Therefore, there is an urgent need for a highly accurate method and device for extracting bill data to improve the reliability of user business analysis. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a method, device and computer-readable medium for extracting bill data, so as to solve the problem that the extraction of bill data is not precise enough, resulting in large deviation in the extraction result.

[0006] To solve the above technical problems, the present application proposes a method for text recognition of shopping receipts, including: constructing a keyword graph, the keyword graph includes vertices and edges, the vertices include keywords and matching rules, the keywords correspond to the matching rules one by one, the edges are used to connect two vertices, the edges include the operational relationship between the two connected vertices, and the keywords are related to the target data to be extracted; obtaining the target text in the receipt, each target text includes mutually corresponding text and data; comparing the keywords in each vertex in the keyword graph and the text in each target text according to the matching rules, obtaining the target vertex matching the target text, and constructing the keyword subgraph of the receipt according to the target vertex and the target edge corresponding to the target vertex; selecting the longest path from all paths including the target vertex and the target edge from the keyword subgraph; and calculating the target data according to the operational relationship between the data corresponding to the keyword of the target vertex in the longest path and the target edge.

[0007] In one embodiment of the present application, the step of obtaining the target text in the bill includes: setting a starting position and an ending position; extracting all text lines between the starting position and the ending position in the bill; and extracting the target text in all text lines.

[0008] In one embodiment of the present application, the steps of setting the starting position and the ending position include: searching the text lines in the bill line by line, and comparing the text in the text lines with the keywords, taking the text line number where the text matching the keyword appears for the first time as the starting position, and taking the text line number where the text matching the keyword appears for the last time as the ending position.

[0009] In one embodiment of the present application, after the step of comparing the keywords in each vertex in the keyword graph and the text in each target text according to the matching rules, it also includes: if the target text cannot match the keyword in any vertex in the keyword graph, the target text is used as a new keyword, and a new vertex is added to the keyword graph. The new vertex includes the new keyword and the corresponding new matching rule, and one or more new edges are constructed according to the operational relationship between the new vertex and other vertices.

[0010] In one embodiment of the present application, the step of constructing a keyword subgraph of the bill based on the target vertex matching the target text and the target edge corresponding to the target vertex includes: in the keyword graph, adding a match failure mark to the vertex that does not match the text in the target text.

[0011] In one embodiment of the present application, the step of constructing a keyword subgraph of the bill based on target vertices matching the target text and target edges corresponding to the target vertices includes: in the keyword graph, deleting vertices that do not match the text in the target text and edges related to the vertices.

[0012] In one embodiment of the present application, the step of selecting the longest path among all paths including the target vertex and the target edge from the keyword subgraph includes: traversing all paths in the keyword subgraph using a depth-first traversal method, and determining the deepest path as the longest path.

[0013] In one embodiment of the present application, the keyword graph further includes a start vertex and an end vertex, the start vertex serves as the starting point of all paths, and the end vertex serves as the end point of all paths.

[0014] In one embodiment of the present application, the data is amount data.

[0015] In order to solve the above technical problems, the present application also proposes a device for extracting bill data, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the method as described above.

[0016] In order to solve the above technical problem, the present application also proposes a computer-readable medium storing a computer program code, and the computer program code implements the above method when executed by a processor.

[0017] The method for extracting bill data of the present invention constructs a keyword graph related to the target data, and constructs a keyword subgraph according to the target text of the bill, and selects the longest path from all paths in the keyword subgraph to calculate the target data, thereby improving the accuracy of bill data extraction. By adding new vertices and edges to the keyword graph, different types of bills can be handled, thereby improving the scalability and availability of bill data extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to make the above-mentioned objects, features and advantages of the present invention more clearly understood, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein:

[0019] Figure 1 is an exemplary flow chart of an extraction method according to an embodiment of the present invention;

[0020] Figure 2 is a schematic diagram of a keyword graph in an extraction method according to an embodiment of the present invention;

[0021] Figure 3 is a schematic diagram of a bill obtained by an extraction method according to an embodiment of the present invention;

[0022] Figure 4 is a schematic diagram of another bill obtained by the extraction method according to an embodiment of the present invention;

[0023] Figure 5 According to an extraction method according to an embodiment of the present invention, Figure 3 A schematic diagram of a text line extracted from a bill shown;

[0024] Figure 6 According to an extraction method according to an embodiment of the present invention, Figure 4 A schematic diagram of a text line extracted from a bill shown;

[0025] Figure 7 According to an embodiment of the present invention, the extraction method is Figure 3 A schematic diagram of a keyword subgraph constructed by the bill shown;

[0026] Figure 8 According to an embodiment of the present invention, the extraction method is Figure 4 A schematic diagram of a keyword subgraph constructed by the bill shown;

[0027] Fig. 9 It is a system block diagram of a method for extracting bill data according to an embodiment of the present invention;

[0028] Fig.10 4 is a system block diagram of a device for extracting bill data according to an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for the description of the embodiments. Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. Unless it is obvious from the language environment or otherwise explained, the same reference numerals in the figures represent the same structure or operation.

[0030] As shown in this application and claims, unless the context clearly indicates an exception, the words "a", "an", "an" and / or "the" do not refer to the singular and may also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.

[0031] Unless otherwise specifically stated, the relative arrangement, numerical expressions and numerical values ​​of the parts and steps set forth in these embodiments do not limit the scope of the present application. At the same time, it should be understood that, for ease of description, the sizes of the various parts shown in the accompanying drawings are not drawn according to the actual proportional relationship. The technology, method and equipment known to those of ordinary skill in the relevant field may not be discussed in detail, but in appropriate cases, the technology, method and equipment should be considered as a part of the authorization specification. In all examples shown and discussed here, any specific value should be interpreted as being merely exemplary, rather than as a limitation. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so that once a certain item is defined in an accompanying drawing, it does not need to be further discussed in subsequent drawings.

[0032] Flowcharts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, various steps may be processed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or more operations may be removed from these processes.

[0033] Figure 1 FIG. 1 is an exemplary flow chart of an extraction method according to an embodiment of the present invention. Figure 1 As shown, the method 10 for extracting bill data of this embodiment includes the following steps:

[0034] Step S11: construct a keyword graph, the keyword graph includes vertices and edges, the vertices include keywords and matching rules, the keywords correspond to the matching rules one by one, the edges are used to connect two vertices, the edges include the operation relationship between the two connected vertices, and the keywords are related to the target data to be extracted.

[0035] Step S12: Obtain target texts in the bill, each target text including corresponding texts and data.

[0036] Step S13: Compare the keywords in each vertex in the keyword graph with the text in each target text according to the matching rules, obtain the target vertex matching the target text, and construct the keyword subgraph of the bill according to the target vertex and the target edge corresponding to the target vertex.

[0037] Step S14: Select the longest path among all paths including the target vertex and the target edge from the keyword subgraph.

[0038] Step S15: Calculate the target data according to the operation relationship between the data corresponding to the keyword of the target vertex in the longest path and the target edge.

[0039] Combine the following Figure 2-Figure 9The above steps S11-S15 are described in detail:

[0040] In step S11, the constructed keyword graph is a data structure that uses a graph to represent keywords and the relationship between them and other keywords. A graph is a type of data structure that consists of vertices and edges to form a "network"-like structure. Both vertices and edges can store certain information as needed. Generally speaking, the vertices of a graph are used to represent data, and the edges are used to represent the relationship between data. A graph is usually represented as: G(V, E), where G represents a graph, V is the set of vertices in the graph G, and E is the set of edges in the graph G.

[0041] Figure 2 Schematic diagram of a keyword graph in an extraction method according to an embodiment of the present invention. Figure 2 As shown, the vertices of the keyword graph 20 include keywords and matching rules, and the keywords of each vertex correspond to the matching rules one by one. That is to say, for a vertex, keywords and matching rules are stored therein. An edge is used to connect two vertices, and the edge includes the operation relationship (operator) between the two connected vertices. Figure 2 In , circles are used to represent vertices, and arrows between circles represent edges. Figure 2 The keyword graph 20 shown includes 6 keyword vertices V1-V6. Taking two vertices V1 and V2 as examples, the keyword of vertex V1 is "total amount", and the matching rule corresponding to V1 is "(total amount)[::]*([0-9]+)". The keyword of vertex V2 is "rounded-off amount", and the corresponding matching rule is "(rounded-off amount)[::]*([0-9]+)". Edge E1 indicates that the operator relationship between vertex V1 and vertex V2 is "-", and the edge E1 between V1 and V2 has a direction, that is, from V1 to V2, which means that if the "total amount" and "rounded-off amount" are extracted from the receipt, then when calculating the final result, it is necessary to subtract the rounded-off amount from the total amount.

[0042] In the embodiment of the present invention, the keywords in the keyword map are related to the target data to be extracted. If the target data is to obtain the user's net operating income from the receipt, the keywords are all related to the net operating income. Figure 2 As shown, the keywords include: total amount, rounded amount, discount amount, actual receipts, cash, cash change, etc., which are all data names needed to calculate net operating income.

[0043] This specification will use the target data of net operating income as an example for illustration. These embodiments are not used to limit the specific content of the target data. Users of this method can set specific keywords related to the target data as needed and construct a corresponding keyword map.

[0044] In some embodiments, the keyword graph further includes a start vertex and an end vertex. Figure 2 As shown, the keyword graph 20 includes a starting vertex Vstart and an ending vertex Vend. The keyword graph 20 includes multiple different paths from the starting vertex Vstart to the ending vertex Vend, and these paths calculate the target data according to the vertices passed. For example, through the path of Vstart-V1-V2-V3-Vend, the formula can be obtained:

[0045] Vend = Vstart + total amount - rounded amount - discount amount.

[0046] Since Vstart does not include actual data, the relationship between Vstart and all the vertices connected to it is "+"; Vend represents the result of the target data that is actually desired to be obtained, so the formula can be simplified as follows:

[0047] Target data = total amount - rounded amount - discount amount.

[0048] The keyword graph including the start vertex and the end vertex helps to form a clear path, so that it is more convenient to calculate the target data according to the path.

[0049] In step S12, the bill refers to a receipt from a shopping mall or supermarket or an invoice issued by a company's finance department. The present invention does not limit the specific content of the bill and the method of obtaining the bill. In some embodiments, after the cash register completes the shopping checkout, an electronic bill is generated and delivered to the printer for generating a paper bill. The extraction method of the present application can directly obtain an electronic bill for printing a paper bill from the printer, and the target text extracted from the electronic bill can be stored in a database in the form of a string, or stored in a text file.

[0050] Figure 3 FIG. 3 is a schematic diagram of a bill obtained by an extraction method according to an embodiment of the present invention. The bill 30 may be a paper bill or an electronic bill. Figure 3 As shown, the content of the bill 30 includes multiple lines of text information such as order number, order time, product details, total amount, cash, actual receipt, cash change, transaction number, etc. The product details may include multiple text blocks such as product name, unit price, quantity, amount, etc.

[0051] Figure 4FIG. 1 is a schematic diagram of another bill obtained by the extraction method according to an embodiment of the present invention. Figure 4 As shown, the bill 40 includes multiple lines of text information such as order number, order time, product details, total amount, discount amount, rounding, actual amount received, transaction number, etc. The product details may include multiple text blocks such as product name, unit price, quantity, subtotal, etc.

[0052] Figure 3 and Figure 4 This is only an example of a bill, and the present invention does not limit the content, arrangement, etc. of the text of the bill data. A typical bill includes multiple text lines.

[0053] contrast Figure 3 and Figure 4 It can be seen that the key word "actually collected" is included in the bills. According to the traditional bill parsing system, if only the key word "actually collected" is extracted and used to calculate the net operating income of the merchant, it can be clearly seen that the calculated result is deviated from the actual situation. Figure 3 In the bill 30 shown, the net operating income should be equal to the actual amount minus the cash change or the cash minus the cash change, that is, the total amount; Figure 4 In the bill 40 shown, the net operating income should be equal to the total amount minus the discount amount, minus the zeroed amount, that is, equal to the actual amount received. If limited keywords and fixed calculation logic are used to calculate the actual net operating income, some bills will obtain incorrect results.

[0054] In step S12, obtaining the target text in the bill means obtaining the target text of interest from the entire content of the bill, and each target text includes corresponding text and data. Figure 3 If the target text obtained is the total amount, it includes the text "total amount" and the data "55.30".

[0055] In some embodiments, the data is monetary data.

[0056] In some embodiments, the step of obtaining the target text in the bill in step S12 includes the following steps S121-S123:

[0057] Step S121: Setting the starting position and the ending position.

[0058] Step S122: extract all text lines between the start position and the end position in the bill.

[0059] Step S123: extract the target text from all text lines.

[0060] In step S121, the step of setting the starting position and the ending position includes: searching the text lines in the bill line by line, and comparing the characters in the text lines with the keywords, taking the text line number where the characters matching the keywords appear for the first time as the starting position, and taking the text line number where the characters matching the keywords appear for the last time as the ending position. The keywords here refer to all the keywords in the keyword graph constructed in step S11. In step S121, the characters in the text lines are compared with all the keywords, and when there is a character that matches one of all the keywords, the line number where the character is located is taken as the starting position.

[0061] by Figure 2 The keywords in the embodiment shown in FIG. 20 and Figure 3 Taking the bill 30 shown as an example, the text lines in the bill 30 are searched line by line. When the text matching the keyword "total amount" in the keyword map 20 appears for the first time in line R1, the text line numbered R1 is used as the starting position; after the text matching the keyword "cash change" in the keyword map 20 appears in line R2, there is no more text matching any keyword in the keyword map 20 in the text below, and line R2 is used as the ending position.

[0062] Figure 5 According to an extraction method according to an embodiment of the present invention, Figure 3 Schematic diagram of text lines extracted from the bill shown in FIG. Figure 5 As shown, in step S122, all text lines between the starting position R1 and the ending position R2 are extracted, and other redundant information in the bill 30 that is not related to the calculation target data is removed.

[0063] The above embodiment searches text lines in the bill 30 from top to bottom line by line. The present invention does not limit the specific search order, and the search can also be from bottom to top.

[0064] refer to Figure 5 As shown, after step S122, the extracted text line also includes redundant information, such as text 51, whose content is "payment method", which is not a keyword in keyword diagram 20, nor does it have corresponding data, but is only text. However, "cash" and its corresponding data "100.0" in this line are the required target text, so after step S122, the extracted text line includes the line where the text 51 is located.

[0065] Step S123 can screen all the text lines extracted in step S122 again to extract the target text with words and their corresponding data. Figure 5For example, the target text obtained may be text data pairs such as [total amount 55.30], [cash 100.00], [actual amount received 100.00], and [cash change 44.70], excluding "payment method".

[0066] Figure 6 According to an extraction method according to an embodiment of the present invention, Figure 4 Schematic diagram of text lines extracted from the bill shown in FIG. Figure 4 The target text extracted from the bill 40 shown may be [Total Amount 53.52], [Discount Amount 2.00], [Round off 0.02], and [Actual Received 51.50], excluding irrelevant information.

[0067] In step S13, the matching rules in the keyword graph are used to match the keywords in the vertices in the keyword graph with the text in the target text. When the keywords of the vertices in the keyword graph can be matched in the target text, this vertex is the target vertex, and the edge corresponding to the target vertex is the target edge. The keyword subgraph consists of the target vertex and the target edge.

[0068] by Figure 2 The keywords shown in Figure 20 and Figure 5 Take the target text shown as an example, refer to Figure 2 As shown, after the comparison in step S13, the target vertices matching the target text include V1, V4, V5 and V6. Figure 5 The target text shown is from Figure 3 As obtained in the note 30 shown, these vertices and their corresponding edges constitute the keyword subgraph of the note 30.

[0069] In some embodiments, the step of constructing a keyword subgraph of the bill according to the target vertices matching the target text and the target edges corresponding to the target vertices includes: in the keyword graph, adding a match failure mark to the vertices that do not match the words in the target text. Figure 3 The Note 30 shown in Figure 2 In the keyword graph 20 shown, the keyword graph after adding matching failure marks to vertices V2 and V3 is the keyword subgraph of the bill 30.

[0070] In some embodiments, the step of constructing a keyword subgraph of the bill according to the target vertices matching the target text and the target edges corresponding to the target vertices includes: in the keyword graph, deleting the vertices and edges associated with the vertices that do not match the text in the target text. Figure 3 The Note 30 shown in Figure 2 In the keyword graph 20 shown in FIG. 20, by deleting vertices V2 and V3 and their related edges, we obtain Figure 7 Keyword sub-graph 70 is shown.

[0071] Figure 7 According to an extraction method according to one embodiment of the present invention, Figure 3 The schematic diagram of the keyword subgraph constructed by the bill shown in FIG. Figure 7 As shown, the target vertices of the keyword subgraph 70 include the starting vertex Vstart, the total amount V1, the actual amount received V4, the cash V5, the cash change V6 and the ending vertex Vend in the keyword graph 20.

[0072] Figure 8 According to an extraction method according to one embodiment of the present invention, Figure 4 The schematic diagram of the keyword subgraph constructed by the bill shown in FIG. Figure 8 As shown, the target vertices of the keyword subgraph 80 include the starting vertex Vstart, the total amount V1, the zeroed amount V2, the preferential amount V3, the actual amount V4 and the ending vertex Vend in the keyword graph 20. Figure 2 For the keyword graph 20 shown in FIG. 20 , vertices V5 cash and V6 cash change and their associated edges are deleted from the keyword graph. The reconstructed keyword subgraph only contains Figure 4 Information related to the ticket shown.

[0073] In step S14, a path refers to a sequence of edges that start from a certain vertex and reach another vertex. The step of selecting the longest path from all paths including the target vertex and the target edge in the keyword subgraph includes traversing all paths from the start vertex to the end vertex in the keyword subgraph using a depth-first traversal method, and determining the deepest path as the longest path. In step S15: according to the operation relationship stored in the edge of the longest path obtained in step S14, a calculation expression is obtained, and the amount data corresponding to the keyword of the target vertex is substituted into the calculation expression to obtain the final target data.

[0074] refer to Figure 7 ,by Figure 7 Take the keyword subgraph 70 shown as an example, where there are 4 paths from the starting vertex Vstart to the ending vertex Vend, corresponding to different calculation expressions, which are:

[0075] Path 1: Vstart-V1-Vend; Expression 1: Target data = total amount;

[0076] Path 2: Vstart-V4-Vend; Expression 2: Target data = actual receipt;

[0077] Path 3: Vstart-V4-V6-Vend; Expression 3: Target data = actual receipt - cash change;

[0078] Path 4: Vstart-V5-V6-Vend; Expression 4: Target data = cash-cash change;

[0079] Among them, the lengths of path 3 and path 4 are equal and the longest. For note 30, the target data calculated according to the two paths are equal, both 55.30, which is equal to the result obtained according to path 1. If path 2 is selected, the result is not the actual net operating income.

[0080] refer to Figure 8 ,by Figure 8 Take the keyword subgraph 80 shown as an example, where there are 5 paths from the starting vertex Vstart to the ending vertex Vend, corresponding to different calculation expressions, which are:

[0081] Path 1: Vstart-V1-V2-V3-Vend; Expression 1: Target data = total amount - zeroed amount - discount amount;

[0082] Path 2: Vstart-V1-V2-Vend; Expression 2: Target data = total amount - zero-rounded amount;

[0083] Path 3: Vstart-V1-V3-Vend; Expression 3: Target data = total amount - discount amount;

[0084] Path 4: Vstart-V1-Vend; Expression 4: Target data = total amount;

[0085] Path 5: Vstart-V4-Vend; Expression 5: Target data = actual receipt;

[0086] Among them, path 1 is the longest. For bill 40, the target data calculated according to this path is 51.50, which is equal to the result calculated according to path 4. If calculated according to paths 2, 3, and 4, the result is not the actual net operating income. It can be seen that the calculation formula of the longest path can cover various information in bill 40, so that the required target data can be calculated more accurately and the probability of error can be reduced.

[0087] The method for extracting bill data in this embodiment constructs a keyword graph related to the target data, and constructs a keyword subgraph based on the target text of the bill. The longest path is selected from all paths in the keyword subgraph to calculate the target data, thereby improving the accuracy of bill data extraction.

[0088] In some embodiments, Figure 1In step S13 shown in , after the step of comparing the keyword in each vertex in the keyword graph with the text in each target text according to the matching rules, it also includes: if the target text cannot match the keyword in any vertex in the keyword graph, the target text is used as a new keyword, and a new vertex is added to the keyword graph. The new vertex includes the new keyword and the corresponding new matching rule, and one or more new edges are constructed according to the operation relationship between the new vertex and other vertices.

[0089] According to these embodiments, when the target text obtained from the bill cannot match the keyword in any vertex in the keyword graph, it is necessary to manually analyze whether the target text that cannot be matched is related to the target data. If it is not relevant, the target text is discarded because it will not affect the target data. If it is relevant, the target text is used as a new keyword, and its corresponding matching rules are constructed according to the new keywords. Then, a new vertex is constructed with the new keywords and the corresponding new matching rules, and the new vertex is added to the keyword graph. At the same time, it is necessary to determine the operational relationship between the new vertex and other vertices in the keyword graph, construct edges, and finally obtain an updated keyword graph. The update of the keyword graph can be carried out in real time or at a fixed time, and this application does not limit this.

[0090] refer to Figure 2 As shown, taking the keyword graph 20 as an example, whenever it is found that the analyzed bill includes a new keyword, the new keyword is added to the keyword graph 20 according to the relationship between the new keyword and other keywords to form an updated keyword graph, and the keyword graph will gradually be expanded with more and more vertices and edges, so that the keyword graph can be applied to bills of various categories, improving the usability of the keyword graph. As the vertices are increased, the number or length of the paths is increased accordingly, and the longest path is selected from them for calculating the target data, which can more effectively exclude error-prone paths and obtain more stable and accurate calculation results.

[0091] In some embodiments of the present application, preferably, the constructed keyword graph can be deployed in the cloud. Fig. 9 1 is a system block diagram of a method for extracting bill data according to an embodiment of the present invention. Fig. 9As shown, the system includes a cash register 91, a receipt printer 92, a cloud 93 and a demand user terminal 94. The cash register 91 sends the order information to the receipt printer 92. The receipt printer 92 can be used to print receipts related to the order information on the one hand, and can also send the receipts to the cloud 93 through the network on the other hand, and call the keyword graph constructed in the cloud 93. According to the method for extracting receipt data of the present invention, the required target data is obtained from the receipt, and the target data is fed back to the demand user terminal 94. The demand user terminal 94 can be any object such as a merchant or a shopping mall that needs to obtain the target data in the receipt. The embodiment of the present application can realize fast and real-time receipt data extraction by deploying the keyword graph on the cloud.

[0092] The present application also provides a device for extracting bill data, comprising: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement the above-mentioned method for extracting bill data.

[0093] Fig.10 1 is a system block diagram of a device for extracting receipt data according to an embodiment of the present invention. The device for extracting receipt data 100 may include an internal communication bus 1001, a processor 1002, a read-only memory (ROM) 1003, a random access memory (RAM) 1004, and a communication port 1005. When applied on a personal computer, the text recognition device 100 for shopping receipts may also include a hard disk 1006. The internal communication bus 1001 can realize data communication between components of the text recognition device 100 for shopping receipts. The processor 1002 can make judgments and issue prompts. In some embodiments, the processor 1002 can be composed of one or more processors. The communication port 1005 can realize data communication between the text recognition device 100 for shopping receipts and the outside. In some embodiments, the text recognition device 100 for shopping receipts can send and receive information and data from the network through the communication port 1005. The text recognition device 100 for shopping receipts may also include different forms of program storage units and data storage units, such as a hard disk 1006, a read-only memory (ROM) 1003 and a random access memory (RAM) 1004, which can store various data files used for computer processing and / or communication, and possible program instructions executed by the processor 1002. The processor executes these instructions to implement the main part of the method. The results of the processor processing are transmitted to the user device through the communication port and displayed on the user interface.

[0094] The above-mentioned method for extracting bill data can be implemented as a computer program, stored in the hard disk 1006, and recorded in the processor 1002 for execution to implement any of the methods for extracting bill data in the present application.

[0095] The present application also provides a computer-readable medium storing a computer program code, and when the computer program code is executed by a processor, the computer program code implements any of the above-mentioned methods for extracting bill data.

[0096] When the method for extracting ticket data is implemented as a computer program, it can also be stored in a computer-readable storage medium as a product. For example, a computer-readable storage medium may include, but is not limited to, magnetic storage devices (e.g., hard disks, floppy disks, magnetic strips), optical disks (e.g., compact disks (CDs), digital versatile disks (DVDs)), smart cards, and flash memory devices (e.g., electrically erasable programmable read-only memories (EPROMs), cards, sticks, key drives). In addition, the various storage media described herein can represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media (and / or storage media) that can store, contain and / or carry code and / or instructions and / or data.

[0097] It should be understood that the embodiments described above are only illustrative. The embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or any combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, and / or other electronic units designed to perform the functions described herein, or combinations thereof.

[0098] The basic concepts have been described above. Obviously, for those skilled in the art, the above application disclosure is only an example and does not constitute a limitation of the present application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements and amendments to the present application. Such modifications, improvements and amendments are suggested in the present application, so such modifications, improvements and amendments still belong to the spirit and scope of the exemplary embodiments of the present application.

[0099] At the same time, the present application uses specific words to describe the embodiments of the present application. For example, "one embodiment", "an embodiment", and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of the present application. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more in different positions in this specification does not necessarily refer to the same embodiment. In addition, some features, structures or characteristics in one or more embodiments of the present application can be appropriately combined.

[0100] Some aspects of the present application may be performed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The above hardware or software may be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". The processor may be one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DAPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or combinations thereof. In addition, various aspects of the present application may be expressed as computer products located in one or more computer-readable media, which include computer-readable program codes. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disks, floppy disks, tapes ...), optical disks (e.g., compact disks CDs, digital versatile disks DVDs ...), smart cards, and flash memory devices (e.g., cards, sticks, key drives ...).

[0101] Similarly, it should be noted that in order to simplify the description of the disclosure of this application and thus help understand one or more application embodiments, in the above description of the embodiments of this application, multiple features are sometimes merged into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the object of this application are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.

[0102] Although the present application has been described with reference to the current specific embodiments, ordinary technicians in this technical field should recognize that the above embodiments are only used to illustrate the present application, and various equivalent changes or substitutions may be made without departing from the spirit of the present application. Therefore, as long as the changes and modifications to the above embodiments are within the essential spirit of the present application, they will fall within the scope of the claims of the present application.

Claims

1. A method for extracting bill data, characterized in that: include: Constructing a keyword graph, the keyword graph comprising vertices and edges, the vertices comprising keywords and matching rules, the keywords corresponding to the matching rules one by one, the edges being used to connect two of the vertices, the edges comprising an operation relationship between the two connected vertices, and the keywords being related to the target data to be extracted; Obtaining target texts in the bill, each of the target texts comprising mutually corresponding words and data; Compare the keywords in each vertex in the keyword graph with the words in each target text according to the matching rule, obtain the target vertex matching the target text, and construct the keyword subgraph of the bill according to the target vertex and the target edge corresponding to the target vertex; Selecting the longest path among all paths including the target vertex and the target edge from the keyword subgraph; as well as The target data is calculated according to the operation relationship between the data corresponding to the keyword of the target vertex in the longest path and the target edge.

2. The extraction method according to claim 1, characterized in that The steps of obtaining the target text in the ticket include: Set the starting and ending positions; Extracting all text lines between the start position and the end position in the bill; and The target text is extracted from all the text lines.

3. The extraction method according to claim 2, characterized in that The steps to set the start and end positions include: The text lines in the bill are searched line by line, and the characters in the text lines are compared with the keyword, and the text line number where the characters matching the keyword appear for the first time is used as the starting position, and the text line number where the characters matching the keyword appear for the last time is used as the ending position.

4. The extraction method according to claim 1, characterized in that After the step of comparing the keywords in each vertex in the keyword graph and the characters in each target text according to the matching rules, the step also includes: if the target text cannot match the keywords in any vertex in the keyword graph, the target text is used as a new keyword, and a new vertex is added to the keyword graph, the new vertex includes the new keyword and the corresponding new matching rule, and one or more new edges are constructed according to the operational relationship between the new vertex and other vertices.

5. The extraction method according to claim 1, characterized in that The step of constructing the keyword subgraph of the bill according to the target vertex matching the target text and the target edge corresponding to the target vertex includes: in the keyword graph, adding a match failure mark to the vertex that does not match the text in the target text.

6. The extraction method according to claim 1, characterized in that The step of constructing the keyword subgraph of the bill according to the target vertex matching the target text and the target edge corresponding to the target vertex includes: in the keyword graph, deleting the vertex that does not match the text in the target text and the edge related to the vertex.

7. The extraction method according to claim 1, characterized in that The step of selecting the longest path among all paths including the target vertex and the target edge from the keyword subgraph includes: traversing all paths in the keyword subgraph using a depth-first traversal method, and determining the deepest path as the longest path.

8. The extraction method according to claim 1, characterized in that The keyword graph further includes a start vertex and an end vertex, wherein the start vertex serves as a start point of all the paths, and the end vertex serves as an end point of all the paths.

9. The extraction method according to claim 1, characterized in that The data is monetary amount data.

10. A device for extracting bill data, comprising: a memory for storing instructions executable by a processor; A processor, configured to execute the instructions to implement the method according to any one of claims 1 to 9.

11. A computer readable medium storing computer program code, wherein the computer program code, when executed by a processor, implements the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Bill information processing method, system and computer-readable storage medium

    CN109308476A

  • Shopping receipt information analysis method and system based on keyword knowledge base

    CN113361514A