Document digital processing method and device, equipment and storage medium
By extracting and calculating target numbers in the process of digitizing paper documents and generating electronic documents, the problem of failing to effectively process document data in the prior art is solved, and the application value and management efficiency of documents are improved.
Patent Information
- Application Number
- CN202510443514.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-25
AI Technical Summary
In the prior art, the digitization process of paper documents is limited to the conversion of images or text, and the data cannot be effectively extracted and calculated, hindering the comprehensive application and value mining of digital documents.
By obtaining image data of paper documents, character recognition algorithms are used to extract text information, filter out target numbers that meet the calculation needs, and calculate based on pre-design calculation formulas to generate electronic documents.
It realizes efficient extraction and calculation of numbers in paper documents, and the generated electronic documents can be directly applied to scenarios such as financial statements and statistical data, improving document management and utilization efficiency.
Smart Images

Figure CN120373263A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of document management, and in particular, to a method, apparatus, device, and storage medium for digital processing of documents. Background Art
[0002] With the continuous progress of digital technology, the digitization of paper documents has become an important means to improve work efficiency and information management. In the prior art, the digitization process of paper documents mainly converts paper documents into digital images or PDF files through scanners, photographic equipment, etc. These technologies can effectively save and disseminate document content, making it convenient to retrieve and share paper documents. However, the existing digitization process of paper documents is usually limited to the conversion of images or texts, and does not involve further processing or analysis of the data contained therein. This means that although the document content has been digitized, data such as numerical values contained in the document are still difficult to be efficiently extracted, calculated, or used for other data analysis tasks. This limitation hinders the comprehensive application and value mining of digitized documents to a certain extent. Summary of the Invention
[0003] In view of this, to solve the problems existing in the prior art, this application provides a method, apparatus, device, and storage medium for digital processing of documents.
[0004] In a first aspect, this application provides a method for digital processing of documents, including:
[0005] Obtain image data of a paper document, and extract text information in the image data based on an optical character recognition algorithm;
[0006] If it is determined that the text information contains numbers, screen out target numbers for meeting calculation requirements;
[0007] Based on a preset calculation formula, calculate the target numbers to obtain a calculation result, and display the calculation result in a preset manner;
[0008] Generate an electronic document according to the text information.
[0009] In an optional implementation manner, the screening out of target numbers for meeting calculation requirements includes:
[0010] Identify the number format corresponding to the numbers in the text information;
[0011] When it is determined that the number format corresponding to the number meets the preset calculation requirements according to the context information corresponding to the number, preset variable types, and / or the calculation formula, determine the number as a target number.
[0012] In an alternative embodiment, the process of determining that the numerical format corresponding to the number meets the predetermined calculation requirements according to the context information corresponding to the number, the preset variable type, and / or the calculation formula includes:
[0013] According to the context information corresponding to the number in the image data and the calculation formula, if it is determined that the numerical format corresponding to the number meets the calculation rules corresponding to the calculation formula, it is determined that the predetermined calculation requirements are met;
[0014] and / or, according to the context information corresponding to the number in the image data and the preset variable type, if it is determined that the numerical format corresponding to the number is consistent with the preset variable type, it is determined that the predetermined calculation requirements are met.
[0015] In an alternative embodiment, the calculation of the target number based on the preset calculation formula includes:
[0016] Parse the preset calculation formula to parse each calculation formula into an expression, and each of the expressions includes variables and operators;
[0017] Replace the variables in the expression with the target number whose numerical format is consistent with the type of the variable;
[0018] Perform calculations using the expression after variable replacement.
[0019] In an alternative embodiment, before replacing the variables in the expression with the target number whose numerical format is consistent with the type of the variable, it further includes:
[0020] Match a target detection strategy according to the type of the calculation formula corresponding to the expression to perform error detection on the variables and the target number of the expression;
[0021] If the error detection is passed, perform the operation of replacing the variables in the expression;
[0022] If the error detection is not passed, issue an alarm.
[0023] In an alternative embodiment, the target detection strategy includes:
[0024] Determine whether the variables included in the expression are all the variables required to be included in the calculation formula, and determine whether the variables in the expression are predefined variables;
[0025] and / or, determine whether the value or unit of the number is the target value;
[0026] and / or, determine whether the dependency relationship corresponding to the variables in the expression is the target dependency relationship.
[0027] In an alternative embodiment, the preset manner includes: filling the calculation result into a target position in the image data, or displaying the calculation result through an interface.
[0028] In a second aspect, the present application provides a document digitization processing apparatus, including:
[0029] An identification module, configured to obtain image data of a paper document, and extract text information in the image data based on a character recognition algorithm;
[0030] A screening module, configured to screen out target numbers for meeting calculation requirements if it is determined that the text information contains numbers;
[0031] A calculation module, configured to calculate the target numbers based on a preset calculation formula to obtain a calculation result, and display the calculation result in a preset manner;
[0032] A digitization module, configured to generate an electronic document according to the text information.
[0033] In a third aspect, the present application provides a computer device, which includes a processor and a memory. The memory stores a computer program, and the processor is configured to execute the computer program to implement the foregoing document digitization processing method.
[0034] In a fourth aspect, the present application provides a computer storage medium, which stores a computer program. When the computer program is executed on a processor, the foregoing document digitization processing method is implemented.
[0035] The embodiments of the present application have the following beneficial effects:
[0036] The embodiments of the present application provide a document digitization processing method, which includes: obtaining image data of a paper document, extracting text information in the image data based on a character recognition algorithm; if it is determined that the text information contains numbers, screening out target numbers for meeting calculation requirements; calculating the target numbers based on a preset calculation formula to obtain a calculation result, and displaying the calculation result in a preset manner; generating an electronic document according to the text information. In the process of digitizing a paper document, the embodiments of the present application screen out numbers for meeting calculation requirements from the corresponding text information of the document, and then calculate these numbers according to a preset calculation formula. This means that the document digitization process in the present application is not limited to the conversion of images or texts, but also involves the extraction and calculation of the data contained therein, so that the finally generated electronic document can be directly applied to scenarios such as financial statements and statistical data, enhancing the application value of document digitization, and at the same time improving the efficiency of document management and utilization. Brief Description of the Drawings
[0037] To more clearly illustrate the technical solutions of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the protection scope of the present application. For those of ordinary skill in the art, without creative efforts, other relevant drawings can also be obtained based on these drawings.
[0038] Figure 1 Shows a schematic structural diagram of a document digitization processing system in an embodiment of the present application;
[0039] Figure 2 Shows a schematic flowchart of a document digitization processing method in an embodiment of the present application;
[0040] Figure 3 Shows a schematic structural diagram of a digitization module in a document digitization processing device in an embodiment of the present application. Detailed Description of the Embodiments
[0041] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some, rather than all, of the embodiments of the present application.
[0042] Generally, the components of the embodiments of the present application described and illustrated in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application claimed, but merely represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts fall within the protection scope of the present application.
[0043] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are only intended to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0044] In addition, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and should not be understood as indicating or implying relative importance.
[0045] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present application pertain. The terms (such as those defined in a general use dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning unless clearly defined in various embodiments of the present application.
[0046] The following will describe in detail some embodiments of the present application with reference to the accompanying drawings. Without conflict, the following embodiments and the features in the embodiments may be combined with each other.
[0047] The present application provides an intelligent document digital processing system (hereinafter may be simply referred to as the system), which is used to convert paper documents into electronic documents and perform other operations on the electronic documents, such as formula calculation, etc. This embodiment realizes the full-automatic processing from document collection to recognition and management, automatically and efficiently and accurately converts paper documents into electronic documents, thus eliminating the need for manual entry, significantly reducing labor costs, and reducing errors caused by manual entry operations, which helps to realize the digitization of paper documents, promotes the informatization and automation of business processes, and improves the efficiency of document management, retrieval and utilization; furthermore, the system can be efficiently applied to enterprises or institutions that need to process a large number of paper documents, such as banks, libraries, archives, etc.
[0048] Among them, the system can execute a document digital processing method based on an internal computing program to realize the digital processing of paper documents and obtain electronic documents. In this process, a module can be correspondingly set inside the system for each function realized by this method. In other words, the system can realize one or more functions through the corresponding modules set inside. That is, when the system is running, each module is used to execute one or more steps of the document digital processing method. Among them, the module can be a hardware module or device, or a programmed software function module, and this embodiment does not limit this.
[0049] Exemplarily, as Figure 1 shown, the system includes an image acquisition module 110, an image preprocessing module 120, a character recognition module 130, and an information management module 140; among them, the image acquisition module 110 is used to acquire image data of paper documents; the image preprocessing module 120 is used to optimize the image quality and improve the recognition accuracy; the character recognition module 130 is used to extract text information in the image; the information management module 140 is used to manage and store the recognized text information, and can also perform corresponding processing according to the text information, such as formula calculation, etc.
[0050] Further, during the operation of the system in executing the document digitization method for digitizing paper documents, referentially, as Figure 2 shown, the system can execute the following steps:
[0051] S210, obtain the image data of the paper document, and based on the character recognition algorithm, extract the text information from the image data.
[0052] In this embodiment, the image acquisition module of the system can collect the image data of the paper document by uploading local or camera and other devices. Among them, the paper document includes but is not limited to single-page or multi-page documents such as contracts, bills, invoices, handwritten documents, etc.
[0053] Further, the image preprocessing module further performs preprocessing operations of image enhancement on the image data collected by the image acquisition module, including but not limited to denoising, grayscale conversion, binarization, skew correction, etc., to ensure that the image data is clear and not blurred.
[0054] Exemplarily, the image preprocessing module first performs denoising processing on the image data through a preset denoising algorithm to remove noise points and impurities in each image, ensuring that the text part is clearer; then converts the denoised color or multi-gray image into a grayscale image to simplify the image data and reduce the subsequent calculation amount; then performs binarization processing on the grayscale image to convert the grayscale image into a black-and-white image, highlighting the contrast between the text and the background in the image, making the character edges clearer; then, automatically detect the text direction in the grayscale image and correct it according to the text direction, so that the text in each image is horizontally arranged, facilitating subsequent character recognition; during this process, the system can also automatically optimize and adjust the processing parameters (such as denoising algorithms, etc.) in the image preprocessing module according to the document type corresponding to the original paper document in advance. For example, if the image data is an image under a complex background, automatically match a denoising algorithm with stronger denoising ability, etc. Among them, the preprocessing process can adopt algorithms such as denoising algorithms, grayscale algorithms, text direction detection algorithms, etc. The specific algorithm types and quantities can be set according to actual needs, and this embodiment does not limit this.
[0055] The character recognition module then performs character recognition on the image data output after preprocessing by the image preprocessing module to extract the text information from the image data. Among them, in the character recognition process, character recognition algorithms such as optical character recognition algorithm (OCR) can be adopted, and this embodiment does not limit this.
[0056] In this embodiment, when the character recognition module performs character recognition on the image data, recognition methods such as overall image recognition, radio box recognition, and checkbox recognition can be adopted. Among them, the overall image recognition method can recognize the text content of the image data corresponding to the entire paper document at one time, and this method can be better applied to the case where the document type of the original paper document is a general text document. The radio box recognition method is to receive a specific area selected by the user in the image data (that is, receive a single recognition box), and the character recognition module only performs character recognition on the text information in the area selected by the user. This method is more suitable for the case where the document type of the original paper document is a table or the information to be recognized is a specific text segment. The checkbox recognition method is to receive multiple specific areas selected by the user in the image data (that is, receive multiple recognition boxes), and then the character recognition module performs character recognition on the text information in the multiple recognition boxes selected by the user. This method is also more suitable for the case where the document type of the original paper document is a table or the information to be recognized is a specific text segment.
[0057] The information management module then generates an electronic document based on the text information and image data output by the character recognition module after character recognition, so as to realize the digital management and storage of the text information corresponding to the paper document; among them, the format of the generated electronic document includes but is not limited to PDF, Word, Excel, etc. During the digital management process, the information management module can classify the electronic document according to the document type of the original paper document and the content of the recognized text information, which is convenient for subsequent retrieval and archiving; it can also export the text information corresponding to the electronic document separately, and the export format includes but is not limited to PDF, Word, Excel, etc.
[0058] Furthermore, when storing the electronic document and / or text information, the information management module can perform encrypted storage on the electronic document and / or text information to ensure the security of storage.
[0059] In some examples, the system can generate corresponding work logs according to each working process. In other words, work logs can be generated during the digitalization process of paper documents, and subsequent users can trace back each step in the digitalization process of the entire paper document according to the work logs, so as to realize the efficient management of the document digitalization process.
[0060] It can be understood that the system can use technologies such as OCR to automatically identify and extract the numerical part in the text information, and can accurately locate the numerical information in the document. By analyzing the position and format of the numerical information, the system can identify the numbers in the cells and the rows and columns of the table, and then automatically screen out the numbers used to meet the calculation requirements and perform calculations.
[0061] S220, if it is determined that the text information contains numbers, then screen out the target numbers used to meet the calculation requirements.
[0062] S230 calculates the target number based on a preset calculation formula to obtain a calculation result, and displays the calculation result in a preset manner.
[0063] In this embodiment, during the process of digitizing the image data of a paper document, if the text information recognized by the character recognition module contains numbers, it is further determined whether the number part needs to be calculated, that is, it is judged whether the number part involves a calculation requirement; if it involves a calculation requirement, the number part can be calculated to obtain a calculation result; and finally, the generated electronic document after digitization may include the corresponding calculation result, thereby improving the original text information in the paper document.
[0064] Reference can be made that the system first screens out the target numbers for meeting the calculation requirements from the numbers included in the text information obtained based on character recognition, and then calculates according to the preset calculation formula based on the number format and context information of the target numbers to obtain a calculation result. Subsequently, the calculation result can be displayed according to a preset manner, where the preset manner is the display manner of the calculation result, and this embodiment does not limit this, for example, the preset manner can be to fill the calculation result into the target position in the corresponding image data of the original paper document and then display it (that is, fill it into the corresponding position of the electronic document after digitizing the original paper document and display it along with the display of the electronic document), or directly display the calculation result through an interface.
[0065] Obviously, through this automatic calculation function in this embodiment, when it is recognized that the text information contains numbers, it can calculate the numbers for meeting the calculation requirements according to the preset calculation formula, which can significantly improve the document processing efficiency in specific field scenarios such as financial management and data statistics, and avoid the problems of low efficiency and easy errors caused by manual calculation.
[0066] Further, in some examples, the process of screening the target numbers for meeting the calculation requirements in this embodiment can be to recognize the number format corresponding to the numbers in the text information; according to the context information, preset variable type, and / or calculation formula corresponding to the numbers, judge whether the number format corresponding to the numbers meets the preset calculation requirements, and if it is determined that it meets the preset calculation requirements, then determine the number as the target number.
[0067] When presetting calculation formulas internally in the system, in one implementation, calculation formulas can be set according to different types of documents or documents applicable to different application scenarios. That is, a calculation formula is set separately for each specific type of paper document that needs to be digitally processed (for example, if the paper document is a financial statement, a financial calculation formula is set for it; if the paper document is a statistical statement, a statistical calculation formula is set), thereby ensuring that the calculation formula is only applicable to the management of documents of this type or in this application scenario; this formula setting method is applicable to specific types of documents or scenarios with large differences in calculation formula requirements.
[0068] In another implementation, a shared formula library can be preset internally in the system. The shared formula library contains a variety of calculation formulas, and corresponding calculation formulas can be called from the shared formula library for different types of documents. Furthermore, only this one shared formula library needs to be maintained subsequently to achieve the reuse of multiple calculation formulas, which is convenient for scenarios where the formula types are relatively standard and need to be used frequently, such as basic calculation formulas like addition and subtraction, or some complex formulas commonly used in certain industries (such as financial depreciation, exchange rate conversion, etc.).
[0069] In some examples, when setting calculation formulas, calculation formulas and variables in different types of documents can also be customized. By defining variables, the application of general formulas for different types of documents is achieved. That is, for different types of documents with the same defined variables, the same calculation formula containing the variable can be reused. For example, "total sales = unit price * quantity" can be defined, and the system performs dynamic calculations based on the unit price and quantity contained in the text information of each document.
[0070] In one implementation, the system can also receive and save calculation formulas updated by the user (such as new entry, deletion, or editing) to complete the update of the calculation formulas.
[0071] Furthermore, after the system recognizes the text information containing numbers in the image data corresponding to a paper document, it can recognize the number format corresponding to the numbers in the text information; according to the context information, preset variable type, and / or corresponding calculation formula corresponding to the number, it determines whether the number format corresponding to the number meets the preset calculation requirements, that is, filters out the digital part in the text information that needs to be calculated. If it is determined that the number format corresponding to the number meets the preset calculation requirements, then the number is determined as the target number; in other words, the target number is the digital part in the text information that needs to be calculated.
[0072] Among them, the numerical formats of the numerical parts used for calculation include but are not limited to amounts, percentages, etc., and different format categories can be specifically set according to actual requirements. For example, if the system recognizes that the numerical part in the text information is a numerical value containing currency symbols such as "$" and "€", it can determine that the number corresponding to this type of numerical format belongs to the "amount" category; if the recognized numerical part is a numerical value containing the "%" symbol, it can determine that the number corresponding to this type of numerical format belongs to the "percentage" category; if the recognized numerical part does not contain any symbols and is only a pure number, it is determined that the number corresponding to this type of numerical format belongs to an ordinary number, which may meet the preset calculation requirements.
[0073] In some examples, to ensure the reliability of the calculation (such as for ordinary numbers, more accurately judging whether the ordinary number meets the calculation requirements), one or more judgment methods can be used to judge whether the number meets the calculation requirements. For example, according to the context information corresponding to the number in the image data and the calculation formula, if it is determined that the numerical format corresponding to the number meets the calculation rules corresponding to the calculation formula, it is determined that the preset calculation requirements are met; and / or, according to the context information corresponding to the number in the image data and the preset variable type, if it is determined that the numerical format corresponding to the number is consistent with the preset variable type, it is determined that the preset calculation requirements are met. That is, when any one of the above two conditions is met, it can be determined that the number meets the calculation requirements, and the number needs to be substituted into the corresponding calculation formula for calculation.
[0074] Exemplarily, if it is necessary to implement intelligent recognition and distinguish which numerical formats need to be calculated, the system first recognizes and classifies the numerical formats, and then judges whether these numbers need to participate in the calculation (that is, whether they meet the calculation requirements) according to the set calculation formula. In this process, in the formula library or the context information corresponding to the numerical part, in combination with the preset calculation formula and the calculation requirements, the system needs to judge which numerical formats will be used for calculation, specifically by checking whether each number conforms to certain specific formula rules (for example: total amount * percentage, discount * unit price, etc.). For example, if the preset calculation formula involves the calculation of "amount" and "percentage", the system then determines whether the recognized number is in the numerical format of amount or percentage. If it is determined that the number is in the corresponding numerical format, it is determined that the number matches the corresponding calculation formula, that is, the number needs to be calculated; otherwise, it does not match and there is no need to calculate the number.
[0075] Correspondingly, the system can also combine context information and calculation formulas or variables set in different document types to determine whether the corresponding numerical part needs to be calculated. That is, when setting the calculation formula, the numerical types or symbols that need to be calculated are specified in advance (such as specifying that the variables in the calculation formula are numerical values containing "$"). Then, when it is determined that the recognized number is a numerical value containing the specified numerical type or symbol (such as "$"), it is determined that the calculation requirement is met.
[0076] In addition, the system can directly match the corresponding numbers from the text information according to the variable types set in the calculation formula. For example, if the calculation formula is set as "amount * percentage", the system will extract the numerical part containing the "amount" type from the text information, that is, the number with "$" extracted from the text information. Similarly, "percentage" is the numerical value with "%" in the text information. Then, these formatted data are incorporated into the calculation formula for calculation.
[0077] For example, if the numerical part contained in the text information is "total amount: $200, discount: 10%", and the set calculation formula is: discounted amount = total amount * (1 - discount). Then, based on this calculation formula, the system can recognize that "$200" is a specific amount value belonging to the amount category in the text information, and recognize that "10%" is a percentage belonging to the percentage category, and then substitute them into the calculation formula for adaptive calculation.
[0078] When the system performs calculations, it first parses the preset calculation formula to parse each calculation formula into corresponding expressions, where each expression includes variables and operators; then, it replaces the variables in the expression with target numbers whose numerical formats are consistent with the types of the variables in the expression; and performs calculations using the expression after variable replacement.
[0079] Exemplarily, after the system recognizes and determines the numbers that need to be calculated, it first obtains and parses the calculation formula, where the calculation formula usually contains numerical markers (such as amount, discount) and operators (such as multiplication, addition, etc.). By parsing the formula, it is convenient for the system to directly replace the variables (such as total amount and discount) in the formula with the actually extracted numerical values in the subsequent steps, in other words, replace the corresponding variables in the calculation formula with numbers in the corresponding numerical formats.
[0080] Furthermore, after parsing the calculation formula, extract the numerical parts from the text information that match the variables in the calculation formula. First, identify the relevant numerical regions in the text information, such as "$200" and "10%", and then parse the corresponding numerical parts into numerical values. That is, parse "$200" into the numerical value 200 and "10%" into 0.1, representing the discount rate. In short, convert the identified numerical parts into a format suitable for calculation (e.g., numeric type).
[0081] Then, the system substitutes the processed numerical values into the calculation formula to replace the variables in the calculation formula. For example, the calculation formula is: discounted amount = total amount * (1 - discount). The system replaces "total amount" with 200 and "discount" with 0.1. Consequently, the expression of the formula is converted to: discounted amount = 200 * (1 - 0.1).
[0082] Furthermore, based on the formula after replacing the variables above, perform the specific mathematical calculation: 200 * 0.9 = 180 to obtain the discounted amount (i.e., the calculation result), and then return the calculation result to the front end to display the calculation result in a preset manner, such as directly displaying it by highlighting or presenting it to the user in the form of automatic filling within the text information. Additionally, the user can modify and confirm the calculation result according to actual needs.
[0083] It should be noted that if there are multiple calculation formulas to be calculated during the digital processing of this paper document, it is possible to set to execute each calculation formula sequentially or execute multiple calculation formulas simultaneously. The specific calculation method and process can be set according to actual needs, and this embodiment does not limit this.
[0084] In this embodiment, the system can support the recognition of multiple digital formats, such as integers, decimals, currency units, percentages, etc., to ensure applicability to diverse digital scenarios. And after the calculation formula is set up, it can immediately calculate the numbers in the recognized text information that meet the calculation requirements and display the calculation results on the interface in real time. The user can view the calculation results of each step; this interface also provides a highlighting function to facilitate the user to quickly confirm the correctness of the data. Additionally, the user can further adjust and edit the calculation results, modify or replace the formula parameters. The system will receive the adjusted data input by the user, identify the parameters to be modified, modify the calculation formula, and automatically recalculate according to the modified formula to ensure dynamic update of the results. Specifically, after the user modifies the formula parameters, the system receives the modified data, identifies and modifies the parameters to be modified, updates the internal data according to the modified parameters. Then re-parse the formula, replace the corresponding variables in the formula, and check the legality of the formula; finally, perform the calculation, update the calculation results, and then return the new calculation results to the front end to dynamically update and display the latest calculation results.
[0085] Furthermore, the system can ensure that when the user modifies the formula parameters, the calculation results can be updated in real-time and dynamically. And the calculation results can be displayed or exported in different formats, such as tables, charts, text, etc. The user can save the calculation results as files such as PDF, Excel, Word, etc., or directly embed them into other systems for subsequent data analysis or archiving. Moreover, the system can save the historical records of each calculation. The user can view the past calculation results at any time and compare them with the current data to help analyze the data change trend.
[0086] In practical applications, some potential errors may be accidentally introduced when setting the formula. These errors will not only affect the final calculation results but may also cause the system to crash or the calculation to be inaccurate. Therefore, the system needs to have an automatic error detection mechanism to identify these potential problems and remind the user to make corrections.
[0087] In one example, this embodiment can also match the target detection strategy according to the type of the calculation formula corresponding to the expression to perform error detection on the variables and target numbers of the expression; if it is determined that the error detection is passed, the operation of replacing the variables in the expression is performed; if it is determined that the error detection is not passed, an alarm is issued. Furthermore, through this error detection mechanism, potential problems are identified and then changed in a timely manner to ensure the reliability of the calculation results.
[0088] Exemplarily, the target detection strategy may include but is not limited to: determining whether the variables included in the expression are all the variables required to be included in the calculation formula and determining whether the variables in the expression are predefined variables; and / or, determining whether the value of the number replacing the target variable in the calculation formula or the unit or digital format of the number is the target value; and / or, determining whether the dependency relationship corresponding to the variables in the expression is the target dependency relationship. Among them, the target detection strategy is a combination of one or more of the above-listed strategies, and the strategy can also be adjusted accordingly according to actual needs, and this embodiment does not limit this.
[0089] As a feasible implementation manner, the corresponding detection strategy can be set according to relatively common error types.
[0090] In one example, if the type of the calculation formula is division, if the divisor is zero in the division operation, it will cause the calculation to fail or be abnormal. Therefore, it can be combined with the strategy of determining whether the value of the number replacing the target variable in the calculation formula is the target value in the target detection strategy for detection. The target value is set to 0. If it is determined that the value of the number corresponding to the replaced divisor variable is zero, it is determined that the error detection is not passed, and the corresponding alarm information is output. For example, if the calculation formula is "amount / quantity", if the value corresponding to the variable "quantity" is zero, the system should prompt a division-by-zero error.
[0091] Furthermore, for division formulas, when parsing the formula, the system needs to check the divisor part of the division operator ( / ) involved in the formula. Furthermore, before performing the calculation, the system matches the corresponding detection strategy to check whether all divisors are zero. If it is zero, an error prompt is triggered. Specifically, when parsing the formula, all division operators are identified; if the divisor is zero, the calculation is immediately aborted and the user is prompted, such as outputting the prompt statement "The divisor cannot be zero. Please check the input value."
[0092] In another example, if the calculation formula involves undefined or invalid variables, it will also cause the calculation to fail or be abnormal. For example, a discount rate may be used in the formula, but the variable is not provided in the formula definition or there is a spelling error. Furthermore, before performing the calculation, the system matches the corresponding detection strategy to check whether the calculation formula contains all the required variables and whether these variables have been predefined (that is, to determine whether the variables included in the expression are all the variables required to be included in the calculation formula and to determine whether the variables in the expression are predefined variables). Before this, a variable dictionary or variable mapping table can be established in advance to track all currently defined variables. If there are undefined variables in the formula, the calculation is aborted and the user is prompted. Specifically, the system first parses all the variables in the formula (such as discount rate, total amount, etc.), and then checks whether these variables are currently defined; if a variable is undefined, the system stops the calculation and outputs the prompt statement "The discount rate variable is undefined. Please check the formula."
[0093] In another example, if the data type of the variable involved in the calculation formula does not match the numerical format of the number that matches the text information, it will also cause the calculation to go wrong. For example, the calculation formula requires a number, but a string or date type is input, resulting in the calculation being unable to execute. Furthermore, when extracting the number used to replace the corresponding variable in the calculation formula from the text information, the system matches the corresponding detection strategy to check whether the data type of each variable is consistent with the numerical format of the number (that is, to determine whether the numerical format of the number replacing the target variable in the calculation formula is the target value, and set the target value as the data type of the target variable). For example, the amount should usually be of the numerical type, the date should be of the date type, and the percentage should be a floating-point value (such as 0.1 represents 10%). For each variable in the formula, it is verified according to the predefined data type. If the data type of the variable does not match the numerical format of the number, the user is prompted to make corrections. Specifically, before performing the calculation, check the data type of each variable and the numerical format of the number. If it is determined that the two do not match, stop the calculation and return an error prompt to remind the user to correct the input format.
[0094] In another example, if the calculation formula involves a circular reference situation, that is, a certain variable in the formula depends on itself, it will also cause calculation errors. For example, in the formula total amount = total amount + tax, this situation will lead to an infinite loop and cannot be solved. Furthermore, when parsing the formula, the system also needs to match the corresponding detection strategy to check the dependency relationship between each variable in the calculation formula to ensure that the formula does not form a circular reference (that is, to determine whether the dependency relationship corresponding to the variables in the expression is the target dependency relationship). In this process, topological sorting in graph theory can be used to detect circular dependencies, or recursive tracking of dependency paths can be utilized. If variable A depends on B, B depends on C, and C depends on A, the system should prompt a circular reference error. Specifically, track the dependency relationship for each variable in the formula. If a certain variable depends on itself, trigger an error and prompt the user.
[0095] In another example, if the units of the variables involved in the calculation formula are inconsistent with the units of the target numbers in the literal information, it will also cause calculation errors. For example, if the amount is in US dollars ($) while other variables are in euros (€), this will lead to deviations in the calculation results. When parsing the formula, the system then checks the units of each variable and the target numbers in the literal information according to the corresponding detection strategy and ensures their consistency (determine whether the unit of the number replacing the target variable in the calculation formula is the target value). For cases involving unit conversion, it can also automatically detect and prompt the user whether unit conversion is required. Specifically, determine whether the unit of the variable in the calculation formula is consistent with the unit of the target number. If the units are inconsistent, prompt the user to perform unit conversion; if the units are consistent, perform the calculation.
[0096] In another example, if the value range of the target numbers in the literal information corresponding to the variables involved in the calculation formula exceeds the reasonable range, it may lead to calculation results that do not conform to reality. For example, discounts are usually between 0% and 100%, and amounts usually cannot be negative. Furthermore, the system needs to match the corresponding detection strategy to verify whether the value of the target number exceeds the predetermined reasonable range. For example, for variables of types such as discounts (0 - 100%), amounts (greater than 0), quantities (greater than 0), etc., check the value of the target number according to the set value range. If the value of the target number is not within the reasonable range of the corresponding type, abort the calculation and remind the user to modify the value of the target number.
[0097] In another example, if the calculation formula is too complex, it may lead to an overly long calculation time or even be unable to be calculated, especially when it contains a large number of recursions, complex mathematical operations, or extremely large datasets. Furthermore, the system can also set and match corresponding detection strategies to analyze the complexity of the formula, such as checking the depth of recursive nesting, the depth of exponential operations, or detecting whether there are calculations that may cause performance bottlenecks. If the calculation formula is too complex, the system will optimize the performance of the calculation formula or prompt the user that the formula may exceed the reasonable calculation range.
[0098] Exemplarily, calculate the nesting depth of the calculation formula or the amount of mathematical operations used; if it is determined that the nesting depth or the amount of mathematical operations exceeds a preset threshold, it is determined that the calculation formula is too complex or has poor performance, thereby aborting the calculation and prompting the user and suggesting to simplify the formula. Among them, the preset threshold can be set according to actual needs, and no limitation is imposed on this.
[0099] In some examples, when performing the calculation of the corresponding calculation formula after passing the error detection, if the calculation result exceeds the preset numerical range (such as an abnormal amount in a financial statement), the system will also give a warning prompt to help the user discover and correct the problem in a timely manner. That is, the system detects the calculation result obtained from each calculation formula. If it is determined that the calculation result does not meet the preset requirements, an alarm is issued. If the calculation result meets the preset requirements, the calculation result is saved and output.
[0100] S240, generate an electronic document according to the text information.
[0101] In the digital processing process of a paper document, if the corresponding calculation is completed, an electronic document is generated based on the calculation result together with all the text information that has been recognized in the paper document; among them, the calculation result can be directly filled into the target position of the electronic document, and the target position can be a blank position predefined in the paper document or a position customized by the system in the electronic document.
[0102] Or, an electronic document is generated only based on all the text information that has been recognized in the paper document, and the calculation result can be output or displayed in other preset ways. For example, one or more electronic documents containing only the calculation result can be generated, and the electronic document containing the calculation result is associated with the electronic document containing the text information.
[0103] In this embodiment, the generation form and generation method of the electronic document are not limited. This embodiment can be set according to actual needs. In addition, this embodiment also does not limit the generation process and generation result of generating the electronic document from the calculation result and the text information. Specifically, it can be set according to actual needs whether to generate only one electronic document or multiple electronic documents.
[0104] It can be understood that this embodiment can support the digital processing of multiple documents in batch. While processing the documents in batch, corresponding digital calculations are automatically performed, and a comprehensive calculation report is generated, which is applicable to large-scale financial or statistical processing tasks. During this process, the system can automatically execute digital calculations according to preset time or trigger conditions. For example, users can set to automatically process a certain type of financial statement daily and generate calculation results. Through the automated calculation function, the system can significantly improve the efficiency of digital calculations in document processing, reduce manual calculation errors, and is simple and intuitive to operate, applicable to various document processing scenarios.
[0105] Please refer to Figure 3 , this embodiment of the present application also provides a document digital processing device. Exemplarily, the device includes:
[0106] An identification module 310, configured to obtain image data of a paper document and extract text information in the image data based on a character recognition algorithm;
[0107] A screening module 320, configured to screen out target numbers for meeting calculation requirements if it is determined that the text information contains numbers;
[0108] A calculation module 330, configured to calculate the target numbers based on a preset calculation formula to obtain a calculation result, and display the calculation result in a preset manner;
[0109] A digitalization module 340, configured to generate an electronic document according to the text information.
[0110] It can be understood that the document digital processing device in this embodiment corresponds to the document digital processing method in the above embodiment. The optional items in the above embodiment are also applicable to this embodiment, so they will not be repeated here.
[0111] The present application also provides a computer device. Exemplarily, the computer device includes a processor and a memory. Among them, the memory stores a computer program, and the processor runs the computer program to enable the computer device to execute the above-mentioned document digital processing method or the functions of each module in the above-mentioned document digital processing device.
[0112] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0113] The memory can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. Among them, the memory is used to store a computer program, and after receiving an execution instruction, the processor can execute the computer program accordingly.
[0114] The present application also provides a computer storage medium for storing the computer program used in the above computer device. Among them, the computer storage medium can be a readable storage medium, a non-volatile storage medium, or a volatile storage medium. For example, the computer storage medium can include, but is not limited to: USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs, etc., which are various media that can store program codes.
[0115] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structure diagram and / or flowchart, as well as the combination of blocks in the structure diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0116] In addition, in each embodiment of the present application, the various functional modules or units can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0117] If the above functions are implemented in the form of software function modules and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.
[0118] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered by the protection scope of the present application.
Claims
1. A method for document digital processing, characterized in that Including: Obtain the image data of a paper document, and based on an optical character recognition algorithm, extract the text information in the image data; If it is determined that the text information contains numbers, then screen out the target numbers for meeting the calculation requirements; Based on a preset calculation formula, calculate the target numbers to obtain a calculation result, and display the calculation result in a preset manner; Generate an electronic document according to the text information.
2. The document digitization processing method according to claim 1, wherein The screening out the target numbers for meeting the calculation requirements includes: Identify the number format corresponding to the numbers in the text information; When it is determined that the number format corresponding to the number meets the preset calculation requirements according to the context information corresponding to the number, the preset variable type, and / or the calculation formula, determine the number as the target number.
3. The document digitization processing method according to claim 2, characterized in that, The process of determining that the number format corresponding to the number meets the preset calculation requirements according to the context information corresponding to the number, the preset variable type, and / or the calculation formula includes: According to the context information corresponding to the number in the image data and the calculation formula, if it is determined that the number format corresponding to the number meets the calculation rules corresponding to the calculation formula, it is determined that the preset calculation requirements are met; And / or, according to the context information corresponding to the number in the image data and the preset variable type, if it is determined that the number format corresponding to the number is consistent with the preset variable type, it is determined that the preset calculation requirements are met.
4. The document digitization processing method according to any one of claims 1 to 3, characterized in that, The calculating the target numbers based on a preset calculation formula includes: Analyze the preset calculation formula to parse each calculation formula into an expression, and each of the expressions includes variables and operators; Replace the variables in the expression with the target numbers whose number formats are consistent with the types of the variables; Perform calculations using the expression after variable replacement.
5. The document digitization processing method according to claim 4, wherein Before replacing the variables in the expression with the target numbers whose number formats are consistent with the types of the variables, it further includes: According to the type of the calculation formula corresponding to the expression, match a target detection strategy to perform error detection on the variables and target numbers of the expression; If the error detection is passed, perform the operation of replacing the variables in the expression; If the error detection is not passed, issue an alarm.
6. The document digitization processing method according to claim 5, wherein The target detection strategy includes: Determine whether the variables included in the expression are all the variables required to be included in the calculation formula, and determine whether the variables in the expression are predefined variables; And / or, determine whether the value or unit of the number is a target value; And / or, determine whether the dependency relationship corresponding to the variables in the expression is a target dependency relationship.
7. The document digitization processing method according to claim 1, characterized in that The preset manner includes: filling the calculation result into a target position in the image data, or displaying the calculation result through an interface.
8. A document digital processing device, characterized in that, Including: An identification module, configured to obtain the image data of a paper document, and based on an optical character recognition algorithm, extract the text information in the image data; A screening module, configured to screen out the target numbers for meeting the calculation requirements if it is determined that the text information contains numbers; A calculation module, configured to calculate the target number based on a preset calculation formula to obtain a calculation result, and display the calculation result in a preset manner; A digitization module, configured to generate an electronic document according to the text information.
9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the document digitization processing method according to any one of claims 1-7.
10. A computer storage medium, characterized in that, It stores a computer program, and when the computer program is executed on a processor, it implements the document digitization processing method according to any one of claims 1-7.
Citation Information
Cited By
Numerical calculation proofreading method and system, storage medium and electronic equipment
CN121117195A