Document processing method and device, storage medium, and electronic device
Through technologies such as image correction, text recognition and correction processing, the problem of OCR recognition errors in real estate project prediction reports is solved, the accuracy and efficiency of document processing are improved, and automated text unification and accuracy are achieved.
Patent Information
- Application Number
- CN202111295323.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-11-03
AI Technical Summary
The existing OCR table recognition technology has problems such as text recognition errors, mixed seal text, misaligned table structures and incomplete recognition of formats when processing forecast drawing reports for real estate projects, resulting in inefficient manual entry and prone to errors.
Use image correction processing, text recognition processing, text correction processing, normalization processing and composite verification processing methods, including noise removal, watermark removal, direction correction, text detection and recognition, text correction, format conversion and name standardization to improve documents Processing accuracy and efficiency.
It significantly improves the recognition accuracy of pre-drawn documents, reduces manual entry errors, provides an automated and intelligent text unification method, and improves the efficiency and accuracy of business processing.
Smart Images

Figure CN114005107B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a document processing method and device, a computer-readable storage medium, and an electronic device. Background Art
[0002] The project development process is carried out in stages, and different stages will produce different indicator data for use by other functions. In particular, the forecasting and drawing stage of real estate projects will produce the project's forecasting and drawing reports. The number of such forecasting and drawing reports is large, and most of them are paper versions, which are not easy to process online.
[0003] In response to the needs of parsing and structured data processing of forecasting reports in real estate projects, the existing OCR (Optical Character Recognition) table recognition technology almost always has some text recognition errors for surveying and mapping reports, mixed seal text in the recognition results, misaligned table structure or incomplete recognition of table format, etc., and it is impossible to save the table format of the test report while recognizing the table text. Therefore, when operators manually or use public cloud table OCR services to enter or extract content information in spreadsheets or PDF (Portable Document Format) documents into computers, and then compare and match them one by one with the existing model indicators in the computer, it not only consumes a lot of manpower, but also has low efficiency. Due to the large amount of data, there is a possibility of input errors in manual input verification, and even if public cloud services are used for information extraction, there are still inconsistent formats. The recognition capabilities of public clouds are limited, and the results are easily affected by the quality and content of PDF documents, resulting in recognition errors, which brings inconvenience to input.
[0004] In view of this, there is an urgent need in the art to develop a new document processing method and device.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the present disclosure is to provide a document processing method, a document processing device, a computer-readable storage medium and an electronic device, thereby overcoming the technical problems of poor document processing effect and low information entry efficiency caused by the limitations of related technologies at least to a certain extent.
[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0008] According to a first aspect of an embodiment of the present invention, there is provided a document processing method, the method comprising:
[0009] Acquire a predicted drawing document, and perform image correction processing on the predicted drawing document to obtain a corrected document;
[0010] Performing text recognition processing on the corrected document to obtain document text, and performing text correction processing on the document text to obtain corrected text;
[0011] The corrected text is normalized to obtain a standard text, and the standard text is compound-checked to obtain a target text.
[0012] In an exemplary embodiment of the present invention, the step of performing image correction processing on the predicted drawing document to obtain a corrected document includes:
[0013] Performing noise removal processing on the predicted drawing document to obtain a denoised document;
[0014] Performing watermark removal processing on the denoised document to obtain a watermark-free document;
[0015] Direction correction is performed on the watermark-free document to obtain a corrected document.
[0016] In an exemplary embodiment of the present invention, the step of performing noise removal processing on the predicted drawing document to obtain a denoised document includes:
[0017] A denoising algorithm is used to remove noise from the predicted drawing document to obtain a denoised document.
[0018] In an exemplary embodiment of the present invention, the step of performing watermark removal processing on the denoised document to obtain a watermark-free document includes:
[0019] Using a watermark detection algorithm to perform watermark recognition processing on the denoised document to obtain a watermark image, and performing color space conversion on the watermark image to obtain a converted watermark image;
[0020] Performing color recognition processing on the converted watermark image to obtain the watermark color of the converted watermark image;
[0021] The converted watermark image is subjected to layer expansion processing according to the watermark color to obtain the image to be removed, and the image to be removed is subjected to threshold processing in the denoising document to obtain a watermark-free document.
[0022] In an exemplary embodiment of the present invention, the step of performing direction correction processing on the watermark-free document to obtain a corrected document includes:
[0023] Performing direction recognition processing on the watermark-free document using a text direction recognition model to determine the text direction of the watermark-free document;
[0024] The document direction of the watermark-free document is changed according to the text direction to obtain a corrected document.
[0025] In an exemplary embodiment of the present invention, the step of performing text recognition processing on the corrected document to obtain the document text includes:
[0026] Performing text detection processing on the corrected document using a text detection model to obtain a text box in the corrected document;
[0027] The composite neural network model is used to perform text recognition processing on the text box to obtain the document text.
[0028] In an exemplary embodiment of the present invention, the step of performing text recognition processing on the text box using a composite neural network model to obtain the document text includes:
[0029] Performing feature extraction processing on the text box to obtain image features;
[0030] Performing time series feature conversion on the image features to obtain time series features;
[0031] The temporal features are subjected to feature integration processing to obtain document text.
[0032] In an exemplary embodiment of the present invention, the step of performing text correction processing on the document text to obtain a corrected text includes:
[0033] Obtaining a text score corresponding to the document text, and obtaining a score threshold corresponding to the text score;
[0034] Obtaining standard surveying and mapping terms according to a comparison result between the text score and the score threshold, and performing similarity distance calculation between the document text and the standard surveying and mapping terms to obtain a text distance;
[0035] Based on the text distance, the document text is subjected to text replacement processing using the standard surveying and mapping terminology to obtain a corrected text.
[0036] In an exemplary embodiment of the present invention, the step of normalizing the corrected text to obtain a normalized text includes:
[0037] Performing format conversion processing on the corrected text to obtain a target format text;
[0038] Performing unified typeset processing on the target format text to obtain a unified typeset text;
[0039] The uniform typesetting text is processed by name standardization to obtain a standard text.
[0040] In an exemplary embodiment of the present invention, the step of performing a composite verification process on the standard text to obtain a target text includes:
[0041] Performing household information verification on the standard text to obtain a household information text, and obtaining a model indicator document corresponding to the prediction drawing document;
[0042] The model indicator document is used to perform comparison and matching processing on the user information text to obtain the target text.
[0043] According to a second aspect of an embodiment of the present invention, there is provided a document processing device, characterized in that it includes:
[0044] An image correction module is configured to obtain a predicted drawing document and perform image correction processing on the predicted drawing document to obtain a corrected document;
[0045] A text generation module is configured to perform text recognition processing on the corrected document to obtain a document text, and perform text correction processing on the document text to obtain a corrected text;
[0046] The standard verification module is configured to perform standardization processing on the corrected text to obtain a standard text, and perform compound verification processing on the standard text to obtain a target text.
[0047] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor and a memory; wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the document processing method in any of the above exemplary embodiments is implemented.
[0048] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the document processing method in any of the above exemplary embodiments is implemented.
[0049] It can be seen from the above technical solutions that the document processing method, document processing device, computer storage medium and electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
[0050] In the method and apparatus provided by the exemplary embodiments of the present disclosure, image correction processing is performed on the predicted drawing document, which can provide an accurate document data basis for text information extraction to the greatest extent, and greatly improve the recognition accuracy of low-quality predicted drawing documents. Furthermore, text recognition processing is performed on the corrected document, which reduces the dependence on the total amount of model training data in the conventional text recognition process and improves the accuracy of text recognition. Furthermore, the corrected text is normalized and compositely verified, which is no longer limited to the extraction of text content, but also pays more attention to the accuracy of text content and design fit, provides an automated and intelligent text unification method and multiple verification methods, reduces the occurrence of errors in target text extraction, and focuses on ensuring the accuracy of text extraction from two aspects: the data itself and the particularity of the field to which the document belongs, thereby also improving the efficiency and speed of business processing.
[0051] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0053] Figure 1 A flowchart schematically illustrates a document processing method in an exemplary embodiment of the present disclosure;
[0054] Figure 2 A flowchart schematically illustrating a method for image correction processing in an exemplary embodiment of the present disclosure;
[0055] Figure 3 A schematic diagram schematically illustrates a flow chart of a method for watermark removal processing in an exemplary embodiment of the present disclosure;
[0056] Figure 4 A schematic diagram schematically illustrates a flow chart of a method for direction correction processing in an exemplary embodiment of the present disclosure;
[0057] Figure 5 A flowchart schematically illustrating a method for text recognition processing in an exemplary embodiment of the present disclosure;
[0058] Figure 6 A flowchart schematically illustrating a method for text recognition processing in an exemplary embodiment of the present disclosure;
[0059] Figure 7A flowchart schematically illustrates a method for text correction processing in an exemplary embodiment of the present disclosure;
[0060] Figure 8 A flowchart schematically illustrating a method for normalization processing in an exemplary embodiment of the present disclosure;
[0061] Fig. 9 A schematic diagram schematically illustrates a flow chart of a method for composite verification processing in an exemplary embodiment of the present disclosure;
[0062] Fig.10 A system architecture diagram schematically illustrates a document processing method in an application scenario in an exemplary embodiment of the present disclosure;
[0063] Fig.11 A system module diagram schematically illustrating a document processing method in an application scenario in an exemplary embodiment of the present disclosure;
[0064] Fig.12 A schematic flow chart of a method for performing text recognition processing on a text box using a composite neural network model in an application scenario in an exemplary embodiment of the present disclosure is schematically shown;
[0065] Fig.13 A schematic diagram schematically shows the structure of a document processing device in an exemplary embodiment of the present disclosure;
[0066] Fig.14 An electronic device for implementing a document processing method in an exemplary embodiment of the present disclosure is schematically shown;
[0067] Fig.15 A computer-readable storage medium for implementing a document processing method in an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0068] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0069] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0070] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0071] The development process of a project is carried out in stages, and different stages will produce different indicator data for use by other functions. In particular, the forecasting stage of real estate projects will produce a forecasting report for the project, which is mostly produced by building and contains various area indicators. For a real estate project, the buildings usually range from dozens to hundreds, and villa projects can even reach thousands, so the number of reports is large. From the form of the report, most of them are paper versions, which are not easy to process online.
[0072] Currently, forecasting reports are transmitted offline, requiring manual input of data into the system based on the contents of the forecasting reports, which is time-consuming, laborious and prone to errors.
[0073] In addition, there is no device on the market that has the same functions as the analysis and structured data processing of forecasting reports in real estate projects. The existing OCR table recognition technology cannot recognize the text in the table while saving the table format of the test report. Experiments have shown that almost all the existing mature public cloud table OCRs have partial text recognition errors, mixed seal text in the recognition results, misaligned table structures, or incomplete recognition of table formats.
[0074] Therefore, based on existing technologies, operators need to manually or use the public cloud spreadsheet OCR service to enter or extract the content information in the spreadsheet or PDF document into the computer. Then they compare and match the existing model indicators in the computer one by one. This comparison and matching method is inefficient and consumes a lot of manpower. According to statistics, it takes more than 10 minutes for a skilled salesperson to complete the information entry and comparison of a building.
[0075] In addition, due to the large amount of data, manual data entry and verification may result in errors. Even if public cloud services are used for information extraction, there are still inconsistencies in the format and limited recognition capabilities of public clouds. As a result, the quality and content of PDF documents may affect recognition errors, which brings inconvenience to data entry.
[0076] In view of the problems existing in the related art, the present invention proposes a document processing method. Figure 1 A flowchart of a document processing method is shown, such as Figure 1 As shown, the document processing method includes at least the following steps:
[0077] Step S110: Obtain a predicted drawing document, and perform image correction processing on the predicted drawing document to obtain a corrected document.
[0078] Step S120: Perform text recognition processing on the corrected document to obtain the document text, and perform text correction processing on the document text to obtain the corrected text.
[0079] Step S130: normalize the corrected text to obtain a standard text, and perform compound verification on the standard text to obtain a target text.
[0080] In an exemplary embodiment of the present disclosure, image correction processing is performed on the predicted drawing document, which can provide an accurate document data basis for text information extraction to the greatest extent, and greatly improve the recognition accuracy of low-quality predicted drawing documents. Furthermore, text recognition processing is performed on the corrected document, which reduces the dependence on the total amount of model training data in the conventional text recognition process and improves the accuracy of text recognition. Furthermore, the corrected text is normalized and compositely verified, which is no longer limited to the extraction of text content, but also pays more attention to the accuracy of text content and design fit, provides an automated and intelligent text unification method and multiple verification methods, reduces the occurrence of errors in target text extraction, and focuses on ensuring the accuracy of text extraction from two aspects: the data itself and the particularity of the field to which the document belongs, thereby also improving the efficiency and speed of business processing.
[0081] The following is a detailed description of each step of the document processing method.
[0082] In step S110, a predicted drawing document is obtained, and image correction processing is performed on the predicted drawing document to obtain a corrected document.
[0083] In the exemplary embodiment of the present disclosure, a forecast report of the project will be generated during the forecast phase of the real estate project. The report is mostly generated by building and contains various area indicators. For a real estate project, the buildings usually range from dozens to hundreds, and villa projects may even reach thousands, so the number of forecast reports is large.
[0084] The document generated by the forecast drawing report is the forecast drawing document. The forecast drawing document may include three formats: Word (Microsoft Word, a word processing application), Excel (Microsoft Excel, a spreadsheet processing application) and PDF.
[0085] Furthermore, image correction processing can be performed on the predicted drawing document in PDF format.
[0086] In an alternative embodiment, Figure 2 A flow chart of a method for image correction processing is shown, as shown in FIG. Figure 2 As shown, the method at least includes the following steps: In step S210, noise removal is performed on the predicted drawing document to obtain a denoised document.
[0087] In an optional embodiment, a denoising algorithm is used to remove noise from the predicted drawing document to obtain a denoised document.
[0088] The denoising algorithm may be a non-local average denoising algorithm.
[0089] The non-local average denoising algorithm is a new denoising technique proposed in recent years. This method makes full use of the redundant information in the image and can preserve the image details to the greatest extent while denoising. The basic idea of the non-local average denoising algorithm is that the estimated value of the current pixel is obtained by weighted averaging the pixels in the image that have similar neighborhood structures to it.
[0090] In theory, the algorithm needs to determine the similarity between pixels in the entire image, that is, each time a pixel is processed, its similarity with all pixels in the image must be calculated. However, considering efficiency issues, two fixed-size windows are set during implementation: the search window and the neighborhood window. The neighborhood window slides in the search window, and the pixel weight is determined based on the similarity between neighbors, so as to remove noise points in the de-noised document and obtain a denoised document.
[0091] In step S220, the denoised document is subjected to watermark removal processing to obtain a watermark-free document.
[0092] In an alternative embodiment, Figure 3 A schematic diagram of a watermark removal process is shown. Figure 3 As shown, the method includes at least the following steps: in step S310, a watermark detection algorithm is used to perform watermark recognition processing on the denoised document to obtain a watermark image, and the watermark image is converted into a color space to obtain a converted watermark image.
[0093] Among them, watermark is a kind of protection information embedded in the carrier file by using computer algorithm. The carrier file can be multimedia, documents and software, etc. By detecting watermark, it can be used for information security protection, anti-counterfeiting traceability, copyright protection and other aspects. However, the existence of watermark will also cause certain obstruction to the content itself, such as documents.
[0094] In this case, the watermark detection algorithm can be used to perform watermark recognition processing on the denoised document. Generally, the watermark detection algorithm can use traditional machine learning algorithms, such as decision trees, logistic regression, and random forests, to identify the watermark image in the carrier file of the denoised document.
[0095] Furthermore, the watermark image may be converted from an RGB (Red Green Blue) color space to an HSV (Hue Saturation Value) color space.
[0096] Among them, the HSV model is often used in computer graphics applications. In various application environments where users must select a color to be applied to a specific graphic element, the HSV color wheel is often used. In it, the hue is represented as a ring, and a separate triangle can be used to represent the saturation and lightness. Generally, the vertical axis of this triangle indicates saturation, while the horizontal axis indicates lightness. In this way, the color can be selected by first selecting the hue in the ring, and then selecting the desired saturation and lightness from the triangle.
[0097] Another way to visualize the HSV model is as a cone. In this representation, hue is expressed as an angle around the central axis of the cone, saturation is expressed as the distance from the center of the cone's cross section to this point, and lightness is expressed as the distance from the center of the cone's cross section to the vertex. Some representations use a hexagonal pyramid. This method is more suitable for displaying the HSV color space in a single object. However, due to its three-dimensional nature, it is not suitable for selecting colors in a two-dimensional computer interface.
[0098] The HSV color space can also be represented as a cylinder similar to a cone, with hue varying along the outer circumference of the cylinder, saturation varying along the distance from the center of the cross section, and lightness varying along the distance from the bottom and top of the cross section. This representation might be considered a more accurate mathematical model of the HSV color space. However, in practice the number of distinguishable levels of saturation and hue decreases as lightness approaches black. Furthermore, computers typically store RGB values with a limited precision range, which constrains accuracy, combined with the limitations of human color perception, making the cone representation more practical in most cases.
[0099] To convert the watermark image from RGB color space to HSV color space, we can assume that (r, g, b) are the red, green, and blue coordinates of a color, respectively, and their values are real numbers between 0 and 1. Let max be equivalent to the maximum of r, g, and b. Let min be equal to the minimum of these values. To find the (h, s, v) value in HSV space, where h∈[0,360) is the hue angle, and s, v∈[0,1] are the saturation and brightness, the calculation is:
[0100] max=max(R,G,B)
[0101] min=min(R,G,B)
[0102] if R=max,H=(GB) / (max-min)
[0103] if G=max,H=2+(BR) / (max-min)
[0104] if B=max,H=4+(RG) / (max-min)
[0105] H=H*60
[0106] if H<0,H=H+360
[0107] V=max(R,G,B)
[0108] S=(max-min) / max
[0109] The value of h is usually normalized to lie between 0 and 360°, and h=0 is used when max=min (i.e. gray) rather than leaving h undefined.
[0110] In step S320, color recognition processing is performed on the converted watermark image to obtain the watermark color of the converted watermark image.
[0111] When the watermark image after the color space conversion is obtained, the converted watermark image can be further subjected to color recognition processing.
[0112] Specifically, a chromaticity value range can be set based on the mean value of the hue value. For example, when the mean value of the hue value of the converted watermark image is calculated to be 50, the chromaticity value range can be set with the hue value fluctuating by 10. That is, the chromaticity value range is 40-60. When the hue value of the watermark image is within the chromaticity value range, it can be determined that the color of the converted watermark image is blue; when the hue value of the watermark image is outside the chromaticity value range, it can be determined that the color of the converted watermark image is non-blue.
[0113] In step S330, the converted watermark image is subjected to layer expansion processing according to the watermark color to obtain the image to be removed, and the image to be removed is subjected to threshold processing in the denoising document to obtain a watermark-free document.
[0114] After the watermark image is determined, the converted watermark image can be subjected to layer expansion processing according to the watermark color.
[0115] Specifically, when the watermark color is blue, the layer of the blue channel of the converted watermark image can be obtained; when the watermark color is red, the layer of the red channel of the converted watermark image can be obtained.
[0116] Further, the watermark layer of the acquired watermark color is copied twice to expand the acquired watermark layer to three channels.
[0117] Furthermore, the converted watermark image expanded to three channels is grayed out, and the converted watermark image is converted into an image to be removed in a grayscale space.
[0118] After obtaining the image to be removed, threshold processing can be performed on the image to be removed in the denoising document.
[0119] Specifically, a threshold is set, for example, it can be 100. When the pixel value of the image to be removed in the denoised document is greater than 100, the pixel value can be converted to 1; when the pixel value of the image to be removed in the denoised document is less than 100, the pixel value can be converted to 0. According to this thresholding method, the image to be removed in the denoised document can be removed to obtain a watermark-free document.
[0120] In this exemplary embodiment, the watermark image in the denoised document is identified through a watermark detection algorithm, and the identified watermark image is further removed to obtain a watermark-free document, thereby achieving the removal effect of watermarks with seals, etc., reducing the occurrence of watermarks blocking the content of the predicted drawing document, and further ensuring the accuracy of the predicted drawing document information extraction.
[0121] In step S230, the direction correction process is performed on the watermark-free document to obtain a corrected document.
[0122] In an alternative embodiment, Figure 4 A flow chart of a method for direction correction processing is shown, as Figure 4 As shown, the method at least includes the following steps: In step S410, a text direction recognition model is used to perform direction recognition processing on the watermark-free document to determine the text direction of the watermark-free document.
[0123] Among them, the text direction recognition model can be a 50-layer residual network (ResNet50) or other network models, and this exemplary embodiment does not make any special limitations on this.
[0124] ResNet (Residual Neural Network) is a neural network proposed by He Kaiming and others. The structure of ResNet can avoid model degradation caused by gradient vanishing or gradient explosion due to the deepening of neural network layers. As the model layers increase, the accuracy of target detection will be improved, or at least will not deteriorate. In the field of image processing, how to achieve the best image processing effect through ResNet network is a technical problem that needs to be solved urgently.
[0125] The idea of ResNet is to assume that there is an optimal network layer involved. Therefore, deep networks are often designed with many redundant layers. It is hoped that these redundant layers can complete the identity mapping to ensure that the input and output of the identity layer are exactly the same. Which layers are identity layers can be determined by the network itself during training.
[0126] The direction judger constructed by ResNet50 is trained by using 7200 pictures with different text directions such as 0 degrees, 90 degrees, 180 degrees and 270 degrees to obtain a trained text direction recognition model.
[0127] Furthermore, the trained text direction recognition model is used to perform direction recognition processing on the acquired watermark-free document to obtain the text direction of the watermark-free document.
[0128] In step S420, the document without watermark is changed in direction according to the text direction to obtain a corrected document.
[0129] When the text direction of the watermark-free document is 90 degrees, 180 degrees or 270 degrees, the document direction of the watermark-free document can also be changed.
[0130] Among them, the affine transformation function warpAffine of opencv is used to realize the arbitrary angle rotation of the watermark-free document to obtain the corrected document.
[0131] Specifically, image text rotation usually obtains the tilt angle of the image during affine transformation, and uses the transformation relationship between the time domain and the frequency domain in Fourier transform to achieve correction of the rotated text.
[0132] The obvious feature of the text of a rotated watermark-free document is the presence of line breaks. When a watermark-free document is rotated, its spectrum in the frequency domain will also rotate. Based on this feature, the DFT (Discrete Fourier Transfor) of the text image is calculated. The result of the DFT transform is that the low frequency is located at the four corners of the boundary, and the high frequency is concentrated in the central area. The low frequency and high frequency are interchanged to achieve the movement of the center. Furthermore, it can be seen that the spectrum of the watermark-free document has an obvious inclined straight line. By calculating the inclination angle of the inclined straight line, the image correction of the watermark-free document can be completed using affine transformation.
[0133] In this exemplary embodiment, the text direction of the watermark-free document is determined by a text direction recognition model to further reverse the document direction of the watermark-free document, thereby preventing the recognition garbled code problem caused by the reversed direction of the watermark-free document and providing a corrected document basis and support for subsequent text recognition processing.
[0134] In step S120, text recognition processing is performed on the corrected document to obtain document text, and text correction processing is performed on the document text to obtain corrected text.
[0135] In an exemplary embodiment of the present disclosure, after the corrected document is obtained, text recognition processing may be performed on the corrected document.
[0136] In an alternative embodiment, Figure 5 A flowchart of a method for text recognition processing is shown in FIG. Figure 5 As shown, the method includes at least the following steps: In step S510, a text detection model is used to perform text detection processing on the corrected document to obtain a text box in the corrected document.
[0137] The text detection model may be a DBnet (Differentiable Binarization) model or other models, which is not particularly limited in this exemplary embodiment.
[0138] DBnet is a segmentation detection algorithm based on adaptive thresholds. In the selection of thresholds, the DB algorithm predicts the threshold at each position of the image through the network instead of using a fixed value, so that the background and foreground can be separated well. However, such an operation will cause the gradient to be non-differentiable during training. In response to this, a differentiable binarization is proposed to solve the non-differentiable problem.
[0139] This also gives the DB algorithm many advantages. Among them, it has good performance on five benchmark datasets, including horizontal, multi-directional, and curved text. It is much faster than previous methods because DB can provide robust binary images, which greatly simplifies the post-processing process. It also performs well using a lightweight backbone. The DB module can be removed during the inference process, so it does not take up additional memory and time consumption.
[0140] In step S520, the composite neural network model is used to perform text recognition processing on the text box to obtain the document text.
[0141] In an alternative embodiment, Figure 6 A flowchart of a method for text recognition processing is shown in FIG. Figure 6 As shown, the method at least includes the following steps: In step S610, feature extraction processing is performed on the text box to obtain image features.
[0142] The feature extraction process can be implemented by CNN (Convolutional Neural Networks, CNN).
[0143] CNN has some advantages that traditional technologies do not have, specifically good fault tolerance, parallel processing and self-learning capabilities. It can handle problems with complex environmental information, unclear background knowledge, and unclear reasoning rules. It allows samples to have large defects and distortions, runs fast, has good adaptive performance, and has high resolution. CNN integrates feature extraction functions into multi-layer perceptrons by restructuring and reducing weights, omitting the complex image feature extraction process before recognition.
[0144] The generalization ability of CNN is significantly better than other methods. Convolutional neural networks have been applied to pattern classification, object detection and object recognition. Convolutional neural networks are used to build pattern classifiers, and convolutional neural networks are used as general pattern classifiers directly for grayscale images.
[0145] CNN is a feedforward neural network that can extract the topological structure from a two-dimensional image and use the back propagation algorithm to optimize the network structure and solve the unknown parameters in the network.
[0146] CNN is a type of multi-layer neural network specially designed to process two-dimensional data. CNN is considered to be the first truly successful robust deep learning method using a multi-layer hierarchical network. CNN reduces the number of trainable parameters in the network by mining the spatial correlation in the data, thereby improving the efficiency of the back-propagation algorithm of the forward propagation network. Because CNN requires very little data preprocessing, it is also considered a deep learning method. In CNN, small areas in the image (also called "local perception areas") are used as the bottom input data in the hierarchy. Information is forward propagated through each layer of the network, and filters are formed in each layer to obtain some significant features of the observed data. Because the local perception area can obtain some basic features, such as the boundaries and corners in the image, this method can provide a certain degree of relative invariance to displacement, stretching and rotation.
[0147] The close connections between layers and spatial information in CNN make it particularly suitable for image processing and understanding, and it can automatically extract rich relevant features from images.
[0148] CNN makes full use of the local characteristics of the data itself by combining local perception areas, shared weights, and spatial or temporal downsampling to optimize the network structure and ensure a certain degree of invariance to displacement and deformation.
[0149] CNN is inspired by the visual neural mechanism and is a multi-layer perceptron designed to recognize two-dimensional or three-dimensional signals. This network structure is highly invariant to deformations such as translation, scaling, and tilt.
[0150] CNN can be used to identify two-dimensional or three-dimensional images that are invariant to displacement, scaling, and other forms of distortion. The parameters of the feature extraction layer of CNN are learned through training data, so it avoids manual feature extraction and learns from training data. Secondly, neurons in the same feature map share weights, which reduces network parameters, which is also a major advantage of convolutional networks over fully connected networks. The special structure of sharing local weights is closer to real biological neural networks, which makes CNN uniquely superior in the fields of image processing and speech recognition. On the other hand, weight sharing also reduces the complexity of the network, and the feature that multi-dimensional input signals (speech, images) can be directly input into the network avoids the process of data re-arrangement during feature extraction and classification.
[0151] CNN is a special deep neural network model. Its special features are reflected in two aspects. On the one hand, the connections between its neurons are not fully connected, and on the other hand, the weights of the connections between some neurons in the same layer are shared (i.e. the same). Its non-fully connected and weight-shared network structure makes it more similar to biological neural networks, reducing the complexity of the network model (which is very important for deep structures that are difficult to learn) and reducing the number of weights.
[0152] CNN is a machine learning model under deep supervised learning. It has strong adaptability and is good at mining local features of data, extracting global training features and classification. Its weight-sharing structure network makes it more similar to biological neural networks, and has achieved good results in various fields of pattern recognition.
[0153] Convolutional neural network is a multi-layer supervised learning neural network. The convolution layer and pool sampling layer of the hidden layer are the core modules to realize the feature extraction function of convolutional neural network. The network model uses the gradient descent method to minimize the loss function to reversely adjust the weight parameters in the network layer by layer, and improves the accuracy of the network through frequent iterative training. The low hidden layer of the convolutional neural network is composed of alternating convolution layers and maximum pool sampling layers, and the high layer is a fully connected layer corresponding to the hidden layer and logistic regression classifier of the traditional multi-layer perceptron. The input of the first fully connected layer is the feature image obtained by feature extraction of the convolution layer and the subsampling layer. The last output layer is a classifier, which can use logistic regression, Softmax regression or even support vector machine to classify the input image.
[0154] The convolutional neural network structure includes convolutional layers, downsampling layers, and fully connected layers. Each layer has multiple feature maps, each of which extracts a feature of the input through a convolution filter, and each feature map has multiple neurons.
[0155] The reason for using the convolution layer is that an important feature of the convolution operation is that the convolution operation can enhance the original signal characteristics and reduce noise.
[0156] The reason for using downsampling is that according to the principle of local correlation of images, subsampling the image can reduce the amount of calculation while maintaining the image rotation invariance.
[0157] The fully connected layer uses the activation value obtained by softmax full connection, which is the image feature extracted by the convolutional neural network.
[0158] In step S620, the image features are converted into time series features to obtain time series features.
[0159] After the CNN network is used to perform feature extraction on the text box to obtain the image features, the image features are also converted into time series features according to the time sequence of the image features to obtain the time series features.
[0160] Among them, the temporal feature conversion of image features can be realized by an RNN (Recurrent Neural Network) network.
[0161] A neural network consists of an input layer, a hidden layer, and an output layer. The output is controlled by an activation function, and the layers are connected by weights. The activation function is determined in advance, so what the neural network model "learns" through training is contained in the "weights."
[0162] The basic neural network only establishes weighted connections between layers. The biggest difference of RNN is that the neurons between layers are also fully connected. In the standard RNN structure, the neurons in the hidden layer also have weights. In other words, as the sequence continues to advance, the previous hidden layer will affect the subsequent hidden layer. Therefore, the RNN network can convert the image features into time series features to obtain time series features.
[0163] In step S630, feature integration processing is performed on the temporal features to obtain the document text.
[0164] Furthermore, a pre-trained language model may be used to perform feature integration processing on the temporal features, wherein the pre-trained language model may be a BERT (Bidirectional Encoder Representation from Transformers, a pre-trained language representation model) model, or other models, which are not specifically limited in this exemplary embodiment.
[0165] The BERT model emphasizes that it no longer uses the traditional unidirectional language model or the shallow splicing of two unidirectional language models for pre-training as in the past, but instead uses a new masked language model (MLM) to generate deep bidirectional language representations. When the BERT paper was published, it mentioned that new results were obtained in 11 NLP (Natural Language Processing) tasks, mainly using MLM to pre-train bidirectional Transformers to generate deep bidirectional language representations. Moreover, after pre-training, only an additional output layer needs to be added for fine-tuning to achieve good performance in a variety of downstream tasks. In this process, there is no need to make task-specific structural modifications to BERT.
[0166] In this exemplary embodiment, a composite neural network model consisting of a CNN network, an RNN network and a BERT model is used to perform text recognition processing on the text box to obtain the document text present in the text box, thereby reducing the workload of information extraction for predicting the document, effectively improving the accuracy of the model, and using the capabilities of the pre-trained language model to reduce dependence on the total amount of training data, thereby improving the speed and efficiency of text recognition.
[0167] After the document text is obtained, since there may be recognition errors in the content of the document text, the document text may also be corrected.
[0168] In an alternative embodiment, Figure 7 A flowchart of a method for text correction processing is shown, such as Figure 7 As shown, the method at least includes the following steps: In step S710, a text score corresponding to the document text is obtained, and a score threshold corresponding to the text score is obtained.
[0169] It is worth noting that when the review neural network model performs feature integration processing on the time series features, in addition to being able to output the document text, it can also output the text score corresponding to the document text. The text score is a parameter that characterizes the recognition accuracy of the document text and is a parameter between 0 and 1.
[0170] Furthermore, a score threshold corresponding to the text score may be obtained. Generally, the score threshold may be 0.5, or other values may be set, which is not particularly limited in this exemplary embodiment.
[0171] In step S720, the standard surveying and mapping terminology is obtained according to the comparison result between the text score and the score threshold, and the similarity distance between the document text and the standard surveying and mapping terminology is calculated to obtain the text distance.
[0172] After obtaining the text score and the corresponding score threshold, the text score can be compared with the score threshold to obtain a comparison result.
[0173] For example, when the text score is 0.8 and the score threshold is 0.5, that is, when the text score is greater than the score threshold, it can be determined that the recognized document text is correct and no text correction processing is required.
[0174] When the text score is 0.3 and the score threshold is 0.5, that is, when the text score is less than or equal to the score threshold, it can be determined that the recognized document text is most likely wrong, so text correction processing can be performed.
[0175] In order to perform text correction processing on the document text, standard surveying and mapping terms can be first obtained. The marked surveying and mapping terms can be all correct surveying and mapping report terms entered into the search library.
[0176] Furthermore, similarity distances are calculated between document text and standard surveying and mapping terms.
[0177] Specifically, the edit distance between the document text and the standard surveying and mapping terms may be calculated.
[0178] Among them, the Minimum Edit Distance (MED) was proposed by Russian scientist Vladimir Levenshtein in 1965, and is therefore named Levenshtein Distance.
[0179] In the fields of information theory, linguistics, and computer science, Levenshtein Distance is an indicator used to measure the similarity between two sequences. In layman's terms, the edit distance refers to the minimum number of single-character edit operations required to convert one word into the other.
[0180] There are only three single-character editing operations defined here, namely Insertion, Deletion, and Substitution.
[0181] In step S730, based on the text distance, standard surveying and mapping terminology is used to perform text replacement processing on the document text to obtain a corrected text.
[0182] After calculating the text distance between the document text and the standard surveying and mapping terminology, the corresponding document text may be replaced with the standard surveying and mapping terminology with the smallest text distance, that is, the highest similarity, to obtain a corrected text.
[0183] In this exemplary embodiment, based on the comparison result between the text score and the score threshold, standard surveying and mapping terminology is further used to perform text replacement processing on the document text to obtain corrected text, thereby reducing the occurrence of typos and other text errors in the extracted target text, and improving the accuracy of extracted information from the perspective of the document text.
[0184] In step S130, the corrected text is normalized to obtain a standard text, and the standard text is compound-checked to obtain a target text.
[0185] In an exemplary embodiment of the present disclosure, after the corrected text is obtained, the corrected text can be normalized. In addition, the predicted drawing documents in Word and Excel formats can also be normalized. Here, the normalized processing flow is explained by taking the corrected text as an example.
[0186] In an alternative embodiment, Figure 8A flow chart of the normalization processing method is shown, Figure 8 As shown, the method includes at least the following steps: In step S810, the corrected text is formatted to obtain a target format text.
[0187] Specifically, the format conversion process may be to convert the corrected text into a target format text in JSON (JavaScript Object Notation, JS object notation) format.
[0188] Among them, JSON is a lightweight data exchange format. It is based on a subset of ECMAScript (js specification developed by the European Computer Association) and uses a text format that is completely independent of programming languages to store and represent data. The simplicity and clear hierarchical structure make JSON an ideal data exchange language. It is easy for people to read and write, and it is also easy for machines to parse and generate, and it effectively improves network transmission efficiency.
[0189] In step S820, the target format text is subjected to unified typesetting processing to obtain a unified typesetting text.
[0190] Since the target format text may have a problem of inconsistent typesetting methods such as horizontal or vertical format, after obtaining the target format text, the target format text may be typeset in a unified manner.
[0191] Specifically, when the horizontal layout of the target format text is in the order of household number, household type, etc., the horizontally formatted target format text is unified into a vertical layout in the form of 1, household; 2, unit number; 3, floor; 4, building area, etc. to obtain a unified layout text.
[0192] In step S830, the uniform typesetting text is subjected to name standardization processing to obtain a standard text.
[0193] After obtaining the unified typesetting text, the name entries involved in the unified typesetting text may be standardized.
[0194] Specifically, the household number or room number in the unified layout text can be unified as household, the negative first floor or negative first floor can be unified as -1, etc. In addition, the name normalization processing here can also include merging different floor areas of the units of the split-level to unify the building area in the unified layout text.
[0195] Therefore, by following this name standardization processing method, a standard text corresponding to the unified typeset text can be obtained.
[0196] In this exemplary embodiment, after a series of standardization processes such as format conversion, typesetting unification and name standardization are performed on the corrected text, the corresponding standard text can be obtained, thereby realizing the standardization of corrected texts in different cities and providing a prerequisite for information integration in different cities.
[0197] After obtaining the standard text, a composite verification process may be performed on the standard text.
[0198] In an alternative embodiment, Fig. 9 A schematic diagram of the process of composite verification processing is shown, Fig. 9 As shown, the method at least includes the following steps: in step S910, household information verification is performed on the standard text to obtain household information text, and a model indicator document corresponding to the prediction drawing document is obtained.
[0199] Specifically, household information verification may be verification of the building area or area relationship in the specification text.
[0200] For example, when checking the building area in the specification text, the building area of 1,000 square meters can be compared with the allowable error range. When the error between 1,000 square meters and 100 square meters exceeds the allowable error range, it can be determined that the building area is abnormal. It can also be that for the specification text with a building area of less than 20 square meters, it is further determined whether the corresponding type recorded in the specification text is a parking space, and when the building area is less than 20 square meters and is not a parking space, the building area is determined to be abnormal.
[0201] When checking the area relationship in the specification text, it can be determined whether the indoor area plus the common area of a unit is equal to the total area of the unit. When the indoor area plus the common area of the unit does not satisfy the area relationship equal to the total area, it can be determined that the area relationship is abnormal.
[0202] By verifying the household information of the standard text, anomalies in the standard text can be identified, and highlighted reminders can be given to business personnel, so that business personnel can make modifications and confirmation to obtain accurate household information text.
[0203] After obtaining the household information text, in order to determine whether the generated household information text meets the design drawing requirements of the designer, the model indicator text corresponding to the prediction drawing document can be further obtained. The model indicator document is a document with the design drawing requirements of the designer. For example, the model indicator document may include design requirements such as the number of households and the area of the same household type.
[0204] In step S920, the user information text is compared and matched using the model indicator document to obtain the target text.
[0205] After obtaining the model indicator document, the model indicator document can be used to perform comparison and matching processing on the user information text.
[0206] Specifically, the number of households and the area of the same type of household included in the household information text may be compared and matched with the number of households and the area of the same type of household included in the model indicator document. When the number of households and the area of the same type of household included in the household information text are the same as the number of households and the area of the same type of household included in the model indicator document, it can be determined that the corresponding content of the household information text is correct and does not need to be modified; when the number of households and the area of the same type of household included in the household information text are different from the number of households and the area of the same type of household included in the model indicator document, the corresponding content of the household information text may be highlighted or otherwise highlighted for business personnel to view and modify, and finally obtain the target text that matches the design requirements.
[0207] In this exemplary embodiment, the final target text is obtained by performing user information verification and comparison matching on the standard text. After the text content is extracted, an automatic double verification can be performed, which not only improves the efficiency of business information extraction, but also greatly improves the accuracy of target text acquisition.
[0208] The document processing method in the embodiment of the present disclosure is described in detail below in conjunction with an application scenario.
[0209] Fig.10 The system architecture diagram of the document processing method in the application scenario is shown as follows: Fig.10 As shown, this system adopts the architecture deployment of Vue (a progressive framework for building user interfaces) front-end framework, flask (a lightweight web application framework written in Python) microservice and docker (an open source application container engine) container, which ensures the speed and stability of service deployment.
[0210] Among them, the middleware is the dependency of the system. Among them, Anaconda (open source Python distribution) provides dependencies for the flask microservice, and the neural networks involved in the document processing method all run on Anaconda. Gunicorn (open source Python server) is the service component of the flask microservice, which provides support for the flask microservice and achieves the effect of expanded operation. Redis (data structure server) can cache the intermediate files generated during the document processing method, such as the target format text, so that the data transmission speed in the document processing method is faster.
[0211] The Bootstrap (front-end framework), Htmls, Css3 (the latest CSS standard), Ajax (Web data interaction method) and Jquery (a fast, small and feature-rich JavaScript library) involved in the front-end UI provide support for the display, transmission and other functions of the Vue front-end framework.
[0212] Https (Hyper Text Transfer Protocol over SecureSocket Layer) and Restful (the design style and development method of network applications) are the protocol layers followed by the front-end and back-end operations.
[0213] Furthermore, Fig.11 The processing logic of the business layer is presented in the form of system modules.
[0214] Fig.11 A system module diagram of a document processing method in an application scenario is shown, such as Fig.11 As shown in the figure, the software system includes a front-end human-computer interaction interface and a back-end business processing service. The back-end business processing service consists of three parts: the preprocessing module, the extraction business logic module and the system controller. The system controller determines the timing scheduling between the preprocessing module and the extraction business logic module as well as the database and manual verification.
[0215] When the system is working, business people can submit forecast drawing documents to this software system through the front-end human-computer interaction interface.
[0216] The submitted prediction drawing document can be security-checked in the front-end human-computer interaction interface to prevent malicious parties without security tokens from accessing it.
[0217] Furthermore, in the front-end human-computer interaction interface, the API provided by Python can be used to identify the document type of the prediction drawing document. Among them, the prediction drawing document can include three formats: Word, Excel and PDF.
[0218] When it is determined that the predicted drawing document is in PDF format, a customized OCR service can be used to perform image correction processing on the predicted drawing document in PDF format.
[0219] Since PDF-formatted predictive drawing documents may be blurred, tilted, or have stamps or paper integrity issues, customized OCR services can be used to remove noise, remove watermarks, and correct the orientation of PDF-formatted predictive drawing documents.
[0220] Specifically, a denoising algorithm is used to remove noise points from the predicted drawing document to obtain a denoised document.
[0221] The denoising algorithm may be a non-local average denoising algorithm.
[0222] Furthermore, the denoised document is subjected to watermark removal processing to obtain a watermark-free document.
[0223] The watermark detection algorithm is used to perform watermark recognition processing on the denoised document to obtain a watermark image, and the watermark image is converted into a color space to obtain a converted watermark image.
[0224] In this case, the watermark detection algorithm can be used to perform watermark recognition processing on the denoised document. Generally, the watermark detection algorithm can use traditional machine learning algorithms, such as decision trees, logistic regression, and random forests, to identify the watermark image in the carrier file of the denoised document.
[0225] Furthermore, the watermark image can be converted from the RGB color space to the HSV color space.
[0226] The converted watermark image is subjected to color recognition processing to obtain the watermark color of the converted watermark image.
[0227] When the watermark image after the color space conversion is obtained, the converted watermark image can be further subjected to color recognition processing.
[0228] Specifically, a chromaticity value range can be set based on the mean value of the hue value. For example, when the mean value of the hue value of the converted watermark image is calculated to be 50, the chromaticity value range can be set with the hue value fluctuating by 10. That is, the chromaticity value range is 40-60. When the hue value of the watermark image is within the chromaticity value range, it can be determined that the color of the converted watermark image is blue; when the hue value of the watermark image is outside the chromaticity value range, it can be determined that the color of the converted watermark image is non-blue.
[0229] The converted watermark image is layer expanded according to the watermark color to obtain the image to be removed, and the image to be removed is thresholded in the denoising document to obtain a watermark-free document.
[0230] After the watermark image is determined, the converted watermark image can be subjected to layer expansion processing according to the watermark color.
[0231] Specifically, when the watermark color is blue, the layer of the blue channel of the converted watermark image can be obtained; when the watermark color is red, the layer of the red channel of the converted watermark image can be obtained.
[0232] Further, the watermark layer of the acquired watermark color is copied twice to expand the acquired watermark layer to three channels.
[0233] Furthermore, the converted watermark image expanded to three channels is grayed out, and the converted watermark image is converted into an image to be removed in a grayscale space.
[0234] After obtaining the image to be removed, threshold processing can be performed on the image to be removed in the denoising document.
[0235] Specifically, a threshold is set, for example, it can be 100. When the pixel value of the image to be removed in the denoised document is greater than 100, the pixel value can be converted to 1; when the pixel value of the image to be removed in the denoised document is less than 100, the pixel value can be converted to 0. According to this thresholding method, the image to be removed in the denoised document can be removed to obtain a watermark-free document.
[0236] Furthermore, the direction of the watermark-free document is corrected to obtain a corrected document.
[0237] The text direction recognition model is used to perform direction recognition processing on the watermark-free document to determine the text direction of the watermark-free document.
[0238] Among them, the text direction recognition model can be a 50-layer residual network.
[0239] The direction judger constructed by ResNet50 is trained by using 7200 pictures with different text directions such as 0 degrees, 90 degrees, 180 degrees and 270 degrees to obtain a trained text direction recognition model.
[0240] Furthermore, the trained text direction recognition model is used to perform direction recognition processing on the acquired watermark-free document to obtain the text direction of the watermark-free document.
[0241] When the text direction of the watermark-free document is 90 degrees, 180 degrees or 270 degrees, the document direction of the watermark-free document can also be changed.
[0242] Among them, the affine transformation function warpAffine of opencv is used to realize the arbitrary angle rotation of the watermark-free document to obtain the corrected document.
[0243] In addition, the customized OCR service can also perform text recognition processing on the corrected document to obtain the document text.
[0244] The corrected document is processed by text recognition to obtain the document text, and the document text is processed by text correction to obtain the corrected text.
[0245] The text detection model is used to perform text detection processing on the corrected document to obtain a text box in the corrected document. The text detection model may be DBnet.
[0246] The composite neural network model is used to perform text recognition processing on the text box to obtain the document text.
[0247] Fig.12 The flowchart of the method of using the composite neural network model to perform text recognition processing on a text box in an application scenario is shown as follows: Fig.12 As shown, feature extraction is performed on the text box to obtain image features. The feature extraction process can be implemented by CNN.
[0248] After obtaining the image features obtained by CNN feature extraction processing, the image features can be converted into time series features to obtain time series features.
[0249] The temporal feature conversion of the image features can be implemented by RNN. Therefore, the image features output by CNN can be input into RNN.
[0250] Then, the temporal features are integrated to obtain the document text.
[0251] Furthermore, the pre-trained language model can be used to perform feature integration processing on the temporal features. The pre-trained language model can be a BERT model. Therefore, the temporal features output by the RNN can be input into the BERT model so that the BERT model outputs the document text.
[0252] A composite neural network model consisting of a CNN network, an RNN network, and a BERT model is used to perform text recognition processing on text boxes to obtain the document text in the text boxes, which effectively improves the accuracy of the model. In addition, the ability of the pre-trained language model is used to reduce dependence on the total amount of training data, thereby improving the speed and efficiency of text recognition.
[0253] It is worth noting that a similar OCR private cloud can be built to implement text detection processing and text recognition processing, and this exemplary embodiment does not specifically limit this.
[0254] After the OCR customized service obtains the document text, since there may be recognition errors in the content of the document text, the recognition result correction module can be used to correct the text of the document.
[0255] Get a text score corresponding to the document text, and get a score threshold corresponding to the text score.
[0256] It is worth noting that when the review neural network model performs feature integration processing on the time series features, in addition to being able to output the document text, it can also output the text score corresponding to the document text. The text score is a parameter that characterizes the recognition accuracy of the document text and is a parameter between 0 and 1.
[0257] Furthermore, a score threshold corresponding to the text score may be obtained. Generally, the score threshold may be 0.5, or other values may be set, which is not particularly limited in this exemplary embodiment.
[0258] The standard surveying and mapping terms are obtained based on the comparison result between the text score and the score threshold, and the text distance is obtained by performing similarity distance calculation between the document text and the standard surveying and mapping terms.
[0259] After obtaining the text score and the corresponding score threshold, the text score can be compared with the score threshold to obtain a comparison result.
[0260] For example, when the text score is 0.8 and the score threshold is 0.5, that is, when the text score is greater than the score threshold, it can be determined that the recognized document text is correct and no text correction processing is required.
[0261] When the text score is 0.3 and the score threshold is 0.5, that is, when the text score is less than or equal to the score threshold, it can be determined that the recognized document text is most likely wrong, so text correction processing can be performed.
[0262] In order to perform text correction processing on the document text, standard surveying and mapping terms can be first obtained. The marked surveying and mapping terms can be all correct surveying and mapping report terms entered into the search library.
[0263] Furthermore, similarity distances are calculated between document text and standard surveying and mapping terms.
[0264] Specifically, the edit distance between the document text and the standard surveying and mapping terms may be calculated.
[0265] Based on the text distance, the document text is replaced using standard surveying and mapping terminology to obtain the corrected text.
[0266] After calculating the text distance between the document text and the standard surveying and mapping terminology, the corresponding document text may be replaced with the standard surveying and mapping terminology with the smallest text distance, that is, the highest similarity, to obtain a corrected text.
[0267] After the corrected text is obtained, the corrected text can be normalized. In addition, the prediction drawing documents in Word and Excel formats can also be normalized. Here, the normalization process is explained by taking the corrected text as an example.
[0268] Specifically, the format adaptation module is used to perform format conversion processing on the corrected text to obtain the target format text. The format conversion processing may be to convert the corrected text into the target format text in JSON format.
[0269] The multi-city format recognition module is used to perform unified typeset processing on the target format text to obtain a unified typeset text.
[0270] Since the target format text may have a problem of inconsistent typesetting methods such as horizontal or vertical format, after obtaining the target format text, the target format text may be typeset in a unified manner.
[0271] Specifically, when the horizontal layout of the target format text is in the order of household number, household type, etc., the horizontally formatted target format text is unified into a vertical layout in the form of 1, household; 2, unit number; 3, floor; 4, building area, etc. to obtain a unified layout text.
[0272] The content extraction module is used to perform name standardization processing on the uniform typesetting text to obtain the standardized text.
[0273] After obtaining the unified typesetting text, the name entries involved in the unified typesetting text may be standardized.
[0274] Specifically, the household number or room number in the unified layout text can be unified as household, the negative first floor or negative first floor can be unified as -1, etc. In addition, the name normalization processing here can also include merging different floor areas of the units of the split-level to unify the building area in the unified layout text.
[0275] Therefore, by following this name standardization processing method, a standard text corresponding to the unified typeset text can be obtained.
[0276] Furthermore, standard household information corresponding to the standard text can be generated in the household information structuring module. The standard household information can generate a unique ID for each household to provide data support for subsequent interconnection with the property management system and the commercial system.
[0277] The user information verification module can perform user information verification on the standard text.
[0278] Specifically, household information verification may be verification of the building area or area relationship in the specification text.
[0279] For example, when checking the building area in the specification text, the building area of 1,000 square meters can be compared with the allowable error range. When the error between 1,000 square meters and 100 square meters exceeds the allowable error range, it can be determined that the building area is abnormal. It can also be that for the specification text with a building area of less than 20 square meters, it is further determined whether the corresponding type recorded in the specification text is a parking space, and when the building area is less than 20 square meters and is not a parking space, the building area is determined to be abnormal.
[0280] When checking the area relationship in the specification text, it can be determined whether the indoor area plus the common area of a unit is equal to the total area of the unit. When the indoor area plus the common area of the unit does not satisfy the area relationship equal to the total area, it can be determined that the area relationship is abnormal.
[0281] By verifying the household information of the standard text, anomalies in the standard text can be identified, and highlighted reminders can be given to business personnel, so that business personnel in the manual verification module can modify and confirm to obtain accurate household information text.
[0282] After obtaining the household information text, in order to determine whether the generated household information text meets the design drawing requirements of the designer, the model indicator text corresponding to the prediction drawing document can be further obtained. The model indicator document is a document with the design drawing requirements of the designer. For example, the model indicator document may include design requirements such as the number of households and the area of the same household type.
[0283] The model indicator document is used to compare and match the user information text to obtain the target text.
[0284] After obtaining the model indicator document, the model indicator document can be used to perform comparison and matching processing on the user information text.
[0285] Specifically, the number of households and the area of the same type of household included in the household information text may be compared and matched with the number of households and the area of the same type of household included in the model indicator document. When the number of households and the area of the same type of household included in the household information text are the same as the number of households and the area of the same type of household included in the model indicator document, it can be determined that the corresponding content of the household information text is correct and does not need to be modified; when the number of households and the area of the same type of household included in the household information text are different from the number of households and the area of the same type of household included in the model indicator document, the corresponding content of the household information text may be highlighted or otherwise highlighted for business personnel to view and modify, and finally obtain the target text that matches the design requirements.
[0286] After obtaining the target text, the target text can be stored in a database to provide data support for subsequent interconnection with a property management system and a commercial system.
[0287] The document processing method in this application scenario performs image correction processing on the predicted drawing document, which can provide an accurate document data basis for text information extraction to the greatest extent, and greatly improve the recognition accuracy of low-quality predicted drawing documents. Furthermore, text recognition processing is performed on the corrected document, which reduces the dependence on the total amount of model training data in the conventional text recognition process and improves the accuracy of text recognition. Furthermore, the corrected text is normalized and compositely verified, which is no longer limited to the extraction of text content, but also pays more attention to the accuracy of text content and design fit, providing an automated and intelligent text unification method and multiple verification methods, reducing the occurrence of errors in target text extraction, and focusing on ensuring the accuracy of text extraction from both the data itself and the particularity of the field to which the document belongs, thereby also improving the efficiency and speed of business processing.
[0288] Furthermore, in an exemplary embodiment of the present disclosure, a document processing apparatus is also provided. Fig.13 A schematic diagram of the structure of a document processing device is shown. Fig.13 As shown, the document processing device 1300 may include: an image correction module 1310, a text generation module 1320 and a standard verification module 1330. Among them:
[0289] The image correction module 1310 is configured to obtain a predicted drawing document and perform image correction processing on the predicted drawing document to obtain a corrected document;
[0290] The text generation module 1320 is configured to perform text recognition processing on the corrected document to obtain the document text, and perform text correction processing on the document text to obtain the corrected text;
[0291] The standard verification module 1330 is configured to perform standardization processing on the corrected text to obtain a standard text, and perform compound verification processing on the standard text to obtain a target text.
[0292] In an exemplary embodiment of the present invention, the step of performing image correction processing on the predicted drawing document to obtain a corrected document includes:
[0293] Performing noise removal processing on the predicted drawing document to obtain a denoised document;
[0294] Performing watermark removal processing on the denoised document to obtain a watermark-free document;
[0295] Direction correction is performed on the watermark-free document to obtain a corrected document.
[0296] In an exemplary embodiment of the present invention, the step of performing noise removal processing on the predicted drawing document to obtain a denoised document includes:
[0297] A denoising algorithm is used to remove noise from the predicted drawing document to obtain a denoised document.
[0298] In an exemplary embodiment of the present invention, the step of performing watermark removal processing on the denoised document to obtain a watermark-free document includes:
[0299] Using a watermark detection algorithm to perform watermark recognition processing on the denoised document to obtain a watermark image, and performing color space conversion on the watermark image to obtain a converted watermark image;
[0300] Performing color recognition processing on the converted watermark image to obtain the watermark color of the converted watermark image;
[0301] The converted watermark image is subjected to layer expansion processing according to the watermark color to obtain the image to be removed, and the image to be removed is subjected to threshold processing in the denoising document to obtain a watermark-free document.
[0302] In an exemplary embodiment of the present invention, the step of performing direction correction processing on the watermark-free document to obtain a corrected document includes:
[0303] Performing direction recognition processing on the watermark-free document using a text direction recognition model to determine the text direction of the watermark-free document;
[0304] The document direction of the watermark-free document is changed according to the text direction to obtain a corrected document.
[0305] In an exemplary embodiment of the present invention, the step of performing text recognition processing on the corrected document to obtain the document text includes:
[0306] Performing text detection processing on the corrected document using a text detection model to obtain a text box in the corrected document;
[0307] The composite neural network model is used to perform text recognition processing on the text box to obtain the document text.
[0308] In an exemplary embodiment of the present invention, the step of performing text recognition processing on the text box using a composite neural network model to obtain the document text includes:
[0309] Performing feature extraction processing on the text box to obtain image features;
[0310] Performing time series feature conversion on the image features to obtain time series features;
[0311] The temporal features are subjected to feature integration processing to obtain document text.
[0312] In an exemplary embodiment of the present invention, the step of performing text correction processing on the document text to obtain a corrected text includes:
[0313] Obtaining a text score corresponding to the document text, and obtaining a score threshold corresponding to the text score;
[0314] Obtaining standard surveying and mapping terms according to a comparison result between the text score and the score threshold, and performing similarity distance calculation between the document text and the standard surveying and mapping terms to obtain a text distance;
[0315] Based on the text distance, the document text is subjected to text replacement processing using the standard surveying and mapping terminology to obtain a corrected text.
[0316] In an exemplary embodiment of the present invention, the step of normalizing the corrected text to obtain a normalized text includes:
[0317] Performing format conversion processing on the corrected text to obtain a target format text;
[0318] Performing unified typeset processing on the target format text to obtain a unified typeset text;
[0319] The uniform typesetting text is processed by name standardization to obtain a standard text.
[0320] In an exemplary embodiment of the present invention, the step of performing a composite verification process on the standard text to obtain a target text includes:
[0321] Performing household information verification on the standard text to obtain a household information text, and obtaining a model indicator document corresponding to the prediction drawing document;
[0322] The model indicator document is used to perform comparison and matching processing on the user information text to obtain the target text.
[0323] The specific details of the above-mentioned document processing device 1300 have been described in detail in the corresponding document processing method, so they will not be repeated here.
[0324] It should be noted that although several modules or units of the document processing device 1300 are mentioned in the above detailed description, such division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units for embodiment.
[0325] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0326] Refer to the following Fig.14 1400 according to this embodiment of the present invention is described. Fig.14 The electronic device 1400 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0327] like Fig.14 As shown, the electronic device 1400 is in the form of a general computing device. The components of the electronic device 1400 may include, but are not limited to: the at least one processing unit 1410, the at least one storage unit 1420, a bus 1430 connecting different system components (including the storage unit 1420 and the processing unit 1410), and a display unit 1440.
[0328] The storage unit stores program codes, which can be executed by the processing unit 1410, so that the processing unit 1410 executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.
[0329] The storage unit 1420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 1421 and / or a cache storage unit 1422 , and may further include a read-only storage unit (ROM) 1423 .
[0330] The storage unit 1420 may also include a program / utility 1424 having a set (at least one) of program modules 1425, such program modules 1425 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0331] Bus 1430 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0332] The electronic device 1400 may also communicate with one or more external devices 1600 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1400, and / or communicate with any device that enables the electronic device 1400 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1450. In addition, the electronic device 1400 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1460. As shown, the network adapter 1460 communicates with other modules of the electronic device 1400 via a bus 1430. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0333] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiment of the present disclosure.
[0334] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible embodiments, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0335] refer to Fig.15 As shown, a program product 1500 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0336] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The 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 (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable 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.
[0337] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a 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.
[0338] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0339] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0340] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A document processing method, characterized in that: The method comprises: Acquire a predicted drawing document, and perform image correction processing on the predicted drawing document to obtain a corrected document; Performing text recognition processing on the corrected document to obtain document text, and performing text correction processing on the document text to obtain corrected text; Performing normalization processing on the corrected text to obtain a standard text, and performing composite verification processing on the standard text to obtain a target text; The step of performing text recognition processing on the corrected document to obtain the document text comprises: Performing text detection processing on the corrected document using a text detection model to obtain a text box in the corrected document; Using a composite neural network model to perform text recognition processing on the text box to obtain document text, including: performing feature extraction processing on the text box to obtain image features; performing time series feature conversion on the image features to obtain time series features; performing feature integration processing on the time series features to obtain document text; The step of performing text correction processing on the document text to obtain a corrected text includes: Obtain a text score corresponding to the document text, and obtain a score threshold corresponding to the text score; obtain standard surveying and mapping terms based on a comparison result between the text score and the score threshold, and perform a similarity distance calculation between the document text and the standard surveying and mapping terms to obtain a text distance; based on the text distance, perform text replacement processing on the document text using the standard surveying and mapping terms to obtain a corrected text.
2. The document processing method according to claim 1, characterized in that: The performing image correction processing on the predicted drawing document to obtain a corrected document includes: Performing noise removal processing on the predicted drawing document to obtain a denoised document; Performing watermark removal processing on the denoised document to obtain a watermark-free document; Direction correction is performed on the watermark-free document to obtain a corrected document.
3. The document processing method according to claim 2, characterized in that: The step of performing noise removal processing on the predicted drawing document to obtain a denoised document includes: A denoising algorithm is used to remove noise from the predicted drawing document to obtain a denoised document.
4. The document processing method according to claim 2, characterized in that: The step of performing watermark removal processing on the denoised document to obtain a watermark-free document comprises: Using a watermark detection algorithm to perform watermark recognition processing on the denoised document to obtain a watermark image, and performing color space conversion on the watermark image to obtain a converted watermark image; Performing color recognition processing on the converted watermark image to obtain the watermark color of the converted watermark image; The converted watermark image is subjected to layer expansion processing according to the watermark color to obtain the image to be removed, and the image to be removed is subjected to threshold processing in the denoising document to obtain a watermark-free document.
5. The document processing method according to claim 2, characterized in that: The step of performing direction correction processing on the watermark-free document to obtain a corrected document includes: Performing direction recognition processing on the watermark-free document using a text direction recognition model to determine the text direction of the watermark-free document; The document direction of the watermark-free document is changed according to the text direction to obtain a corrected document.
6. The document processing method according to claim 1, characterized in that: The step of normalizing the corrected text to obtain a normalized text includes: Performing format conversion processing on the corrected text to obtain a target format text; Performing unified typeset processing on the target format text to obtain a unified typeset text; The uniform typesetting text is processed by name standardization to obtain a standard text.
7. The document processing method according to claim 1, characterized in that: The step of performing compound verification processing on the standard text to obtain the target text includes: Performing household information verification on the standard text to obtain a household information text, and obtaining a model indicator document corresponding to the prediction drawing document; The model indicator document is used to perform comparison and matching processing on the user information text to obtain the target text.
8. A document processing device, characterized in that: include: An image correction module is configured to obtain a predicted drawing document and perform image correction processing on the predicted drawing document to obtain a corrected document; A text generation module is configured to perform text recognition processing on the corrected document to obtain a document text, and perform text correction processing on the document text to obtain a corrected text; A standard verification module is configured to perform standardization processing on the corrected text to obtain a standard text, and perform compound verification processing on the standard text to obtain a target text; The step of performing text recognition processing on the corrected document to obtain the document text comprises: Performing text detection processing on the corrected document using a text detection model to obtain a text box in the corrected document; Using a composite neural network model to perform text recognition processing on the text box to obtain document text, including: performing feature extraction processing on the text box to obtain image features; performing time series feature conversion on the image features to obtain time series features; performing feature integration processing on the time series features to obtain document text; The step of performing text correction processing on the document text to obtain a corrected text includes: Obtain a text score corresponding to the document text, and obtain a score threshold corresponding to the text score; obtain standard surveying and mapping terms based on a comparison result between the text score and the score threshold, and perform a similarity distance calculation between the document text and the standard surveying and mapping terms to obtain a text distance; based on the text distance, perform text replacement processing on the document text using the standard surveying and mapping terms to obtain a corrected text.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the document processing method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to execute the document processing method according to any one of claims 1 to 7 by executing the executable instructions.
Citation Information
Patent Citations
Image correction method and device, and computer readable storage medium
CN108921158A
Structured processing method and device of image, storage medium and electronic equipment
CN111144210A
Text document-based character recognition method and device, equipment and storage medium
CN113569833A
