Numerical calculation method and device for financial statement
By correcting the pictures of financial statements and checking the tables, combining the matching method of open source models and database formula sets, the accuracy of the numerical calculation of financial statements in the existing technology is solved, achieving higher accuracy and reliability.
Patent Information
- Application Number
- CN202411614542.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-28
AI Technical Summary
When calculating the values of financial statements, the accuracy rate is low and the financial statements in different formats cannot be effectively processed, resulting in inaccurate account matching and affecting the accuracy of the calculation results.
By obtaining financial statements and correcting each of its pictures, detecting and intercepting table areas, text recognition and subject matching are performed. Use the open source model to match the formula set in the database, use the cosine distance and edit distance to determine the final matching subject, and replace the numerical value of the subject to be matched, and finally calculate the numerical value of the financial statement.
It improves the accuracy of numerical calculation of financial statements, can effectively process financial statements in different formats, enhances the accuracy of account matching, and thus improves the reliability of calculation results.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method and device for numerical calculation of financial statements. Background Art
[0002] In the bank's corporate credit business, business personnel need to analyze the company's operating conditions based on financial statements (PDF format). The financial statements include the income statement, balance sheet, and cash flow statement provided by the company. The financial statements reflect the indicators and values of the company's operating conditions. Therefore, it is necessary to calculate the values in the financial statements to decide whether to lend to the company.
[0003] In the existing technology, the file information of the financial table is first divided into a text area and a table area using a layout analysis model, and text recognition is performed on the text area to obtain the text content of the text area. Secondly, the table analysis model is used to obtain the table structure information of the table area, and text recognition is used to obtain the target text content of the table area. The subjects in the formula contained in the text content and the target text content are then extracted, and the subjects in the formula are then matched with the subjects in the database table to obtain the values in the database table. The subjects in the formula are then replaced with the matched values, and finally the traditional Reverse Polish algorithm or abstract syntax tree algorithm is used to calculate the final formula value.
[0004] However, the layout analysis model has the problem of low accuracy and cannot cover financial statements of various formats. In addition, when matching accounts, it adopts an exact matching method, which may cause some accounts with the same meaning but different expressions to fail to match successfully, resulting in inaccurate values in the calculated financial statements. Summary of the invention
[0005] Based on the above-mentioned deficiencies of the prior art, the present application provides a method and device for calculating numerical values of financial statements to solve the problem of inaccurate numerical values of calculated financial statements brought about by the prior art.
[0006] In order to achieve the above objectives, this application provides the following technical solutions:
[0007] The first aspect of the present application provides a numerical calculation method for financial statements, comprising:
[0008] Obtaining a financial statement, and performing correction processing on each image in the financial statement to obtain a plurality of target images;
[0009] For each of the target images, detecting whether there is a table in the target image;
[0010] If there is a table in the target image, the coordinates of each point of the table in the target image are obtained, and based on the coordinates of each point, the name area of the table is intercepted to obtain a sub-image of the table;
[0011] Perform text recognition on the sub-image of the table to obtain the name of the table, and determine whether the name of the table is any of the three major financial tables;
[0012] If the name of the table is any of the three major financial tables, the target image is input into the open source model to obtain the table data corresponding to the target image, and the formula set is obtained from the database;
[0013] Based on each subject to be matched in the formula set, determine whether there are multiple final matching subjects among all subjects included in the table data; wherein the final matching subject refers to a subject that meets a preset requirement; the preset requirement refers to a subject whose cosine distance with the subject to be matched is the smallest and the cosine distance is less than a preset threshold;
[0014] If there is a final matching subject among all the subjects included in the table data, then for each final matching subject, the value of the subject to be matched corresponding to the final matching subject is replaced with the value corresponding to the final matching subject, so as to obtain the target value of the subject to be matched corresponding to the final matching subject;
[0015] Based on the target value of each of the subjects to be matched, the formula set is calculated to obtain the calculation result corresponding to the financial statement.
[0016] Optionally, in the above-mentioned numerical calculation method of the financial statement, the correction processing is performed on each image in the financial statement to obtain multiple target images, including:
[0017] Performing Hough line detection on each image in the financial statement to obtain a left straight line and a right straight line corresponding to each image;
[0018] Calculate the inclination angle between the left straight line and the right straight line corresponding to each of the images;
[0019] According to the tilt angle of each of the images, a rotation algorithm is used to correct each of the images to obtain multiple target images.
[0020] Optionally, in the above-mentioned numerical calculation method for financial statements, the step of intercepting the name area of the table based on the coordinates of each point to obtain a sub-graph of the table includes:
[0021] Obtain the left vertex coordinates and the right vertex coordinates of the target image;
[0022] Extract the target left vertex coordinates and the target right vertex coordinates of the table from the coordinates of each point;
[0023] Based on the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates, and the target right vertex coordinates, the name area of the table is intercepted to obtain a subgraph of the table.
[0024] Optionally, in the above-mentioned numerical calculation method of financial statements, the open source model includes a table structure prediction module, a text module, an aggregation module and an export module, and the target image is input into the open source model to obtain the table data corresponding to the target image, including:
[0025] Acquire the four-point coordinates and table structure information of each cell in the target image through the table structure prediction module;
[0026] Identify the four-point coordinates and text information of each line of text box in the target image through the text module;
[0027] For each row of text boxes in the target image, the aggregation module is used to determine whether the four-point coordinates of all cells contain the four-point coordinates of the text box;
[0028] If there are target four-point coordinates including the four-point coordinates of the text box among the four-point coordinates of all cells, the cell corresponding to the target four-point coordinates and the text information of the text box are spliced by the aggregation module to obtain the target cell;
[0029] The export module is used to convert the table structure information of all the target cells into a form to obtain the table data corresponding to the target image.
[0030] Optionally, in the above-mentioned numerical calculation method of financial statements, after inputting the target image into the open source model to obtain the table data corresponding to the target image, the method further includes:
[0031] Deleting the interference symbol at the beginning of each subject included in the table data;
[0032] Deleting the punctuation marks at the end of each subject included in the table data;
[0033] Delete the numbers in each subject included in the table data.
[0034] Optionally, in the above-mentioned numerical calculation method of financial statements, judging whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set includes:
[0035] For each subject to be matched in the formula set, respectively, calculating the edit distance between the subject to be matched and each subject in the table data;
[0036] Filtering all target subjects that meet preset requirements from all the subjects, and adding all the target subjects to the candidate set; wherein the target subject refers to a subject whose edit distance is less than half of the character length of the subject to be matched;
[0037] Calculating the cosine distance between the subject to be matched and each target subject in the candidate set;
[0038] Obtaining a minimum cosine distance from all the cosine distances, and determining whether the minimum cosine distance is less than a preset threshold;
[0039] If the minimum cosine distance is less than a preset threshold, the target subject corresponding to the minimum cosine distance is determined as the final matching subject, and it is determined that there is a final matching subject among all the subjects included in the table data.
[0040] Optionally, in the above-mentioned numerical calculation method of financial statements, after judging whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set, the method further includes:
[0041] If there are no multiple final matching subjects among all subjects included in the table data, identifying a special subject formula dictionary from the table data;
[0042] Determine whether the subject to be matched exists in the special subject formula dictionary;
[0043] If the subject to be matched exists in the special subject formula dictionary, the subject to be matched is decomposed into a formula to obtain a sub-formula corresponding to the subject to be matched, and the subject to be matched is replaced with the sub-formula;
[0044] Adding the sub-formula to the formula set;
[0045] If the subject to be matched does not exist in the special subject formula dictionary, the subject to be matched is replaced with a preset threshold value.
[0046] Optionally, in the above-mentioned method for calculating the numerical value of the financial statement, the formula set is calculated based on the target numerical value of each of the to-be-matched subjects to obtain the calculation result corresponding to the financial statement, including:
[0047] Using regular expressions to search for special symbols in the formula set;
[0048] Replacing special symbols in the formula set to obtain a target formula set;
[0049] According to the target value of each of the to-be-matched subjects, the target formula set is calculated using the reverse Polish notation to obtain the calculation result corresponding to the financial statement.
[0050] A second aspect of the present application provides a numerical calculation device for financial statements, comprising:
[0051] A correction unit, used for obtaining a financial statement and performing correction processing on each image in the financial statement to obtain a plurality of target images;
[0052] A table detection unit, used for detecting, for each of the target images, whether there is a table in the target image;
[0053] A cutting unit, configured to obtain the coordinates of each point of the table in the target image if there is a table in the target image, and to cut the name area of the table based on the coordinates of each point to obtain a sub-image of the table;
[0054] A text recognition unit, used to perform text recognition on the sub-image of the table, obtain the name of the table, and determine whether the name of the table is any of the three major financial tables;
[0055] A processing unit, configured to input the target image into the open source model if the name of the table is any one of the three major financial tables, obtain the table data corresponding to the target image, and obtain a formula set from the database;
[0056] A judgment unit, configured to judge whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set; wherein the final matching subject refers to a subject that meets a preset requirement; the preset requirement refers to a subject whose cosine distance with the subject to be matched is the smallest and the cosine distance is less than a preset threshold;
[0057] A value replacement unit, for replacing the value of the subject to be matched corresponding to the final matching subject with the value corresponding to the final matching subject for each final matching subject, if there is a final matching subject among all the subjects included in the table data, so as to obtain a target value of the subject to be matched corresponding to the final matching subject;
[0058] A calculation unit is used to calculate the formula set based on the target value of each of the subjects to be matched, so as to obtain the calculation result corresponding to the financial statement.
[0059] Optionally, in the above-mentioned numerical calculation device for financial statements, the correction unit includes:
[0060] A straight line detection unit, used for performing Hough straight line detection on each image in the financial statement to obtain a left straight line and a right straight line corresponding to each image;
[0061] An angle calculation unit, used to calculate the inclination angle between the left straight line and the right straight line corresponding to each of the pictures;
[0062] The correction subunit is used to correct each of the pictures using a rotation algorithm according to the tilt angle of each of the pictures to obtain multiple target pictures.
[0063] Optionally, in the above-mentioned numerical calculation device for financial statements, the interception unit includes:
[0064] A coordinate acquisition unit, used to acquire the left vertex coordinates and the right vertex coordinates of the target image;
[0065] A coordinate extraction unit, used to extract the target left vertex coordinates and the target right vertex coordinates of the table from the coordinates of each point;
[0066] The interception subunit is used to intercept the name area of the table based on the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates and the target right vertex coordinates to obtain a subgraph of the table.
[0067] Optionally, in the above-mentioned numerical calculation device for financial statements, the open source model includes a table structure prediction module, a text module, an aggregation module and an export module, and the processing unit includes:
[0068] An acquisition unit, used for acquiring four-point coordinates and table structure information of each cell in the target image through the table structure prediction module;
[0069] A recognition unit, used to recognize the four-point coordinates and text information of each line of text box in the target image through the text module;
[0070] A coordinate judgment unit, for each row of text boxes in the target image, judging through the aggregation module whether there are target four-point coordinates including the four-point coordinates of the text box in the four-point coordinates of all cells;
[0071] A splicing unit, configured to, if there are target four-point coordinates including the four-point coordinates of the text box among the four-point coordinates of all cells, splice the cells corresponding to the target four-point coordinates and the text information of the text box through the aggregation module to obtain the target cell;
[0072] The conversion unit is used to convert the table structure information of all the target cells into a form through the export module to obtain the table data corresponding to the target image.
[0073] Optionally, in the above-mentioned numerical calculation device for financial statements, it further includes:
[0074] A first deleting unit, used for deleting the interference symbol at the beginning position of each subject included in the table data;
[0075] A second deleting unit, used for deleting the punctuation marks at the end of each subject included in the table data;
[0076] The third deleting unit is used to delete the numbers in each subject included in the table data.
[0077] Optionally, in the above-mentioned numerical calculation device for financial statements, the judgment unit includes:
[0078] An edit distance calculation unit, used for respectively calculating the edit distance between each subject to be matched in the formula set and each subject in the table data;
[0079] A screening unit, used to screen out all target subjects that meet preset requirements from all the subjects, and add all the target subjects to a candidate set; wherein the target subject refers to a subject whose edit distance is less than half of the character length of the subject to be matched;
[0080] A cosine distance calculation unit, used for calculating the cosine distance between the subject to be matched and each target subject in the candidate set;
[0081] A judging subunit, configured to obtain a minimum cosine distance from all the cosine distances, and judge whether the minimum cosine distance is less than a preset threshold;
[0082] The first determination unit is configured to determine the target subject corresponding to the minimum cosine distance as the final matching subject if the minimum cosine distance is less than a preset threshold, and to determine whether there is a final matching subject among all the subjects included in the table data.
[0083] Optionally, in the above-mentioned numerical calculation device for financial statements, it further includes:
[0084] an identification unit, configured to identify a special subject formula dictionary from the table data if there are no multiple final matching subjects among all subjects included in the table data;
[0085] A subject judgment unit, used for judging whether the subject to be matched exists in the special subject formula dictionary;
[0086] A formula decomposition unit, configured to, if the subject to be matched exists in the formula dictionary of the special subject, decompose the formula of the subject to be matched to obtain a sub-formula corresponding to the subject to be matched, and replace the subject to be matched with the sub-formula;
[0087] An adding unit, used for adding the sub-formula to the formula set;
[0088] The first replacement unit is used to replace the subject to be matched with a preset threshold value if the subject to be matched does not exist in the special subject formula dictionary.
[0089] Optionally, in the above-mentioned numerical calculation device for financial statements, the calculation unit includes:
[0090] A search unit, used for searching for special symbols in the formula set using regular expressions;
[0091] A second replacement unit, used for replacing special symbols in the formula set to obtain a target formula set;
[0092] The calculation subunit is used to calculate the target formula set using the reverse Polish notation according to the target value of each of the to-be-matched subjects, so as to obtain the calculation result corresponding to the financial statement.
[0093] The application provides a numerical calculation method for financial statements, which obtains financial statements and corrects each image in the financial statements to obtain multiple target images. Secondly, for each target image, it is detected whether there is a table in the target image. If there is a table in the target image, the coordinates of each point of the table in the target image are obtained, and based on the coordinates of each point, the name area of the table is intercepted to obtain a sub-image of the table. Then, the sub-image of the table is text-recognized to obtain the name of the table, and it is determined whether the name of the table is any of the three major financial tables. If the name of the table is any of the three major financial tables, the target image is input into an open source model to obtain the table data corresponding to the target image, and a formula set is obtained from a database. Then, based on each subject to be matched in the formula set, it is determined whether there are multiple final matching subjects in all subjects included in the table data. If there are multiple final matching subjects in all subjects included in the table data, the value of the subject to be matched corresponding to the final matching subject is replaced with the value corresponding to the final matching subject for each final matching subject, and the target value of the subject to be matched corresponding to the final matching subject is obtained. Finally, based on the target value of each subject to be matched, the formula set is calculated to obtain the calculation result corresponding to the financial statement. Therefore, based on the matching relationship between each subject to be matched in the formula set and all subjects contained in the table data, not only the matching problem of subjects with the same semantics can be solved, but also the matching problem of subjects with missing text or character recognition errors and formula subjects can be solved to the greatest extent, thereby effectively solving the problem of inaccurate numerical values in the calculated financial statements. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0095] Figure 1 A schematic diagram of the structure of a financial statement intelligent numerical calculation system provided in an embodiment of the present application;
[0096] Figure 2 A flowchart of a numerical calculation method for financial statements provided in an embodiment of the present application;
[0097] Figure 3 A schematic diagram of a flow chart of a method for correcting an image provided by another embodiment of the present application;
[0098] Figure 4 A schematic diagram of a flow chart of a method for capturing a table image provided in another embodiment of the present application;
[0099] Figure 5 A flowchart of a method for pre-processing subjects provided in an embodiment of the present application;
[0100] Figure 6 A flowchart of a method for obtaining table data provided in another embodiment of the present application;
[0101] Figure 7 A flowchart of a method for determining a final matching subject provided by another embodiment of the present application;
[0102] Figure 8 A flowchart of a method for processing a special subject provided in an embodiment of the present application;
[0103] Fig. 9 A schematic diagram of a flow chart of a calculation method of a formula set provided in another embodiment of the present application;
[0104] Fig.10 A schematic diagram of the structure of a numerical calculation device for financial statements provided in another embodiment of the present application. DETAILED DESCRIPTION
[0105] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. 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 creative work are within the scope of protection of this application.
[0106] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0107] The embodiment of the present application provides a numerical calculation method for financial statements, which is applied to an intelligent numerical calculation system for financial statements to solve the problem of inaccurate numerical values in calculating financial statements caused by the prior art.
[0108] Alternatively, if Figure 1As shown, an embodiment of the present application provides a financial statement intelligent numerical calculation system, including: a financial statement automatic search module, an OCR table recognition module and a formula parsing calculation module.
[0109] It should be noted that the financial statement automatic search module includes an image rotation module, a table detection module, and a file detection and recognition module.
[0110] The formula parsing and calculation module includes the subject matching module and the mathematical expression calculation module.
[0111] Specifically, the image rotation module is used to perform rotation correction on tilted and flipped images.
[0112] The table detection module is used to detect the table in the image and determine whether there is a table on the PDF page of the financial report.
[0113] The file detection and recognition module is used to recognize the name of the table.
[0114] The OCR table recognition module is mainly used to convert table images in financial statements into Excel format data using the open source model PPstructure.
[0115] The subject matching module is used to match the subjects in the formula set with the subjects in the data in Excel format.
[0116] The mathematical expression calculation module is used to calculate the final result of a set of formulas.
[0117] Based on the above-mentioned intelligent numerical calculation system for financial statements, the embodiment of the present application provides a numerical calculation method for financial statements, such as Figure 2 As shown, the specific steps include:
[0118] S201, obtaining a financial statement, and performing correction processing on each image in the financial statement to obtain a plurality of target images.
[0119] It can be understood that after obtaining the company's financial statements, since the company's financial statements are usually in PDF format, the images in the company's financial statements often have skewed tables. If these skewed table images are not processed, the accuracy of table detection and recognition will be affected later. Therefore, it is necessary to correct each image in the financial statement to obtain a non-skewed image.
[0120] Optionally, in another embodiment of the present application, in step S201, each image in the financial statement is corrected to obtain another specific implementation of multiple target images, such as Figure 3 As shown, the following steps are included:
[0121] S301, perform Hough line detection on each image in the financial statement to obtain a left straight line and a right straight line corresponding to each image.
[0122] Specifically, since the pictures included in the financial statements usually contain many straight lines, it is possible to determine whether the table pictures are skewed by detecting the straight lines. Therefore, the Hough straight line detection method is adopted to perform straight line detection on each picture in the financial statements, so that the left straight line and the right straight line corresponding to each picture can be obtained.
[0123] S302: Calculate the inclination angle between the left straight line and the right straight line corresponding to each image.
[0124] It can be understood that to calculate the inclination angle between the left straight line and the right straight line corresponding to the picture, we can first obtain the endpoint coordinates of the left straight line and the endpoint coordinates of the right straight line, and then for the two straight lines, based on the endpoint coordinates of the left straight line and the endpoint coordinates of the right straight line, calculate the slope m of the two straight lines, and then based on the relationship between the slope and the angle: θ=arctan(m), we can calculate the inclination angle of the left straight line and the inclination angle of the right straight line, and finally calculate the angle difference between the inclination angle of the left straight line and the inclination angle of the right straight line, so that the inclination angle between the left straight line and the right straight line corresponding to the picture can be obtained.
[0125] S303, according to the tilt angle of each picture, use a rotation algorithm to correct each picture to obtain multiple target pictures.
[0126] It is understandable that when the tilt angle of the image is between 10° and 350°, it means that the image is in a tilted state, so a rotation algorithm can be used to rotate each image, so that the image can be corrected. The rotation algorithm can be opencv, of course, other image processing software can also be used, and the embodiment of the present application is not limited to this one.
[0127] S202: for each target image, detect whether there is a table in the target image.
[0128] Specifically, after obtaining the corrected target image, it is necessary to first use the open source model Table Transformer to perform table detection on the target image to find out whether there is a table in the target image. If so, then it is necessary to call the Table Transformer API to determine the number of tables in the target image. Because in financial statements, the three major financial tables are generally presented as a single table, so you can first simply identify the target image to find out whether there is a table in the target image. That is, detect whether there is a table in the target image. If there is a table in the target image, it means that the table may be a table in the three major financial tables. Therefore, step S203 is executed at this time.
[0129] Optionally, if there is no table in the target image, or there are 0 or more tables, the detection of the target image can be skipped and the detection of the next target image can be performed, thereby improving the detection efficiency.
[0130] S203 , obtaining the coordinates of each point of the table in the target image, and based on the coordinates of each point, intercepting the name area of the table to obtain a sub-image of the table.
[0131] It should be emphasized that when there is a table in the target image, it is necessary to further know whether the table is one of the three major financial tables. Therefore, it can be judged by the name of the table. Therefore, it is necessary to first capture the image with the table name, so that the text in the image can be recognized flexibly and effectively later.
[0132] The specific interception method can be processed by coordinates, that is, the target image can be input into the open source model Table Transformer. Through this open source model, the coordinates of each point of the table in the target image can be obtained. Then, since the area directly above the table is usually the name area of the table, the area directly above the table can be intercepted through the coordinates, and the name area of the table can be intercepted, thereby obtaining a sub-image of the table, that is, a sub-image containing the table name.
[0133] Optionally, in another embodiment of the present application, in step S203, based on the coordinates of each point, the name area of the table is intercepted to obtain another specific implementation of the sub-graph of the table, such as Figure 4 As shown, the following steps are included:
[0134] S401, obtaining the left vertex coordinates and the right vertex coordinates of the target image.
[0135] It can be understood that image capture must have a starting point, that is, the position where the capture starts, and an ending point, that is, the position where the capture ends. Therefore, the left vertex coordinates and the right vertex coordinates of the target image can be used as the starting point or the ending point.
[0136] Optionally, the open source model can feedback the coordinates of each point of the table in the target image, and can also feedback the left vertex coordinates and the right vertex coordinates of the target image.
[0137] S402: Extract the target left vertex coordinates and the target right vertex coordinates of the table from the coordinates of each point.
[0138] Specifically, considering that not all four points of the table are convenient for intercepting the name area of the table, in order to conveniently and effectively intercept the name area of the table, the target left vertex coordinates and the target right vertex coordinates of the table can be extracted from the coordinates of each point, and the target left vertex coordinates and the target right vertex coordinates can be used together as the starting point or end point of the intercepted image.
[0139] S403 , based on the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates, and the target right vertex coordinates, intercept the name area of the table to obtain a subgraph of the table.
[0140] Specifically, the image captured based on the four points of the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates, and the target right vertex coordinates is the sub-image of the table.
[0141] S204, performing text recognition on the sub-image of the table to obtain the name of the table, and determining whether the name of the table is any of the three major financial tables.
[0142] Specifically, after obtaining the sub-image of the table, in order to know whether the table is one of the three major financial tables, the open source model PaddleOCR can be used to perform text detection and recognition on the sub-image of the table, so that the name of the table can be obtained. Finally, based on the obtained table name, it can be determined whether the table is one of the three major financial tables, that is, whether the name of the table is any one of the three major financial tables. If the name of the table is any one of the three major financial tables, it means that the table is one of the three major financial tables, so step S205 is executed.
[0143] Optionally, if the name of the table is not any of the three major financial tables, the processing of the table is skipped and the name determination of the next table is continued.
[0144] S205: Input the target image into the open source model, obtain the table data corresponding to the target image, and obtain the formula set from the database.
[0145] It should be noted that when the name of the table is any of the three major financial tables, it is necessary to input the target image corresponding to the table into the open source model PPstructure, so that the target image can be converted into table data in Excel format through the open source model PPstructure to facilitate subsequent subject matching and calculation.
[0146] It should also be noted that after obtaining the table data in Excel format, it is necessary to obtain the formula set from the database, and then use regular expressions to obtain the subjects to be matched in the formula set, so that the subjects to be matched in the formula set can be flexibly and effectively matched with the overall subjects in the table data. The formula set is used to reflect the current performance of the company and other operating conditions, such as "Money Funds Asset Ratio = Monetary Funds / Total Assets", etc., where "Money Funds" and "Total Assets" are subjects in the three major financial tables.
[0147] In the embodiment of the present application, whether two subjects match is determined based on the consistency of the subjects, but there may be some interference items, which makes it inconvenient to accurately match these subjects later. Therefore, optionally, after executing step S205, each subject included in the table data can be uniformly processed in advance. Figure 5 As shown, the embodiment of the present application provides a method for pre-processing subjects, comprising the following steps:
[0148] S501, deleting the interference symbol at the beginning position of each subject included in the table data.
[0149] Specifically, before performing subject matching, each subject included in the table data needs to be preprocessed to reduce the difficulty of matching.
[0150] It is understandable that in financial statements, the beginning of an account usually contains some interference symbols, which increase the difficulty of account matching. Therefore, it is necessary to delete the interference symbols at the beginning of each account contained in the table data.
[0151] Interference symbols such as '☆', '★', '△', '*', etc.
[0152] S502: Delete the punctuation marks at the end of each subject included in the table data.
[0153] Specifically, since there are usually some punctuation marks at the end of a subject, which may affect the subsequent matching efficiency, the matching efficiency will be improved as much as possible, and the punctuation marks at the end of each subject contained in the table data need to be deleted.
[0154] Punctuation marks such as '.', ';', '!', etc.
[0155] S503, delete the numbers in each subject included in the table data.
[0156] In addition, subjects are often accompanied by numbers, but these numbers are of no use for subject matching and may interfere with the accuracy of matching. Therefore, in order to improve the accuracy of matching, it is also necessary to delete the numbers in each subject contained in the table data.
[0157] It should also be noted that in the application embodiment, the execution order of steps S501 to S503 is only one of the optional methods. Since in the application embodiment, steps S501 to S503 are completely independent of each other, the execution order of steps S501 to S503 can also adopt other execution orders, which can be set according to needs.
[0158] Optionally, in another embodiment of the present application, the open source model includes a table structure prediction module, a text module, an aggregation module, and an export module. Therefore, in step S205, the target image is input into the open source model to obtain another specific implementation of the table data corresponding to the target image, such as Figure 6 As shown, the following steps are included:
[0159] S601. Obtain the four-point coordinates and table structure information of each cell in the target image through a table structure prediction module.
[0160] It can be understood that before the table structure prediction module obtains the four-point coordinates and table structure information of each cell in the target image, the target image can be preprocessed to improve the recognition effect. Then, the internal principle of the table structure prediction module can identify the four-point coordinates and table structure information of each cell in the target image, thereby reducing manual intervention and improving efficiency.
[0161] The table structure information may include table style and table type, etc. The four-point coordinates refer to the upper left corner coordinate, the upper right corner coordinate, the lower left corner coordinate, and the lower right corner coordinate.
[0162] S602, identifying the four-point coordinates and text information of each line of text box in the target image through a text module.
[0163] Specifically, the text module can use an edge detection algorithm to find the edges of the text area in the target image, and then use a contour detection method to extract the contour of the text area in the target image, and then filter out non-text contours based on features such as area and shape, retain possible text areas, and then perform rectangular fitting on the detected contours to generate the coordinates of the four corner points of each text box, and finally use an optical character recognition (OCR) tool (such as Tesseract) to identify each text box area, extract the text content, and obtain the text information corresponding to each text box.
[0164] The text information may include specific content in the text box, such as numbers, English, etc. The four-point coordinates refer to the upper left corner coordinates, the upper right corner coordinates, the lower left corner coordinates, and the lower right corner coordinates.
[0165] S603 , for each row of text boxes in the target image, determine through an aggregation module whether the four-point coordinates of all cells contain the target four-point coordinates of the text box.
[0166] It is understandable that in order to accurately merge the text information of the cells and text boxes and lay the foundation for subsequent subject matching, it is necessary to use the aggregation module to determine in advance whether there are target four-point coordinates that include the four-point coordinates of the text box among the four-point coordinates of all cells. If there are target four-point coordinates that include the four-point coordinates of the text box among the four-point coordinates of all cells, execute step S604.
[0167] Optionally, if the target four-point coordinates including the four-point coordinates of the text box do not exist in the four-point coordinates of all cells, the target image can be directly converted into Excel format.
[0168] Specifically, the four-point coordinates of all cells can be traversed through the aggregation module and compared with the four-point coordinates of all text boxes one by one. If matching coordinates are found, they are stored in the result list.
[0169] S604: Using an aggregation module, the cells corresponding to the target four-point coordinates and the text information in the text box are concatenated to obtain the target cell.
[0170] It should be noted that in order to bring related information together and facilitate quick acquisition of comprehensive content, when there are target four-point coordinates that contain the four-point coordinates of a text box among the four-point coordinates of all cells, it is necessary to splice the text information of the cells and text boxes corresponding to the target coordinates to establish a direct connection between the cells and the text boxes, which helps to understand their relationship.
[0171] S605 . The table structure information of all target cells is converted into a form through the export module to obtain table data corresponding to the target image.
[0172] Specifically, the table structure information of all target cells is converted into Excel format through the export module, and the table data in Excel format can be obtained.
[0173] S206. Based on each to-be-matched subject in the formula set, determine whether there are multiple final matching subjects among all subjects included in the table data.
[0174] It should be emphasized that in order to find the final matching subject that best matches each subject to be matched from all subjects included in the table data, it is possible to determine whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set. If there are multiple final matching subjects among all subjects included in the table data, it means that there is a subject among all subjects included in the table data that has the smallest cosine distance with the subject to be matched and the cosine distance is less than the preset threshold, so step S207 can be executed at this time. The final matching subject refers to a subject that meets the preset requirements, and the preset requirements refer to the subject to be matched with the smallest cosine distance and the cosine distance is less than the preset threshold.
[0175] Optionally, in another embodiment of the present application, another specific implementation of step S206 is as follows: Figure 7 As shown, the following steps are included:
[0176] S701. For each subject to be matched in the formula set, calculate the edit distance between the subject to be matched and each subject in the table data.
[0177] It should be noted that, since the existing subject matching methods need to consider different semantic issues of subjects in different contexts, the present application designs a subject matching method of edit distance + calculation of similarity, so that there is no need to consider the contextual issues of the current subject, and thus the subjects to be matched in the formula set can be correctly matched with the subjects in the table data to the maximum extent. Therefore, the edit distance can be used to preliminarily filter out subjects with similar expressions to the subjects to be matched from each subject in the table data. The edit distance is used to calculate the minimum number of editing operations that a string can be converted into another string. These operations include inserting, deleting, and replacing characters. Therefore, based on this method, subjects with similar expressions to a subject to be matched can be quickly found.
[0178] S702. Filter out all target subjects that meet preset requirements from all subjects, and add all target subjects to a candidate set.
[0179] The target subject refers to a subject whose edit distance is less than half the character length of the subject to be matched.
[0180] It should be noted that after finding subjects (that is, target subjects) that are similar in expression to all subjects to be matched based on the edit distance method, the target subjects need to be further screened to further improve the matching accuracy. Therefore, in an embodiment of the present application, target subjects whose edit distance is less than half the character length of the subject to be matched are added to the candidate set.
[0181] S703: Calculate the cosine distance between the subject to be matched and each target subject in the candidate set.
[0182] It should be noted that the smaller the edit distance between two subjects, the higher the semantic similarity of the two subjects. Therefore, it is also necessary to calculate the semantic similarity between the two subjects. Therefore, in the embodiment of the present application, the cosine distance between multiple groups of subjects can be calculated, so that the smaller the cosine value, the higher the semantic similarity. Among them, a group of subjects includes a subject to be matched and all target subjects.
[0183] S704: Obtain a minimum cosine distance from all cosine distances, and determine whether the minimum cosine distance is less than a preset threshold.
[0184] It should be noted that after calculating the cosine distances between multiple groups of subjects, in order to further find the target subject that is most accurate with the subject to be matched from all target subjects, it is necessary to extract the minimum cosine distance of each group from all cosine distances, and determine whether the minimum cosine distance is less than the preset threshold, so as to find the final matching subject through the minimum cosine distance, and determine the similarity between the subject to be matched and the target subject, and then set a threshold to avoid taking the matching results with lower similarity as valid matches, thereby improving the accuracy and reliability of matching.
[0185] Therefore, if the minimum cosine distance is less than the preset threshold, it means that there is a best matching subject in the target subjects, so step S705 is executed at this time.
[0186] Optionally, if the minimum cosine distance is not less than a preset threshold, it means that there is no best matching subject in this group of subject matching, then the processing of this group is skipped and the processing of the next group of subject matching continues.
[0187] S705. Determine the target subject corresponding to the minimum cosine distance as the final matching subject, and determine whether there is a final matching subject among all the subjects included in the table data.
[0188] Optionally, when it is determined that there is no final matching subject among all the subjects included in the table data, there may be special subjects among all the subjects included in the table data. Therefore, in order to match the special subjects, after executing step S206, the special subjects need to be processed uniformly. Figure 8As shown, the embodiment of the present application provides a method for processing special subjects, comprising the following steps:
[0189] S801. When there are no multiple final matching subjects among all subjects included in the table data, identify a special subject formula dictionary from the table data.
[0190] It should be noted that when there is no final matching subject among all the subjects included in the table data, it means that there may be subjects in the table data that can be further disassembled as formulas. Therefore, the special subject formula dictionary can be identified from the table data by means of logic code. The special subject formula dictionary is S = {S1, S2, S3, ..., S n}. The key is the subject and the value is the formula.
[0191] S802. Determine whether there is a subject to be matched in the special subject formula dictionary.
[0192] Specifically, when identifying the special subject formula dictionary from the table data, a regular expression can be used to determine whether there is a subject to be matched in the special subject formula dictionary. If there is a subject to be matched in the special subject formula dictionary, it means that the subject in the table data can be matched, so step S803 is executed at this time. If there is no subject to be matched in the special subject formula dictionary, it means that there is no subject to be matched in the table data, so step S805 is executed at this time.
[0193] S803. Decompose the formula of the subject to be matched to obtain the sub-formula corresponding to the subject to be matched, and replace the subject to be matched with the sub-formula.
[0194] Specifically, when there are subjects to be matched in the special subject formula dictionary, the formula of the subjects to be matched can be decomposed according to the calculation principle of the subjects to be matched, and the decomposed sub-formula can be obtained. At this time, the sub-formula can be replaced with the corresponding subjects to be matched, and then it can be matched with the subjects in the table data.
[0195] For example, “Cash and cash assets ratio = cash and cash equivalents / total assets”, where “Total assets = total current assets + total non-current assets”.
[0196] S804. Add the sub-formula to the formula set.
[0197] It is understandable that after the sub-formula is added to the formula set, the specific implementation methods in steps S701 to S706 can then be executed, which will not be described in detail here.
[0198] S805. Replace the subject to be matched with the preset threshold.
[0199] Specifically, when there is no to-be-matched account in the special account formula dictionary, the to-be-matched account needs to be replaced with "0.0", which means that there is no to-be-matched account that matches the account.
[0200] S207 . For each final matching subject, replace the value of the subject to be matched corresponding to the final matching subject with the value corresponding to the final matching subject, so as to obtain the target value of the subject to be matched corresponding to the final matching subject.
[0201] It is understandable that when there are multiple final matching subjects among all the subjects contained in the table data, it is necessary to replace the value of the subject to be matched corresponding to each final matching subject with the value corresponding to the final matching subject, so that the formula set can be subsequently calculated based on the value corresponding to the final matching subject to obtain the calculation results of the financial statements and store them in string format.
[0202] S208. Based on the target value of each subject to be matched, a set of calculation formulas is calculated to obtain calculation results corresponding to the financial statements.
[0203] Specifically, after obtaining the subject in the table data that matches each subject to be matched and replacing it with the corresponding specific value, the formula calculation symbols in the formula set can be used for parsing and calculation, and then the target value of each subject to be matched is substituted into it, and the calculation result corresponding to the financial statement can be calculated.
[0204] Optionally, in another embodiment of the present application, another specific implementation of the formula set of step S208 is as follows: Fig. 9 As shown, the following steps are included:
[0205] S901. Use regular expressions to search for special symbols in a formula set.
[0206] It should be noted that traditional formula calculation uses reverse Polish notation or abstract syntax tree in the field of computer science to calculate the formula mathematical expression into a specific value, but this method cannot directly identify the calculation method of some special symbols, resulting in inaccurate calculation results. For example, "ABS()" is the absolute value of the calculated value, such as "x*5%", which is to multiply x by 0.05. Therefore, in the embodiment of the present application, regular expressions will be used in advance to find special symbols in the formula set.
[0207] S902: Replace special symbols in the formula set to obtain a target formula set.
[0208] It is understandable that after finding the special symbols in the formula set, some commonly used formula calculation functions can be customized to replace the special symbols, and the customized formula calculation functions must be consistent with the calculation meaning of the special symbols to obtain accurate calculation results.
[0209] For example, when "x*d%" is captured in a math expression, the "x*d%" part in the math expression can be replaced with "x*(d / 100)". When "ABS(a+bc)" is captured in a math expression, first calculate "a+bc", pass the calculation result to the custom ABS(x) function to calculate the numerical result F of "ABS(a+bc)", and convert the result F into a string to replace "ABS(a+bc)". In this way, after calculating and replacing the special symbols in the math expression, the resulting math expression is an expression that only contains addition, subtraction, multiplication, division, and parentheses, so that the formula set can be calculated effectively.
[0210] S903. According to the target value of each account to be matched, the target formula set is calculated using the reverse Polish notation to obtain the calculation result corresponding to the financial statement.
[0211] It can be understood that after replacing the special symbols to obtain the target formula set, the target value of each subject to be matched can be substituted into the formula corresponding to the target formula set, and then the target formula set can be calculated using the reverse Polish notation or the abstract syntax tree to obtain the calculation results corresponding to the financial statements.
[0212] It should be noted that the subject matching method of the entire formula parsing calculation module in the embodiment of the present application can refer to a formula subject matching algorithm provided below, and the specific algorithm is:
[0213] Input: Excel account value dictionary {M1, M2, M3, ..., M n}, Formula Fml. Special subject formula dictionary {S1, S2, S3, ..., S n}.
[0214] Output: The numerical calculation formula after the subject is replaced
[0215] Defsubject_Pair(M,Fml,S):
[0216] Use regular expression to get the subject F of Fml = {F1, F2, F3, ..., F n}
[0217] Get the key of M E = M.keys()
[0218]
[0219]
[0220] The application provides a numerical calculation method for financial statements, which obtains financial statements and corrects each image in the financial statements to obtain multiple target images. Secondly, for each target image, it is detected whether there is a table in the target image. If there is a table in the target image, the coordinates of each point of the table in the target image are obtained, and based on the coordinates of each point, the name area of the table is intercepted to obtain a sub-image of the table. Then, the sub-image of the table is text-recognized to obtain the name of the table, and it is determined whether the name of the table is any of the three major financial tables. If the name of the table is any of the three major financial tables, the target image is input into an open source model to obtain the table data corresponding to the target image, and a formula set is obtained from a database. Then, based on each subject to be matched in the formula set, it is determined whether there are multiple final matching subjects in all subjects included in the table data. If there are multiple final matching subjects in all subjects included in the table data, the value of the subject to be matched corresponding to the final matching subject is replaced with the value corresponding to the final matching subject for each final matching subject, and the target value of the subject to be matched corresponding to the final matching subject is obtained. Finally, based on the target value of each subject to be matched, the formula set is calculated to obtain the calculation result corresponding to the financial statement. Therefore, based on the matching relationship between each subject to be matched in the formula set and all subjects contained in the table data, not only the matching problem of subjects with the same semantics can be solved, but also the matching problem of subjects with missing text or character recognition errors and formula subjects can be solved to the greatest extent, thereby effectively solving the problem of inaccurate numerical values in the calculated financial statements.
[0221] Another embodiment of the present application provides a numerical calculation device for financial statements, such as Fig.10 As shown, it includes the following units:
[0222] The correction unit 1001 is used to obtain a financial statement and perform correction processing on each image in the financial statement to obtain multiple target images.
[0223] The table detection unit 1002 is used to detect whether there is a table in each target image.
[0224] The interception unit 1003 is used to obtain the coordinates of each point of the table in the target image if there is a table in the target image, and intercept the name area of the table based on the coordinates of each point to obtain a sub-image of the table.
[0225] The text recognition unit 1004 is used to perform text recognition on the sub-picture of the table, obtain the name of the table, and determine whether the name of the table is any of the three major financial tables.
[0226] The processing unit 1005 is used to input the target image into the open source model if the name of the table is any of the three major financial tables, obtain the table data corresponding to the target image, and obtain the formula set from the database.
[0227] The judgment unit 1006 is used to judge whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set. The final matching subject refers to a subject that meets the preset requirements. The preset requirements refer to the subject with the smallest cosine distance to the subject to be matched and the cosine distance is less than a preset threshold.
[0228] The value replacement unit 1007 is used to replace the value of the subject to be matched corresponding to the final matching subject with the value corresponding to the final matching subject for each final matching subject if there are multiple final matching subjects among all the subjects included in the table data, so as to obtain the target value of the subject to be matched corresponding to the final matching subject.
[0229] The calculation unit 1008 is used to calculate the formula set based on the target value of each to-be-matched account to obtain the calculation result corresponding to the financial statement.
[0230] It should be noted that the specific working process of the above-mentioned units in the embodiment of the present application can refer to steps S201 to S208 in the above-mentioned method embodiment, and will not be repeated here.
[0231] Optionally, in a numerical calculation device for a financial statement provided in another embodiment of the present application, the correction unit 1001 includes:
[0232] The straight line detection unit is used to perform Hough straight line detection on each image in the financial statement to obtain the left straight line and the right straight line corresponding to each image.
[0233] The angle calculation unit is used to calculate the inclination angle between the left straight line and the right straight line corresponding to each image.
[0234] The correction subunit is used to correct each image using a rotation algorithm according to the tilt angle of each image to obtain multiple target images.
[0235] Optionally, in a numerical calculation device for a financial statement provided in another embodiment of the present application, the interception unit 1003 includes:
[0236] The coordinate acquisition unit is used to acquire the left vertex coordinates and the right vertex coordinates of the target image.
[0237] The coordinate extraction unit is used to extract the target left vertex coordinate and the target right vertex coordinate of the table from the coordinates of each point.
[0238] The interception subunit is used to intercept the name area of the table based on the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates and the target right vertex coordinates to obtain a subgraph of the table.
[0239] Optionally, in a numerical calculation device for financial statements provided in another embodiment of the present application, the open source model includes a table structure prediction module, a text module, an aggregation module, and an export module, and the processing unit 1005 includes:
[0240] The acquisition unit is used to obtain the four-point coordinates and table structure information of each cell in the target image through the table structure prediction module.
[0241] The recognition unit is used to recognize the four-point coordinates and text information of each line of text box in the target image through the text module.
[0242] The coordinate judgment unit is used to judge, for each row of text boxes in the target image, through the aggregation module whether there are target four-point coordinates containing the four-point coordinates of the text box in the four-point coordinates of all cells.
[0243] The splicing unit is used to splice the text information of the cell and text box corresponding to the target four-point coordinates through the aggregation module to obtain the target cell if there are target four-point coordinates containing the four-point coordinates of the text box among the four-point coordinates of all cells.
[0244] The conversion unit is used to convert the table structure information of all target cells through the export module to obtain the table data corresponding to the target image.
[0245] Optionally, in another embodiment of the present application, a numerical calculation device for a financial statement further includes:
[0246] The first deleting unit is used to delete the interference symbol at the beginning position of each subject included in the table data.
[0247] The second deleting unit is used to delete the punctuation mark at the end position of each subject included in the table data.
[0248] The third deleting unit is used to delete the numbers in each subject included in the table data.
[0249] Optionally, in a numerical calculation device for a financial statement provided in another embodiment of the present application, the judgment unit 1006 includes:
[0250] The edit distance calculation unit is used to calculate the edit distance between each subject to be matched in the formula set and each subject in the table data.
[0251] The screening unit is used to screen out all target subjects that meet preset requirements from all subjects and add all target subjects to the candidate set. The target subject refers to a subject whose edit distance is less than half of the character length of the subject to be matched.
[0252] The cosine distance calculation unit is used to calculate the cosine distance between the subject to be matched and each target subject in the candidate set.
[0253] The judging subunit is used to obtain the minimum cosine distance from all cosine distances and judge whether the minimum cosine distance is less than a preset threshold.
[0254] The first determination unit is used to determine the target subject corresponding to the minimum cosine distance as the final matching subject if the minimum cosine distance is less than a preset threshold, and determine whether there is a final matching subject among all subjects included in the table data.
[0255] Optionally, in another embodiment of the present application, a numerical calculation device for a financial statement further includes:
[0256] The second identification unit is used to identify a special subject formula dictionary from the table data if there are no multiple final matching subjects among all subjects included in the table data.
[0257] The subject judgment unit is used to judge whether there is a subject to be matched in the special subject formula dictionary.
[0258] The formula decomposition unit is used to decompose the formula of the to-be-matched subject if there is a to-be-matched subject in the special subject formula dictionary, obtain the sub-formula corresponding to the to-be-matched subject, and replace the to-be-matched subject with the sub-formula.
[0259] Add cell, used to add a sub-formula to the formula collection.
[0260] The first replacement unit is used to replace the subject to be matched with a preset threshold value if the subject to be matched does not exist in the special subject formula dictionary.
[0261] Optionally, in a numerical calculation device for a financial statement provided in another embodiment of the present application, the calculation unit 1008 includes:
[0262] The search unit is used to search for special symbols in a formula set using regular expressions.
[0263] The second replacement unit is used to replace special symbols in the formula set to obtain a target formula set.
[0264] The calculation subunit is used to calculate the target formula set using the reverse Polish expression according to the target value of each account to be matched, and obtain the calculation result corresponding to the financial statement.
[0265] It should be noted that the specific working process of each unit provided in the above embodiments of the present application can refer to the corresponding steps in the above method embodiments, and will not be repeated here.
[0266] It should also be noted that the numerical calculation device for financial statements provided in the embodiment of the present application has the technical effects of any of the above embodiments, and the embodiment of the present application will not be described in detail here.
[0267] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0268] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A numerical calculation method for financial statements, characterized in that: include: Obtaining a financial statement, and performing correction processing on each image in the financial statement to obtain a plurality of target images; For each of the target images, detecting whether there is a table in the target image; If there is a table in the target image, the coordinates of each point of the table in the target image are obtained, and based on the coordinates of each point, the name area of the table is intercepted to obtain a sub-image of the table; Perform text recognition on the sub-image of the table to obtain the name of the table, and determine whether the name of the table is any of the three major financial tables; If the name of the table is any of the three major financial tables, the target image is input into the open source model to obtain the table data corresponding to the target image, and the formula set is obtained from the database; Based on each subject to be matched in the formula set, determine whether there are multiple final matching subjects among all subjects included in the table data; wherein the final matching subject refers to a subject that meets a preset requirement; the preset requirement refers to a subject whose cosine distance with the subject to be matched is the smallest and the cosine distance is less than a preset threshold; If there is a final matching subject among all the subjects included in the table data, then for each of the final matching subjects, the value of the subject to be matched corresponding to the final matching subject is replaced with the value corresponding to the final matching subject, so as to obtain the target value of the subject to be matched corresponding to the final matching subject; Based on the target value of each of the subjects to be matched, the formula set is calculated to obtain the calculation result corresponding to the financial statement.
2. The method according to claim 1, characterized in that The correction process is performed on each image in the financial statement to obtain multiple target images, including: Performing Hough line detection on each image in the financial statement to obtain a left straight line and a right straight line corresponding to each image; Calculate the inclination angle between the left straight line and the right straight line corresponding to each of the images; According to the tilt angle of each of the images, a rotation algorithm is used to correct each of the images to obtain multiple target images.
3. The method according to claim 1, characterized in that The method of intercepting the name area of the table based on the coordinates of each point to obtain a sub-image of the table includes: Obtain the left vertex coordinates and the right vertex coordinates of the target image; Extract the target left vertex coordinates and the target right vertex coordinates of the table from the coordinates of each point; Based on the left vertex coordinates, the right vertex coordinates, the target left vertex coordinates, and the target right vertex coordinates, the name area of the table is intercepted to obtain a subgraph of the table.
4. The method according to claim 1, characterized in that The open source model includes a table structure prediction module, a text module, an aggregation module, and an export module. The target image is input into the open source model to obtain the table data corresponding to the target image, including: Acquire the four-point coordinates and table structure information of each cell in the target image through the table structure prediction module; Identify the four-point coordinates and text information of each line of text box in the target image through the text module; For each row of text boxes in the target image, the aggregation module is used to determine whether the four-point coordinates of all cells contain the four-point coordinates of the text box; If there are target four-point coordinates including the four-point coordinates of the text box among the four-point coordinates of all cells, the cell corresponding to the target four-point coordinates and the text information of the text box are spliced by the aggregation module to obtain the target cell; The export module is used to convert the table structure information of all the target cells into a form to obtain the table data corresponding to the target image.
5. The method according to claim 1, characterized in that After inputting the target image into the open source model to obtain the table data corresponding to the target image, the method further includes: Deleting the interference symbol at the beginning of each subject included in the table data; Deleting the punctuation marks at the end of each subject included in the table data; Delete the numbers in each subject included in the table data.
6. The method according to claim 1, characterized in that The step of judging whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set includes: For each subject to be matched in the formula set, respectively, calculating the edit distance between the subject to be matched and each subject in the table data; Filtering all target subjects that meet preset requirements from all the subjects, and adding all the target subjects to the candidate set; wherein the target subject refers to a subject whose edit distance is less than half of the character length of the subject to be matched; Calculating the cosine distance between the subject to be matched and each target subject in the candidate set; Obtaining a minimum cosine distance from all the cosine distances, and determining whether the minimum cosine distance is less than a preset threshold; If the minimum cosine distance is less than a preset threshold, the target subject corresponding to the minimum cosine distance is determined as the final matching subject, and it is determined that there is a final matching subject among all the subjects included in the table data.
7. The method according to claim 1, characterized in that After judging whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set, the method further includes: If there are no multiple final matching subjects among all subjects included in the table data, identifying a special subject formula dictionary from the table data; Determine whether the subject to be matched exists in the special subject formula dictionary; If the subject to be matched exists in the special subject formula dictionary, the subject to be matched is decomposed into a formula to obtain a sub-formula corresponding to the subject to be matched, and the subject to be matched is replaced with the sub-formula; Adding the sub-formula to the formula set; If the subject to be matched does not exist in the special subject formula dictionary, the subject to be matched is replaced with a preset threshold value.
8. The method according to claim 1, characterized in that The step of calculating the formula set based on the target value of each of the to-be-matched subjects to obtain the calculation result corresponding to the financial statement includes: Using regular expressions to search for special symbols in the formula set; Replacing special symbols in the formula set to obtain a target formula set; According to the target value of each of the to-be-matched subjects, the target formula set is calculated using the reverse Polish notation to obtain the calculation result corresponding to the financial statement.
9. A numerical calculation device for financial statements, characterized in that: include: A correction unit, used for obtaining a financial statement and performing correction processing on each image in the financial statement to obtain a plurality of target images; A table detection unit, used for detecting, for each of the target images, whether there is a table in the target image; A cutting unit, configured to obtain the coordinates of each point of the table in the target image if there is a table in the target image, and to cut the name area of the table based on the coordinates of each point to obtain a sub-image of the table; A text recognition unit, used to perform text recognition on the sub-image of the table, obtain the name of the table, and determine whether the name of the table is any of the three major financial tables; A processing unit, configured to input the target image into the open source model if the name of the table is any one of the three major financial tables, obtain the table data corresponding to the target image, and obtain a formula set from the database; A judgment unit, configured to judge whether there are multiple final matching subjects among all subjects included in the table data based on each subject to be matched in the formula set; wherein the final matching subject refers to a subject that meets a preset requirement; the preset requirement refers to a subject whose cosine distance with the subject to be matched is the smallest and the cosine distance is less than a preset threshold; A value replacement unit, for replacing the value of the subject to be matched corresponding to the final matching subject with the value corresponding to the final matching subject for each final matching subject, if there is a final matching subject among all the subjects included in the table data, so as to obtain a target value of the subject to be matched corresponding to the final matching subject; A calculation unit is used to calculate the formula set based on the target value of each of the subjects to be matched, so as to obtain the calculation result corresponding to the financial statement.
10. The device according to claim 9, characterized in that The correction unit comprises: A straight line detection unit, used for performing Hough straight line detection on each image in the financial statement to obtain a left straight line and a right straight line corresponding to each image; An angle calculation unit, used to calculate the inclination angle between the left straight line and the right straight line corresponding to each of the pictures; The correction subunit is used to correct each of the pictures using a rotation algorithm according to the tilt angle of each of the pictures to obtain multiple target pictures.