Data comparison method, device and equipment and computer readable storage medium
By extracting and comparing the text content and structure in the financial report PDF file, the problems of inefficient and poor accuracy of financial report data comparison in the existing technology are solved, and efficient and accurate financial report data comparison is achieved.
Patent Information
- Application Number
- CN202411755458.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-02-25
AI Technical Summary
The existing PDF comparison solutions are inefficient and prone to errors, and cannot accurately compare specific formats in financial report data, resulting in poor accuracy of comparison and inability to meet the requirements of processing speed and efficiency.
Provide a data comparison method, which can obtain the original financial report PDF file, perform pre-processing to extract text content, identify and retain the key structure and formats in the financial report, and achieve accurate comparison of financial report data.
It improves the accuracy and efficiency of financial report data comparison, and can efficiently and accurately extract text content from PDF files, identify and retain key structures and formats in financial report.
Smart Images

Figure CN119513620A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data comparison method, device, equipment and computer-readable storage medium. Background Art
[0002] With the development of the digital economy, automated extraction and processing of financial report data has become a trend, which includes automatically extracting data from various financial documents and converting these data into structured formats, such as Portable Document Format (PDF) files, for easy analysis and decision-making.
[0003] In order to verify the accuracy of financial report data extraction, it is necessary to compare multiple original financial report PDF files with the financial report PDF files generated by platform extraction to verify whether the values of the same subjects are consistent.
[0004] Most existing PDF comparison solutions are done manually or with the help of specific tools. However, manual comparison is inefficient, prone to errors, low in accuracy, and costly; tools cannot compare specific formats in financial report data, resulting in poor comparison accuracy, and processing speed and efficiency cannot meet requirements. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a data comparison method, device, equipment and computer-readable storage medium, which can efficiently and accurately extract text content from PDF files, can identify and retain key structures and formats in financial reports, and can achieve accurate comparison of financial report data, thereby improving the accuracy and efficiency of financial report data comparison.
[0006] In a first aspect, an embodiment of the present disclosure provides a data comparison method, the method comprising:
[0007] Get the original financial report PDF file to be processed;
[0008] Preprocessing the original financial report PDF file to obtain a first target text;
[0009] Based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform;
[0010] Preprocessing the confirmed financial report PDF file to obtain a second target text;
[0011] The first target text is compared with the second target text, and a comparison result is output.
[0012] In a second aspect, an embodiment of the present disclosure provides a data comparison device, the device comprising:
[0013] The first acquisition module is used to acquire the original financial report PDF file to be processed;
[0014] A first obtaining module is used to pre-process the original financial report PDF file to obtain a first target text;
[0015] A second acquisition module, configured to obtain an identifier of the financial report file to be compared based on the name of the original financial report PDF file, and obtain a confirmed financial report PDF file from the financial report processing platform based on the identifier of the financial report file to be compared;
[0016] A second obtaining module is used to pre-process the confirmed financial report PDF file to obtain a second target text;
[0017] The output module is used to compare the first target text with the second target text and output the comparison result.
[0018] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0019] Memory;
[0020] Processor; and
[0021] Computer programs;
[0022] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0023] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method as described in the first aspect.
[0024] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect is implemented.
[0025] The data comparison method, device, equipment and computer-readable storage medium provided by the embodiments of the present disclosure obtain the original financial report PDF file to be processed, pre-process the original financial report PDF file, and obtain the first target text. Furthermore, based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform, and the confirmed financial report PDF file is pre-processed to obtain a second target text. The first target text is then compared with the second target text, and the comparison result is output. Compared with the prior art, the embodiments of the present disclosure can efficiently and accurately extract text content from PDF files, can identify and retain key structures and formats in financial reports, can achieve accurate comparison of financial report data, and improve the accuracy and efficiency of financial report data comparison. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0027] In order to more clearly illustrate the embodiments of the present invention 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1 A flow chart of a data comparison method provided in an embodiment of the present disclosure;
[0029] Figure 2 A schematic diagram of a complete data comparison process provided in an embodiment of the present disclosure;
[0030] Figure 3 A flow chart of a data comparison method provided by another embodiment of the present disclosure;
[0031] Figure 4 A flow chart of a data comparison method provided by another embodiment of the present disclosure;
[0032] Figure 5 A schematic diagram of the structure of a data comparison device provided in an embodiment of the present disclosure;
[0033] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0035] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0036] With the development of the digital economy, automated extraction and processing of financial report data has become a trend, which includes automatically extracting data from various financial documents and converting these data into structured formats, such as Portable Document Format (PDF) files, for easy analysis and decision-making.
[0037] In order to verify the accuracy of financial report data extraction, it is necessary to compare multiple original financial report PDF files with the financial report PDF files generated by platform extraction to verify whether the values of the same subjects are consistent.
[0038] Most existing PDF comparison solutions are done manually or with the help of specific tools. However, manual comparison is inefficient, prone to errors, low in accuracy, and costly; tools cannot compare specific formats in financial report data, resulting in poor comparison accuracy, and processing speed and efficiency cannot meet requirements.
[0039] To address this problem, the present disclosure provides a data comparison method, which is described below in conjunction with a specific embodiment.
[0040] Figure 1 A flow chart of the data comparison method provided in the embodiment of the present disclosure. The executor of the method is an electronic device. The electronic device may be a portable mobile device such as a smart phone, a tablet computer, a laptop computer, a car navigation device, an intelligent sports equipment, or a fixed device such as a personal computer, a smart home appliance, or a server, wherein the server may be a single server or a server cluster, and the server cluster may be a distributed cluster or a centralized cluster. The method may be applied to the scenario of comparing financial report data. It is understandable that the data comparison method provided in the embodiment of the present disclosure may also be applied in other scenarios.
[0041] Below Figure 1 The data comparison method shown is introduced, the execution subject of the method is an electronic device, and the specific steps of the method are as follows:
[0042] S101. Obtain the original financial report PDF file to be processed.
[0043] In this step, the electronic device will obtain the original financial report PDF file to be processed.
[0044] S102: Preprocess the original financial report PDF file to obtain a first target text.
[0045] In this step, the electronic device may preprocess the original financial report PDF file to obtain a first target text txt1, and obtain a txt file according to the PDF file through preprocessing. In some embodiments, the preprocessing may include but is not limited to text extraction and data cleaning.
[0046] S103. Based on the name of the original financial report PDF file, obtain an identifier of the financial report file to be compared, and based on the identifier of the financial report file to be compared, obtain a confirmed financial report PDF file from the financial report processing platform.
[0047] In this step, the electronic device will obtain the identifier of the financial report file to be compared based on the name of the original financial report PDF file, and further obtain the confirmed financial report PDF file from the financial report processing platform based on the identifier of the financial report file to be compared. For example, the electronic device can call the interface of the financial report processing platform, query the identifier of the financial report file to be compared based on the name of the original financial report PDF file, and the financial report processing platform will return the identifier of the financial report file to be compared to the electronic device.
[0048] Optionally, the identifier of the financial report file to be compared may be a universally unique identifier (UUID) or other identifiers, which are not specifically limited here. Figure 2 As shown, the electronic device will download the confirmed financial report PDF file from the financial report processing platform based on the identifier of the financial report file to be compared.
[0049] In some embodiments, S103 obtains an identifier of the financial report file to be compared based on the name of the original financial report PDF file, including but not limited to S1031 and S1032:
[0050] S1031. Extracting company information based on the name of the original financial report PDF file, where the company information includes company name and financial report period;
[0051] In this embodiment, the original financial report PDF file is named after the company name and financial report period, such as Figure 2 As shown, the electronic device can extract company information from the name of the original financial report PDF file, and the company information includes the company name and financial report period.
[0052] S1032. Based on the company name and the financial report period, query for an identifier of the financial report file to be compared that corresponds to the company information.
[0053] In some embodiments, the electronic device stores a mapping relationship between the company information and the identifier of the financial report file to be compared, and can query the identifier of the financial report file to be compared corresponding to the company information according to the company name and the financial report period. In other optional implementations, the financial report processing platform stores a mapping relationship between the company information and the identifier of the financial report file to be compared, and the electronic device can call the interface of the financial report processing platform to query the identifier of the financial report file to be compared according to the company name and the financial report period, and the financial report processing platform will return the identifier of the financial report file to be compared to the electronic device.
[0054] S104: Preprocess the confirmed financial report PDF file to obtain a second target text.
[0055] In this step, the electronic device may preprocess the confirmed financial report PDF file to obtain a second target text txt2, and obtain a txt file based on the PDF file through preprocessing. In some embodiments, the preprocessing may include but is not limited to text extraction and data cleaning.
[0056] Optionally, the confirmed financial report PDF file is preprocessed to obtain a second target text, including: performing text extraction on the confirmed financial report PDF file to obtain a second text; and performing data cleaning on the second text to obtain a second target text.
[0057] When extracting text, you can use the Python library (pdfplumber, re) to extract text from the confirmed financial report PDF file (pdf2) and store the text content in txt2: use the pdfplumber.open function to open the confirmed financial report PDF file; initialize an empty string txt2 to store the text of the entire document; traverse each page in the confirmed financial report PDF file.
[0058] Optionally, iterate over each page in the confirmed financial report PDF file, including: 1) extracting the text on each page using the extract_text() method; 2) appending the extracted text to the txt2 string and adding a line break after the text on each page to ensure that the content between pages is not connected.
[0059] During data cleaning: a. Convert the data format of the amount data in the second target text to the target format. Specifically, format the amount data of each account in txt2 and remove the English commas in the amount. For example, format 3,462,834.21 to 3462834.21 to facilitate comparison of financial data.
[0060] b. Find the target pattern data from the second target text, insert a line break between the floating point number and the Chinese character in the target pattern data, and the target pattern data is data in which the floating point number is directly followed by the Chinese character. Specifically, find all patterns in which the floating point number is directly followed by the Chinese character, and insert a line break between the floating point number and the Chinese character in these patterns, so as to achieve the effect of line separation. For example, after adding a line break, the monetary funds 1432 demolition funds 2443 becomes: monetary funds 1432\n demolition funds 2443.
[0061] S105: Compare the first target text with the second target text, and output a comparison result.
[0062] In this step, if Figure 2 As shown, the electronic device will compare the first target text (txt1) with the second target text (txt2), and output the comparison result, which can efficiently and accurately extract text content from the PDF file, can identify and retain the key structure and format in the financial report, and can achieve accurate comparison of financial report data. Optionally, the comparison result can be output in the form of a summary report or other forms, which are not specifically limited here.
[0063] The disclosed embodiment obtains the original financial report PDF file to be processed, pre-processes the original financial report PDF file, and obtains the first target text. Furthermore, based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform, and the confirmed financial report PDF file is pre-processed to obtain the second target text. The first target text is then compared with the second target text, and the comparison result is output. Compared with the prior art, the disclosed embodiment can efficiently and accurately extract text content from PDF files, can identify and retain key structures and formats in financial reports, can achieve accurate comparison of financial report data, and improve the accuracy and efficiency of financial report data comparison.
[0064] Figure 3 A flow chart of a data comparison method provided by another embodiment of the present disclosure is shown in FIG. Figure 3 As shown, the method includes the following steps:
[0065] S201. Read the financial report file directory.
[0066] like Figure 2 As shown, there is a scheduled task in the electronic device, which will trigger the scheduling task regularly. After the scheduling task is triggered regularly, the financial report file directory will be read.
[0067] S202: Determine whether all financial report files in the financial report file directory have been processed.
[0068] like Figure 2 As shown, the electronic device can determine whether the financial report processing is completed, that is, determine whether each financial report file in the financial report file directory has been processed.
[0069] S203. If all financial report files have not been processed, the original financial report PDF file to be processed is obtained from the financial report file directory.
[0070] In this step, if all financial report files have not been processed, the original financial report PDF files to be processed are obtained from the financial report file directory. Figure 2 As shown in the figure, if all financial report files are processed, a summary report will be output.
[0071] S204: Extract text from the original financial report PDF file to obtain a first text.
[0072] In this step, if Figure 2 As shown, the electronic device extracts text from the original financial report PDF file to obtain the first text. For example, the Python library (pdfplumber, re) is used to extract text from the original financial report PDF file (pdf1) and store the text content in txt1.
[0073] Specifically, use the pdfplumber.open function to open the original financial report PDF file; initialize an empty string txt1 to store the text of the entire document; and traverse each page in the original financial report PDF file.
[0074] Optionally, traverse each page in the original financial report PDF file, including: 1) using the extract_text() method to extract the text on each page; 2) append the extracted text to the txt1 string and add a line break after the text of each page to ensure that the content between pages is not connected.
[0075] S205: Perform data cleaning on the first text to obtain a first target text.
[0076] In this step, if Figure 2 As shown, the electronic device performs data cleaning on the first text to obtain a first target text.
[0077] In some embodiments, S205 includes but is not limited to S2051, S2052, S2053:
[0078] S2051, traversing the first target text, and removing field information irrelevant to financial report data in the first target text;
[0079] In this embodiment, txt1 is traversed to remove field information irrelevant to the financial report data, such as company profile, business overview, operating conditions, shareholder conditions, etc., and only financial data related to the cash flow statement, balance sheet, and income statement are retained.
[0080] S2052: Convert the data format of the amount data in the first target text into a target format.
[0081] In this embodiment, the data format of the amount data in the first target text is converted to the target format. Specifically, the amount data of each account in txt2 is formatted, and the English commas in the amount are removed. For example, 3,462,834.21 is formatted as 3462834.21 to facilitate the comparison of financial data.
[0082] S2053. Find target pattern data from the first target text, insert a line break between the floating point number and the Chinese character in the target pattern data, and the target pattern data is data consisting of Chinese characters directly following the floating point number.
[0083] In this embodiment, the target pattern data is found from the first target text, and a line break is inserted between the floating point number and the Chinese character in the target pattern data. The target pattern data is data in which the floating point number is directly followed by the Chinese character. Specifically, all patterns in which the floating point number is directly followed by the Chinese character are found, and a line break is inserted between the floating point number and the Chinese character in these patterns, thereby achieving the effect of line separation. For example, after adding a line break, the monetary fund 1432 demolished funds 2443 becomes: monetary fund 1432\n demolished funds 2443.
[0084] S206. Based on the name of the original financial report PDF file, obtain an identifier of the financial report file to be compared, and based on the identifier of the financial report file to be compared, obtain a confirmed financial report PDF file from the financial report processing platform.
[0085] Specifically, the implementation process and principle of S206 and S103 are the same, and will not be repeated here.
[0086] S207: Preprocess the confirmed financial report PDF file to obtain a second target text.
[0087] Specifically, the implementation process and principle of S207 and S104 are the same, and will not be repeated here.
[0088] S208: Compare the first target text with the second target text, and output a comparison result.
[0089] Specifically, the implementation process and principle of S208 and S105 are the same, and will not be repeated here.
[0090] The disclosed embodiment reads the financial report file directory to determine whether all the financial report files in the financial report file directory have been processed. If all the financial report files have not been processed, the original financial report PDF file to be processed is obtained from the financial report file directory. Then, the original financial report PDF file is subjected to text extraction to obtain a first text, and the first text is subjected to data cleaning to obtain a first target text. Further, based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform, and the confirmed financial report PDF file is preprocessed to obtain a second target text. Then, the first target text is compared with the second target text, and the comparison result is output. Through this method, the disclosed embodiment can efficiently and accurately extract text content from PDF files, can identify and retain key structures and formats in financial reports, can achieve accurate comparison of financial report data, and improve the accuracy and efficiency of financial report data comparison.
[0091] Figure 4 A flow chart of a data comparison method provided by another embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the method includes the following steps:
[0092] S301. Obtain the original financial report PDF file to be processed.
[0093] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.
[0094] S302: pre-process the original financial report PDF file to obtain a first target text.
[0095] Specifically, the implementation process and principle of S302 and S102 are the same, and will not be repeated here.
[0096] S303: Based on the name of the original financial report PDF file, obtain the identifier of the financial report file to be compared, and based on the identifier of the financial report file to be compared, obtain the confirmed financial report PDF file from the financial report processing platform.
[0097] Specifically, the implementation process and principle of S303 and S103 are the same, and will not be repeated here.
[0098] S304: pre-process the confirmed financial report PDF file to obtain a second target text.
[0099] Specifically, the implementation process and principle of S304 and S104 are the same, and will not be repeated here.
[0100] S305: Initialize various counters, including a matching counter and a mismatching counter.
[0101] In this embodiment, the electronic device initializes various counters, including a matching counter and a non-matching counter.
[0102] Optionally, the match counter includes a match counter i1 corresponding to the first value and a match counter i2 corresponding to the second value; the mismatch counter includes a mismatch counter j1 corresponding to the first value and a mismatch counter j2 corresponding to the second value.
[0103] S306: Generate a first target text key-value pair based on the first target text, and generate a second target text key-value pair based on the second target text.
[0104] In this step, the electronic device can extract the subject (i.e. key), amount (i.e. value) and other data from the first target text txt1 and the second target text txt2 according to the subjects in the templates of financial statements such as cash flow statement, balance sheet, income statement, etc., for example, monetary funds 1434.32, and store them in the form of key-value pairs in the dictionary variable, generating the first target text key-value pair and the second target text key-value pair respectively.
[0105] S307 , determining whether the value in the second target text key-value pair includes beginning-of-period financial report data and end-of-period financial report data.
[0106] In this embodiment, it is determined whether the value in the second target text key-value pair includes the beginning financial report data and the end financial report data. Specifically, if one key in the second target text key-value pair corresponds to two values, the value in the second target text key-value pair includes the beginning financial report data and the end financial report data. If one key in the second target text key-value pair corresponds to one value, the value in the second target text key-value pair does not include the beginning financial report data and the end financial report data.
[0107] S308. If it contains beginning-of-period financial report data and end-of-period financial report data, then for any key in the second target text key-value pair, determine whether the first value of the key matches the first value of the corresponding key in the first target text key-value pair, and determine whether the second value of the key matches the second value of the corresponding key in the first target text key-value pair.
[0108] In this step, when the value in the second target text key-value pair includes the beginning financial report data and the end financial report data, for any key in the second target text key-value pair, the electronic device will determine whether the first value of the key matches the first value of the corresponding key in the first target text key-value pair, and determine whether the second value of the key matches the second value of the corresponding key in the first target text key-value pair. The first value is the beginning financial report data, and the second value is the end financial report data.
[0109] S309. If the first value of the key matches the first value of the corresponding key in the first target text key-value pair, or the second value of the key matches the second value of the corresponding key in the first target text key-value pair, then the value of the corresponding match counter is increased by one.
[0110] In this step, if the first value of the key matches the first value of the corresponding key in the first target text key-value pair, the value of the matching counter i1 corresponding to the first value is increased by one; if the second value of the key matches the second value of the corresponding key in the first target text key-value pair, the value of the matching counter i2 corresponding to the second value is increased by one.
[0111] S310. If the first value of the key does not match the first value of the corresponding key in the first target text key-value pair, or the second value of the key does not match the second value of the corresponding key in the first target text key-value pair, the value of the corresponding mismatch counter is increased by one.
[0112] In this step, if the first value of the key does not match the first value of the corresponding key in the first target text key-value pair, the value of the mismatch counter j1 corresponding to the first value is increased by one; if the second value of the key does not match the second value of the corresponding key in the first target text key-value pair, the value of the mismatch counter j2 corresponding to the second value is increased by one.
[0113] S311. Calculate the extraction accuracy of the financial report processing platform according to the value of the matching counter and the value of the mismatching counter, and output the comparison result.
[0114] In this step, the electronic device calculates the extraction accuracy of the financial report processing platform according to the value of the matching counter and the value of the mismatching counter, and outputs the comparison result. In some embodiments, the extraction accuracy of the financial report processing platform ratio = (i1 + i2) / (i1 + i2 + j1 + j2). In some embodiments, the comparison result includes the number of matches, the number of mismatches, the extraction accuracy, and may also include other data quantities, without specific limitation.
[0115] In some embodiments, after S307, the method further includes:
[0116] Step A: If the beginning-of-period financial report data and the end-of-period financial report data are not included, for any key in the second target text key-value pair, determine whether the value of the key matches the value of the corresponding key in the first target text key-value pair;
[0117] In this step, when the value in the second target text key-value pair does not include the beginning-of-period financial report data and the end-of-period financial report data, for any key in the second target text key-value pair, the electronic device will determine whether the value of the key matches the value of the corresponding key in the first target text key-value pair.
[0118] Step B: if the value of the key matches the value of the corresponding key in the first target text key-value pair, then the value of the corresponding matching counter is increased by one;
[0119] In this step, if the value of the key matches the value of the corresponding key in the first target text key-value pair, the value of the matching counter i1 corresponding to the first value is increased by one.
[0120] Step C: if the value of the key does not match the value of the corresponding key in the first target text key-value pair, then the value of the corresponding mismatch counter is increased by one;
[0121] In this step, if the value of the key does not match the value of the corresponding key in the first target text key-value pair, the value of the mismatch counter j1 corresponding to the first value is increased by one.
[0122] Step D: Calculate the extraction accuracy of the financial report processing platform according to the value of the matching counter and the value of the mismatching counter, and output the comparison result.
[0123] In this step, the electronic device calculates the extraction accuracy of the financial report processing platform according to the value of the matching counter and the value of the mismatching counter, and outputs the comparison result. In some embodiments, the extraction accuracy of the financial report processing platform ratio = (i1 + i2) / (i1 + i2 + j1 + j2). In some embodiments, the comparison result includes the number of matches, the number of mismatches, the extraction accuracy, and may also include other data quantities, without specific limitation.
[0124] The disclosed embodiment obtains the original financial report PDF file to be processed, pre-processes the original financial report PDF file, and obtains the first target text. Then, based on the name of the original financial report PDF file, obtains the identifier of the financial report file to be compared, and based on the identifier of the financial report file to be compared, obtains the confirmed financial report PDF file from the financial report processing platform, pre-processes the confirmed financial report PDF file, and obtains the second target text. Further, initialize each counter, each counter includes a matching counter and a mismatching counter, generates a first target text key-value pair based on the first target text, generates a second target text key-value pair based on the second target text, and determines whether the value in the second target text key-value pair contains the beginning financial report data and the end financial report data. If it contains the beginning financial report data and the end financial report data, then for any key in the second target text key-value pair, determine whether the first value of the key matches the first value of the corresponding key in the first target text key-value pair, and determine whether the second value of the key matches the second value of the corresponding key in the first target text key-value pair. Next, if the first value of the key matches the first value of the corresponding key in the first target text key-value pair, or the second value of the key matches the second value of the corresponding key in the first target text key-value pair, the value of the corresponding match counter is increased by one; if the first value of the key does not match the first value of the corresponding key in the first target text key-value pair, or the second value of the key does not match the second value of the corresponding key in the first target text key-value pair, the value of the corresponding mismatch counter is increased by one. Then, according to the value of the match counter and the value of the mismatch counter, the extraction accuracy of the financial report processing platform is calculated, and the comparison result is output. Compared with the prior art, the embodiment of the present disclosure can efficiently and accurately extract text content from PDF files, can identify and retain key structures and formats in financial reports, and realizes accurate comparison of financial report data by defining clear key-value pair matching rules. A new accuracy calculation formula is also proposed, which can comprehensively consider the number of matched key-value pairs and the importance of data to calculate an accuracy index that comprehensively reflects the quality of data extraction, thereby improving the accuracy and efficiency of financial report data comparison.
[0125] Figure 5 The data comparison device provided in the embodiment of the present disclosure is a schematic diagram of the structure of the data comparison device. The data comparison device may be the electronic device described in the above embodiment, or the data comparison device may be a component or assembly in the electronic device. The data comparison device provided in the embodiment of the present disclosure may execute the processing flow provided in the data comparison method embodiment, such as Figure 5As shown, the data comparison device 50 includes: a first acquisition module 51, a first obtaining module 52, a second acquisition module 53, a second obtaining module 54, and an output module 55; wherein the first acquisition module 51 is used to obtain the original financial report PDF file to be processed; the first obtaining module 52 is used to preprocess the original financial report PDF file to obtain a first target text; the second acquisition module 53 is used to obtain an identifier of the financial report file to be compared based on the name of the original financial report PDF file, and based on the identifier of the financial report file to be compared, obtain a confirmed financial report PDF file from the financial report processing platform; the second obtaining module 54 is used to preprocess the confirmed financial report PDF file to obtain a second target text; the output module 55 is used to compare the first target text with the second target text, and output the comparison result.
[0126] Optionally, when the first acquisition module 51 acquires the original financial report PDF file to be processed, it is specifically used to: read the financial report file directory; determine whether all financial report files in the financial report file directory have been processed; if all financial report files have not been processed, acquire the original financial report PDF file to be processed from the financial report file directory.
[0127] Optionally, when the first obtaining module 52 preprocesses the original financial report PDF file to obtain the first target text, it is specifically used to: extract text from the original financial report PDF file to obtain the first text; and clean the first text to obtain the first target text.
[0128] Optionally, the first obtaining module 52 performs data cleaning on the first text to obtain the first target text, specifically for: traversing the first target text to remove field information in the first target text that is not related to the financial report data; converting the data format of the amount data in the first target text into a target format; searching for target pattern data from the first target text, inserting a line break between the floating point number and the Chinese characters in the target pattern data, the target pattern data being data consisting of Chinese characters directly following a floating point number.
[0129] Optionally, when the second acquisition module 53 obtains the identifier of the financial report file to be compared based on the name of the original financial report PDF file, it is specifically used to: extract company information based on the name of the original financial report PDF file, and the company information includes company name and financial report period; based on the company name and the financial report period, query the identifier of the financial report file to be compared corresponding to the company information.
[0130] Optionally, the output module 55 compares the first target text with the second target text, and when outputting the comparison result, is specifically used to: initialize various counters, including matching counters and non-matching counters; generate a first target text key-value pair based on the first target text, and generate a second target text key-value pair based on the second target text; determine whether the value in the second target text key-value pair contains beginning-of-period financial report data and end-of-period financial report data; if it contains beginning-of-period financial report data and end-of-period financial report data, then for any key in the second target text key-value pair, determine whether the first value of the key matches the first value of the corresponding key in the first target text key-value pair, and determine whether the key Whether the second value matches the second value of the corresponding key in the first target text key-value pair; if the first value of the key matches the first value of the corresponding key in the first target text key-value pair, or the second value of the key matches the second value of the corresponding key in the first target text key-value pair, then the value of the corresponding match counter is increased by one; if the first value of the key does not match the first value of the corresponding key in the first target text key-value pair, or the second value of the key does not match the second value of the corresponding key in the first target text key-value pair, then the value of the corresponding mismatch counter is increased by one; based on the value of the match counter and the value of the mismatch counter, the extraction accuracy of the financial report processing platform is calculated, and the comparison result is output.
[0131] Optionally, the output module 55 is also used for: if it does not include beginning-of-period financial report data and end-of-period financial report data, then for any key in the second target text key-value pair, determine whether the value of the key matches the value of the corresponding key in the first target text key-value pair; if the value of the key matches the value of the corresponding key in the first target text key-value pair, then increase the value of the corresponding match counter by one; if the value of the key does not match the value of the corresponding key in the first target text key-value pair, then increase the value of the corresponding mismatch counter by one; based on the value of the match counter and the value of the mismatch counter, calculate the extraction accuracy of the financial report processing platform, and output the comparison result.
[0132] Figure 5 The data comparison device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be described in detail here.
[0133] Figure 6 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 6 , which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0134] like Figure 6As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603 to implement the data comparison method of the embodiment described in the present disclosure. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0135] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0136] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the data comparison method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0137] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0138] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0139] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0140] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0141] Get the original financial report PDF file to be processed;
[0142] Preprocessing the original financial report PDF file to obtain a first target text;
[0143] Based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform;
[0144] Preprocessing the confirmed financial report PDF file to obtain a second target text;
[0145] The first target text is compared with the second target text, and a comparison result is output.
[0146] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0147] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0148] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0149] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0150] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0151] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0152] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0153] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0154] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A data comparison method, characterized in that: The method comprises: Get the original financial report PDF file to be processed; Preprocessing the original financial report PDF file to obtain a first target text; Based on the name of the original financial report PDF file, an identifier of the financial report file to be compared is obtained, and based on the identifier of the financial report file to be compared, a confirmed financial report PDF file is obtained from the financial report processing platform; Preprocessing the confirmed financial report PDF file to obtain a second target text; The first target text is compared with the second target text, and a comparison result is output.
2. The method according to claim 1, characterized in that The obtaining of the original financial report PDF file to be processed includes: Read the financial report file directory; Determine whether all financial report files in the financial report file directory have been processed; If all financial report files have not been processed, the original financial report PDF files to be processed are obtained from the financial report file directory.
3. The method according to claim 1, characterized in that The preprocessing of the original financial report PDF file to obtain a first target text includes: Extracting text from the original financial report PDF file to obtain a first text; Data cleaning is performed on the first text to obtain a first target text.
4. The method according to claim 3, characterized in that The step of performing data cleaning on the first text to obtain a first target text includes: Traversing the first target text, and removing field information irrelevant to the financial report data in the first target text; Converting the data format of the amount data in the first target text into a target format; Target pattern data is found from the first target text, a line break is inserted between the floating point number and the Chinese character in the target pattern data, and the target pattern data is data consisting of Chinese characters directly following the floating point number.
5. The method according to claim 1, characterized in that The step of obtaining the identifier of the financial report file to be compared based on the name of the original financial report PDF file includes: Based on the name of the original financial report PDF file, extract company information, the company information including company name and financial report period; Based on the company name and the financial report period, an identifier of the financial report file to be compared corresponding to the company information is queried.
6. The method according to claim 1, characterized in that The comparing the first target text with the second target text and outputting the comparison result includes: Initializing various counters, wherein the various counters include a matching counter and a mismatching counter; Generate a first target text key-value pair based on the first target text, and generate a second target text key-value pair based on the second target text; Determine whether the value in the second target text key-value pair contains the beginning-of-period financial report data and the end-of-period financial report data; If it contains the beginning-of-period financial report data and the end-of-period financial report data, then for any key in the second target text key-value pair, determine whether the first value of the key matches the first value of the corresponding key in the first target text key-value pair, and determine whether the second value of the key matches the second value of the corresponding key in the first target text key-value pair; If the first value of the key matches the first value of the corresponding key in the first target text key-value pair, or the second value of the key matches the second value of the corresponding key in the first target text key-value pair, then the value of the corresponding match counter is increased by one; If the first value of the key does not match the first value of the corresponding key in the first target text key-value pair, or the second value of the key does not match the second value of the corresponding key in the first target text key-value pair, then the value of the corresponding mismatch counter is increased by one; According to the value of the matching counter and the value of the non-matching counter, the extraction accuracy of the financial report processing platform is calculated, and the comparison result is output.
7. The method according to claim 6, characterized in that The method further comprises: If the beginning-of-period financial report data and the end-of-period financial report data are not included, for any key in the second target text key-value pair, determine whether the value of the key matches the value of the corresponding key in the first target text key-value pair; If the value of the key matches the value of the corresponding key in the first target text key-value pair, the value of the corresponding match counter is increased by one; If the value of the key does not match the value of the corresponding key in the first target text key-value pair, the value of the corresponding mismatch counter is increased by one; According to the value of the matching counter and the value of the non-matching counter, the extraction accuracy of the financial report processing platform is calculated, and the comparison result is output.
8. A data comparison device, characterized in that: The device comprises: The first acquisition module is used to acquire the original financial report PDF file to be processed; A first obtaining module is used to pre-process the original financial report PDF file to obtain a first target text; A second acquisition module, configured to obtain an identifier of the financial report file to be compared based on the name of the original financial report PDF file, and obtain a confirmed financial report PDF file from the financial report processing platform based on the identifier of the financial report file to be compared; A second obtaining module is used to pre-process the confirmed financial report PDF file to obtain a second target text; The output module is used to compare the first target text with the second target text and output the comparison result.
9. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.