Document processing method and device, electronic equipment and storage medium
By dividing the electronic document into pieces with overlapping areas, and adjusting and re-identifying when identifying abnormalities, the problem of insufficient processing efficiency and accuracy of electronic document in the prior art is solved, and higher recognition accuracy and reliability are achieved.
Patent Information
- Application Number
- CN202411974204.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
Smart Images

Figure CN119886138A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a document processing method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of information technology, the application scope of electronic documents is becoming more and more extensive. At the same time, in order to efficiently process electronic documents, it has become a common practice to use models (such as machine learning models, deep learning models, etc.) to identify and analyze documents.
[0003] However, in actual application scenarios, we often encounter large electronic documents, which contain hundreds or thousands of pages and are extremely rich in content. Although the model has the ability to handle concurrent tasks, its computing resources are always limited. When the amount of data processing involved in a single concurrent task is too large, it will also affect the processing efficiency of the model and may even damage the recognition accuracy of the model. In view of this, in order to ensure the recognition accuracy of the model while taking into account the recognition efficiency of the model, the relevant technology proposes to split a large document into multiple smaller document fragments, which can be processed independently by the model, and the model recognition results of each of these document fragments can restore the comprehensive recognition results of the entire document.
[0004] It can be seen that document sharding is crucial to improving the overall performance and efficiency of the model. However, the current sharding method is relatively simple and crude, which may lead to errors in model processing results due to unreasonable sharding. There is an urgent need for a method that can reasonably and accurately shard documents. Summary of the invention
[0005] The present application provides a document processing method, device, electronic device and storage medium to provide a method for reasonably and accurately segmenting documents.
[0006] In a first aspect, the present application provides a document processing method, the method comprising:
[0007] Get the target document to be processed;
[0008] Segmenting the target document into a plurality of document fragments, wherein two adjacent document fragments have a partial overlapping area in terms of content;
[0009] Inputting the plurality of document fragments into a document element recognition model to obtain initial model recognition results of the document element recognition model on the plurality of document fragments;
[0010] When it is determined that the initial model recognition results of the multiple document segments have recognition anomalies, the document segments corresponding to the recognition anomalies are adjusted, and the adjusted document segments are re-input into the document element recognition model to obtain the re-model recognition results of the document element recognition model for the adjusted document segments.
[0011] In a possible implementation manner, after dividing the target document into a plurality of document fragments, the method further includes:
[0012] According to the set correction rules, the multiple document fragments are corrected, so as to use the corrected multiple document fragments to execute the step of inputting the multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments.
[0013] In a possible implementation, the correcting the plurality of document fragments according to the set correction rule includes:
[0014] When it is identified that the last paragraph in the document segment ends with a specific symbol, the first N paragraphs in the next document segment of the document segment are adjusted to the document segment; and / or,
[0015] When it is identified that two adjacent document fragments include a continuous numbering interval, the two adjacent document fragments are re-segmented to segment the continuous numbering interval into the same document fragment; and / or,
[0016] When it is identified that the end of the last paragraph in the document segment does not have a punctuation mark, adjusting the first M paragraphs in the next document segment of the document segment to the document segment;
[0017] Wherein, the M and the N are positive integers.
[0018] In a possible implementation, it is determined whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by:
[0019] Obtaining initial model recognition results of partially overlapping areas in two adjacent document fragments;
[0020] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are inconsistent, determining that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0021] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are consistent, determining that there is no recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0022] The step of adjusting the document fragments corresponding to the recognition anomaly includes:
[0023] The two adjacent document fragments are merged into one document fragment.
[0024] In a possible implementation, it is determined whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by:
[0025] Constructing a directory tree of the target document according to the initial model recognition results of the document element recognition model on the multiple document fragments;
[0026] Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments according to the directory tree.
[0027] In a possible implementation manner, determining whether there are recognition anomalies in the initial model recognition results of the plurality of document fragments according to the directory tree includes:
[0028] Identify whether the directory tree has at least one of the following structural abnormal features: there are unnumbered paragraphs or paragraphs with unordered numbers in the directory tree; there are paragraphs with higher levels than the parent paragraphs of the child paragraph interval in the sub-level paragraph interval of the directory tree; the levels of paragraphs in the same numbered continuous paragraph interval in the directory tree are inconsistent;
[0029] In the case where it is identified that the directory tree has at least one of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments have recognition abnormalities; in the case where it is identified that the directory tree does not have any of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments do not have recognition abnormalities;
[0030] The step of adjusting the document fragments corresponding to the recognition anomaly includes:
[0031] The continuous paragraphs in the target document having at least one of the above structural abnormal features are adjusted to the same document segment.
[0032] In a possible implementation, it is determined whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by:
[0033] Determining whether there is a recognition anomaly in the initial model recognition result of the document segment according to the paragraph format attributes of the paragraph in the document segment;
[0034] The step of adjusting the document fragments corresponding to the recognition anomaly includes:
[0035] Adjust the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment.
[0036] In a possible implementation manner, before inputting the plurality of document fragments into the document element recognition model, the method further includes:
[0037] identifying redundant content from paragraphs in the document fragment;
[0038] The step of inputting the plurality of document fragments into the document element recognition model is performed using non-redundant content in the plurality of document fragments, wherein the non-redundant content refers to other content in the document fragments except the redundant content.
[0039] In a second aspect, the present application provides a document processing device, the device comprising:
[0040] A document acquisition module is used to acquire the target document to be processed;
[0041] A document segmentation module, used for segmenting the target document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content;
[0042] A fragmentation recognition module, used for inputting the plurality of document fragments into a document element recognition model to obtain initial model recognition results of the document element recognition model on the plurality of document fragments;
[0043] A secondary fragmentation module, configured to adjust the document fragments corresponding to the recognition anomalies when it is determined that the initial model recognition results of the plurality of document fragments have recognition anomalies;
[0044] The segment recognition module is further used to input the adjusted document segment into the document element recognition model again to obtain a re-model recognition result of the document element recognition model on the adjusted document segment.
[0045] In a possible implementation, the device further includes:
[0046] The correction module is used to correct the multiple document fragments according to the set correction rules after the target document is divided into multiple document fragments.
[0047] In a possible implementation manner, the correction module is specifically used to:
[0048] When it is identified that the last paragraph in the document segment ends with a specific symbol, the first N paragraphs in the next document segment of the document segment are adjusted to the document segment; and / or,
[0049] When it is identified that two adjacent document fragments include a continuous numbering interval, the two adjacent document fragments are re-segmented to segment the continuous numbering interval into the same document fragment; and / or,
[0050] When it is identified that the end of the last paragraph in the document segment does not have a punctuation mark, adjusting the first M paragraphs in the next document segment of the document segment to the document segment;
[0051] Wherein, the M and the N are positive integers.
[0052] In a possible implementation, the device further includes:
[0053] The anomaly recognition module is used to determine whether there are any recognition anomalies in the initial model recognition results of the multiple document fragments.
[0054] In a possible implementation, the abnormality identification module is specifically used to:
[0055] Obtaining initial model recognition results of partially overlapping areas in two adjacent document fragments;
[0056] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are inconsistent, determining that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0057] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are consistent, determining that there is no recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0058] The secondary sharding module is specifically used for:
[0059] The two adjacent document fragments are merged into one document fragment.
[0060] In a possible implementation, the abnormality identification module is specifically used to:
[0061] Constructing a directory tree of the target document according to the initial model recognition results of the document element recognition model on the multiple document fragments;
[0062] Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments according to the directory tree.
[0063] In a possible implementation, the abnormality identification module is specifically used to:
[0064] Identify whether the directory tree has at least one of the following structural abnormal features: there are unnumbered paragraphs or paragraphs with unordered numbers in the directory tree; there are paragraphs with higher levels than the parent paragraphs of the child paragraph interval in the sub-level paragraph interval of the directory tree; the levels of paragraphs in the same numbered continuous paragraph interval in the directory tree are inconsistent;
[0065] In the case where it is identified that the directory tree has at least one of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments have recognition abnormalities; in the case where it is identified that the directory tree does not have any of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments do not have recognition abnormalities;
[0066] The secondary sharding module is specifically used for:
[0067] The continuous paragraphs in the target document having at least one of the above structural abnormal features are adjusted to the same document segment.
[0068] In a possible implementation, the abnormality identification module is specifically used to:
[0069] Determining whether there is a recognition anomaly in the initial model recognition result of the document segment according to the paragraph format attributes of the paragraph in the document segment;
[0070] The secondary sharding module is specifically used for:
[0071] Adjust the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment.
[0072] In a possible implementation, the device further includes:
[0073] a redundancy identification module, configured to identify redundant content from paragraphs in the document fragments before inputting the plurality of document fragments into the document element identification model;
[0074] The fragment identification module is also used to utilize the non-redundant content in the multiple document fragments to execute the step of inputting the multiple document fragments into the document element identification model, and the non-redundant content refers to other content in the document fragments except the redundant content.
[0075] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, wherein the processor is used to execute a document processing program stored in the memory to implement the document processing method described in any one of the first aspects.
[0076] In a fourth aspect, the present application provides a storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the document processing method described in any one of the first aspects.
[0077] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application obtains the target document to be processed, divides the target document into multiple document fragments, wherein two adjacent document fragments have a partial overlapping area in terms of content. The multiple document fragments are input into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments. When it is determined that the initial model recognition results of the multiple document fragments have recognition anomalies, the document fragments corresponding to the recognition anomalies are adjusted, and the adjusted document fragments are input into the document element recognition model again to obtain the re-model recognition results of the document element recognition model for the adjusted document fragments, thereby providing a method for secondary document fragmentation and recognition. The application of this method can effectively reduce the deviation generated by the model when recognizing document fragments, and improve the accuracy and reliability of document element recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0079] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0080] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0081] Figure 1 A schematic diagram of a system architecture involved in an embodiment of the present application;
[0082] Figure 2 A flowchart of an embodiment of a document processing method provided in an embodiment of the present application;
[0083] Figure 3 A flowchart of another document processing method provided in an embodiment of the present application;
[0084] Figure 4A flowchart of another document processing method provided in an embodiment of the present application;
[0085] Figure 5 A diagram comparing the effects of using soft and hard carriage returns for text content.
[0086] Figure 6 A diagram showing the attachment of separators to content and the correct segmentation structure;
[0087] Figure 7 This is a schematic diagram of the segmentation effect of a space character or a tab character;
[0088] Figure 8 This is a schematic diagram showing the effect of text content not being segmented correctly;
[0089] Fig. 9 A schematic diagram of using consecutive blank lines to achieve paging effect;
[0090] Fig.10 A block diagram of an embodiment of a document processing device provided in an embodiment of the present application;
[0091] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0092] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0093] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0094] The present application provides a document processing method, device, electronic device and storage medium to provide a method for reasonably and accurately segmenting documents.
[0095] Figure 1 Schematic diagram of a system architecture involved in an embodiment of the present application. Figure 1As shown, the system architecture 100 may include: a client 101, a server 102, a model 103, and a network 104. The network 104 is used to provide a communication link between the client 101, the server 102, and the model 103, and may include a wireless link, a wired link, or an optical fiber cable, etc., which is not limited in this application.
[0096] The client 101 may be a hardware device or software that supports network connection to provide document editing services and other network services. When the device is hardware, it may support various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, servers, etc. When the device is software, it may be installed in the electronic devices listed above.
[0097] The server 102 is the core processing unit of the entire system architecture 100, and can be deployed with a variety of algorithms and relatively powerful computing resources. Among them, the algorithm may involve multiple fields such as data processing, machine learning, and deep learning, and is used to process the data uploaded or the request sent by the client 101, and perform specific computing tasks, such as document content processing, document content analysis, etc. The computing resources may include high-performance computing clusters, GPU accelerator cards, etc., which are used to support the rapid execution and efficient processing of algorithms.
[0098] The model end 103 is a server or device deployed with one or more models, which are used to process specific computing tasks or provide specific services. For example, a document element recognition model, a natural language processing model, etc. are deployed on the model end 103. Among them, the document element recognition model is used to identify the element type (such as abstract, title, text, etc.) of the paragraph in the input document. When the server end 102 receives the request from the client 101 and needs to call the model, it forwards the request to the model end 103, and the model end 103 uses the deployed model to perform reasoning calculations and outputs the corresponding results. In addition, with the continuous advancement of algorithms and the continuous accumulation of data, the models deployed on the model end 103 can be updated or optimized regularly. Exemplarily, the model end 103 supports automatic updating and version control of the model to ensure that the model can always maintain the latest performance and accuracy. Exemplarily, the server end 102 is responsible for managing the model on the model end 103, including uploading, updating, deleting and version control of the model.
[0099] Understandably, Figure 1 The number of networks and devices in the system architecture 100 is only for illustration. According to actual needs, the system architecture 100 may include any number of networks and devices, which is not limited in the embodiment of the present application.
[0100] In some examples, at least two of the client 101, the server 102, and the model 103 may be the same device, and different terminals in the same device may also transmit data to each other via wireless or wired connections.
[0101] based on Figure 1 In the illustrated system architecture, in an exemplary application scenario, the client 101 sends a document automatic typesetting request to the server 102 and attaches the document to be typeset. The server 102 receives the request and document from the client 101, forwards the document to the model 103, and requests the model 103 to call the deployed document element recognition model to analyze and recognize the document. After receiving the document, the model 103 calls the deployed document element recognition model to analyze and recognize the document, determine the element type of the paragraph in the document, and then returns the recognition result to the server 102.
[0102] Furthermore, after receiving the model recognition result returned by the model end 103, the server end 102 can also use its own algorithms and computing resources to further analyze and verify the model recognition result returned by the model end 103. For example, the server end can check the accuracy of the model recognition result, or further adjust and optimize the model recognition result based on the document's typesetting style, paragraph format and other features. Finally, the server end 103 determines the element type of the paragraph in the document based on the model recognition result and the results of further analysis. Finally, the server end 103 automatically typesets the document according to the determined element type of the paragraph in the document, and returns the typeset document to the client end 101. Alternatively, the server end 103 sends the determined element type of the paragraph in the document to the client end 101, and the client end 101 automatically typesets the document according to the determined element type of the paragraph in the document to obtain the typeset document.
[0103] Through the above process, the server 102 and the model 103 work together. On the one hand, it can efficiently process the automatic typesetting request of the document. On the other hand, the server 102 can make up for the lack of capabilities of the model 103 in certain aspects, thereby improving the accuracy of the final element type recognition result, and further ensuring that the typesetting of the document meets specific standards or requirements.
[0104] In the above exemplary application scenario, the server 102 requests the model end 103 to call the deployed document element recognition model to identify the paragraph element type of the document. In actual application scenarios, large electronic documents are often encountered, and these electronic documents contain hundreds or thousands of pages with extremely rich content. Although the document element recognition model has the ability to handle concurrent tasks, its computing resources are always limited. When the amount of data processing involved in a single concurrent task is too large, it will also affect the processing efficiency of the document element recognition model, and may even damage the recognition accuracy of the document element recognition model. In view of this, in order to ensure the recognition accuracy of the document element recognition model while taking into account the recognition efficiency of the document element recognition model, it is proposed in the relevant technology to split a large document into multiple smaller document fragments, which can be processed independently by the document element recognition model, and the model recognition results of each of these document fragments can restore the comprehensive recognition results of the entire document. This document fragmentation processing method aims to seek the best balance between efficiency and recognition accuracy, and ensure that the document element recognition model can play the maximum performance under limited computing resources.
[0105] Based on this, the document segmentation method is crucial to improving the overall performance and efficiency of the document element recognition model. A reasonable document segmentation method can not only effectively reduce the data processing volume of a single task, reduce the processing difficulty and time cost of the model, but also make full use of the concurrent processing capabilities of the model to achieve simultaneous recognition of multiple document segments, thereby greatly improving the overall performance of the model.
[0106] It should be noted that the above division of the client 101, the server 102 and the model 103, as well as the functional division of the execution of each end, is only an example, and some functions can be executed by any end, and the embodiments of the present application do not limit this. For example, the above-mentioned typesetting function can be executed on the server 102, or on the client 101; for another example, the above-mentioned filtering, streamlining and other operations on the document content can be executed on the server 102, or on the model 103, or partially on the server 102 and partially on the model 103. In order to briefly explain and clarify, the embodiments of the present application only use some examples to illustrate the functional division of the execution of each end, but the embodiments of the present application do not limit this.
[0107] Figure 2 The flowchart of an embodiment of a document processing method provided in the embodiment of the present application is shown in FIG. In one embodiment, the method is applied to a server, for example Figure 1 The server 102 shown in the example. Figure 2 As shown, the process includes the following steps:
[0108] Step 201: Obtain the target document to be processed.
[0109] The target document to be processed refers to the document that needs to be submitted to the model for feature type recognition, but needs to be segmented before being submitted to the model.
[0110] In one embodiment, the target document refers to an original document, for example, a document that needs to be typeset and is attached when the client 101 sends a request for automatic typesetting of a document to the server 102 .
[0111] In another embodiment, the target document is not the original document, but a document obtained by preprocessing a copy of the original document. The key purpose of preprocessing the copy of the original document is to ensure that the content in the document can be correctly segmented, because correct segmentation is an important prerequisite for the subsequent model end to identify the element type of the paragraph in the document, and is also an important prerequisite for correctly typesetting the paragraph after the element type of the paragraph is determined.
[0112] Specifically, for the correct segmentation of the original document, the difficulty lies in that the original document is correctly segmented at the display level (visual level), but if the segmentation is performed based on the document data of the original document, it will lead to incorrect segmentation due to the different segmentation standards adopted. A simple example is that there are three strings in the document data of the original document: string 1, string 2 and string 3, where string 1 and string 2 are separated by a soft return, and string 2 and string 3 are separated by a hard return. From the visual level, it can be clearly determined that string 1, string 2 and string 3 belong to different paragraphs. However, from the document data level, the original document is segmented using the segmentation standard of the hard return character, and the result of the segmentation is: string 1 and string 2 belong to one paragraph, and string 3 belongs to another paragraph, that is, a segmentation error occurs. In this application, segmentation is performed based on the document data of the original document. In order to obtain correct segmentation, it is necessary to pre-process the copy document of the original document according to the segmentation standard.
[0113] On this basis, the specific implementation of obtaining the target document to be processed includes: creating a copy document of the original document, preprocessing the copy document according to a set preprocessing method, obtaining a preprocessed document, and determining the preprocessed document as the target document to be processed. As for how to preprocess the copy document of the original document according to a set preprocessing method to obtain a preprocessed document, and determine the preprocessed document as the target document to be processed, it will be explained through specific embodiments below, and will not be described in detail here.
[0114] In another embodiment, the target document is a document that has been filtered and streamlined after the preprocessing, in order to remove information in the document that is useless or unhelpful for the document element recognition model to identify the element type. As for how to perform filtering and streamlining operations on the preprocessed document, it will be explained in detail below through specific embodiments, and will not be described in detail here. Of course, filtering, streamlining and other operations can be performed before or after sharding, which is not limited in this embodiment.
[0115] Step 202: Segment the target document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content.
[0116] In one embodiment, the target document is segmented into a plurality of document segments according to a set segmentation rule.
[0117] The set fragmentation rule is used to indicate the basis and standard of fragmentation. For example, the set fragmentation rule indicates that a set number of continuous paragraphs are divided into one document fragment. Based on the fragmentation rule, a paragraph number threshold can be set, and then according to this threshold, the continuous paragraphs in the target document are divided into different document fragments one by one, and each document fragment contains a certain number of paragraphs. In addition, in practical applications, the set paragraph number threshold is not fixed, but can be flexibly adjusted according to actual conditions. For example, when processing particularly complex or lengthy paragraphs, the number of paragraphs in the document fragment can be appropriately reduced to ensure that the document element recognition model can concentrate on processing, and will not cause some paragraphs to be missed or roughly recognized due to excessive processing volume, so that the document element recognition model can more accurately identify the element type of the paragraph. When processing some simple or short paragraphs, the number of paragraphs in the document fragment can be appropriately increased, and the total number of fragments can be reduced to improve the overall processing efficiency.
[0118] According to the set fragmentation rules, the target document can be segmented into multiple document fragments. It should be noted that two adjacent document fragments have some overlapping areas in terms of content. This is to protect the integrity and continuity of information as much as possible during the fragmentation process of the document, reduce the occurrence of continuous paragraphs being segmented into different fragments, and enable the key information and contextual connections in the target document to be completely retained and accurately transmitted, thereby significantly improving the accuracy of the document element recognition model in identifying the paragraph element type in the document fragment.
[0119] For example, the target document includes 50 paragraphs, the threshold of the number of paragraphs is set to 20, and the number of overlapping paragraphs is preset to 3. Then the first to the 20th paragraphs can be divided into one document segment, the 18th to the 37th paragraphs can be divided into one document segment, and the 35th to the 50th paragraphs can be divided into one document segment, so as to obtain 3 document segments, and each two adjacent document segments have 3 overlapping paragraphs in terms of content. For example, the overlapping paragraphs between the first document segment and the second document segment include the 18th to the 20th paragraphs; the overlapping paragraphs between the second document segment and the third document segment include the 35th to the 37th paragraphs.
[0120] Step 203: Input the multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments.
[0121] Step 204: When it is determined that the initial model recognition results of multiple document segments have recognition anomalies, the document segments corresponding to the recognition anomalies are adjusted, and the adjusted document segments are re-input into the document element recognition model to obtain the document element recognition model's re-model recognition results for the adjusted document segments.
[0122] For ease of understanding, step 203 and step 204 are explained uniformly below:
[0123] In practical applications, even if two adjacent document fragments have a partial overlapping area in content, due to the existence of other factors (such as the selection of fragment boundaries, the complexity of document content, the limitations of the model itself, etc.), the model recognition deviation caused by document fragmentation cannot be completely avoided. In this regard, the technical solution provided in the embodiment of the present application proposes a method of secondary fragmentation and secondary recognition. Specifically, as described in steps 203 and 204, the multiple document fragments formed by segmenting the target document according to the set fragmentation rules are first input into the document element recognition model that has been trained to obtain the initial model recognition results of the paragraphs in each document fragment. Afterwards, the initial recognition results of the paragraphs in each document fragment are analyzed to find possible recognition anomalies. Recognition anomalies may be manifested as failure to correctly identify the element type of a paragraph. Once recognition anomalies are found, the document fragments with recognition anomalies are adjusted. After the adjustment is completed, the adjusted document fragments are input into the document element recognition model again to obtain more accurate model recognition results again. Exemplarily, for the same paragraph, when the initial model recognition result and the secondary model recognition result are inconsistent, the secondary model recognition result shall prevail.
[0124] As for how to determine whether there are recognition anomalies in the initial model recognition results of multiple document segments, and how to adjust the document segments corresponding to the recognition anomalies, it will be discussed in different embodiments below and will not be described in detail here.
[0125] The technical solution provided by the embodiment of the present application obtains a target document to be processed, divides the target document into multiple document fragments, wherein two adjacent document fragments have a partially overlapping area in terms of content. The multiple document fragments are input into a document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments. When it is determined that the initial model recognition results of the multiple document fragments have recognition anomalies, the document fragments corresponding to the recognition anomalies are adjusted, and the adjusted document fragments are input into the document element recognition model again to obtain the re-model recognition results of the document element recognition model for the adjusted document fragments. A method of secondary document fragmentation and recognition is provided, and the application of this method can effectively reduce the deviation generated by the model when recognizing document fragments, and improve the accuracy and reliability of document element recognition.
[0126] The fragmentation rule of dividing a set number of consecutive paragraphs into one document fragment is a simple and easy document fragmentation method. However, due to the complexity and diversity of document content, this document fragmentation method may cause problems such as content integrity being destroyed and content fragmentation, thereby affecting the accuracy of document element recognition. In addition, if the logical structure and internal connection of the document content are not fully considered when performing document fragmentation, it may also lead to content fragmentation, so that the originally closely connected information is artificially separated, further reducing the accuracy of document element recognition.
[0127] In order to solve the above problems, the embodiment of the present application proposes to perform correction processing on the document fragments. The purpose of the correction processing is to adjust and optimize the fragmented documents according to specific rules and methods to ensure that each document fragment can accurately reflect the content and structure of the original document, so as to reduce the possibility of information loss and misunderstanding through the correction processing, thereby improving the accuracy of subsequent document element recognition.
[0128] Figure 3 A flowchart of another document processing method provided in an embodiment of the present application. Figure 3 The process shown in Figure 2 Based on the process shown, the following steps are included:
[0129] Step 301: Obtain the target document to be processed.
[0130] Step 302: Segment the target document into multiple document segments.
[0131] For detailed description of steps 301 and 302, please refer to Figure 2 The relevant descriptions in the process shown will not be repeated here.
[0132] Step 303: Correct the multiple document segments according to the set correction rules.
[0133] In one embodiment, according to the set correction rules, the specific implementation of correction processing on multiple document fragments includes: when it is recognized that the last paragraph in the document fragment ends with a specific symbol, the first N paragraphs in the next document fragment of the document fragment are adjusted to the document fragment.
[0134] The above-mentioned specific symbols are symbols that can be used to imply that there is related content to follow, such as a colon. Then, when it is recognized that the last paragraph in a document segment ends with a specific symbol, it can be considered that this document segment may be missing some subsequent content due to improper segmentation. In this regard, according to the set correction rules, the first N paragraphs (N is a positive integer, and the specific value can be set according to actual conditions) in the next document segment are adjusted to the current document segment. This ensures that the content that should originally belong to the current document segment is correctly included, thereby improving the accuracy and completeness of subsequent document element recognition.
[0135] In another embodiment, the specific implementation of correction processing of multiple document fragments according to the set correction rules includes: when it is identified that two adjacent document fragments include a continuous numbering interval, the two adjacent document fragments are re-segmented to divide the continuous numbering interval into the same document fragment.
[0136] Continuous numbering intervals usually appear in lists, directories, or sequential content. If two adjacent document fragments are identified to contain a continuous numbering interval, it can be considered that the two document fragments may have been mistakenly separated due to improper segmentation. In this regard, according to the set correction rules, the two adjacent document fragments are re-segmented to ensure that the continuous numbering interval is completely included in the same document fragment. This can maintain the continuity and integrity of the document content, thereby improving the accuracy and integrity of subsequent document element recognition.
[0137] In another embodiment, when it is identified that the end of the last paragraph in the document segment does not have a punctuation mark, the first M paragraphs in the next document segment of the document segment are adjusted to the document segment so that the end of the last paragraph of the retrieved document segment has a punctuation mark, where M is a positive integer.
[0138] The absence of punctuation at the end of a paragraph usually means that there is related content to follow. So when it is recognized that there is no punctuation at the end of the last paragraph of a document segment, it can be considered that this paragraph may be missing some subsequent content or punctuation due to improper segmentation. In this regard, according to the set correction rules, the first M paragraphs (M is a positive integer, and the specific value can be set according to actual conditions) in the next document segment are adjusted to the current document segment. Doing so can ensure that the content (including punctuation) that should originally belong to the current paragraph or current document segment is correctly included, thereby improving the accuracy and completeness of subsequent document element recognition.
[0139] The above embodiment is only an exemplary method of correcting multiple document segments according to the set correction rules. In actual applications, these correction rules can be set and adjusted according to the specific document content and recognition requirements. At the same time, different correction rules can also be used in combination with each other to further improve the accuracy and completeness of the document segments.
[0140] Step 304: input the corrected multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments.
[0141] Step 305: When it is determined that the initial model recognition results of multiple document segments have recognition anomalies, the document segments corresponding to the recognition anomalies are adjusted, and the adjusted document segments are re-input into the document element recognition model to obtain the document element recognition model's re-model recognition results for the adjusted document segments.
[0142] For detailed description of steps 304 and 305, please refer to Figure 2 The relevant descriptions in the process shown will not be repeated here.
[0143] Figure 3 The process shown, by correcting the document fragments, can further ensure that each document fragment can accurately reflect the content and structure of the original document, reduce the possibility of information loss and misunderstanding, and thus improve the accuracy of subsequent document element recognition.
[0144] Below Figure 2 and Figure 3 Based on the process shown, several different methods are introduced to check whether there are any abnormalities in the initial model recognition results of document shards:
[0145] In one embodiment, it is determined whether there are recognition anomalies in the initial model recognition results of multiple document fragments by: obtaining the initial model recognition results of partially overlapping areas in two adjacent document fragments; when it is recognized that the initial model recognition results of the partially overlapping areas in two adjacent document fragments are inconsistent, it is determined that there are recognition anomalies in the initial model recognition results of the two adjacent document fragments; when it is recognized that the initial model recognition results of the partially overlapping areas in two adjacent document fragments are consistent, it is determined that there are no recognition anomalies in the initial model recognition results of the two adjacent document fragments.
[0146] The above embodiment provides a method for checking whether the initial model recognition result is abnormal through the overlapping area between two adjacent document segments.
[0147] Under normal circumstances, the initial model recognition results of the same paragraph in two document fragments should be consistent. If the initial model recognition results of the same paragraph in two document fragments are inconsistent, it can be determined that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments. Accordingly, the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are obtained; when the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are inconsistent, it is determined that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments; when the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are consistent, it is determined that there is no recognition anomaly in the initial model recognition results of the two adjacent document fragments.
[0148] In this embodiment, the specific implementation of adjusting the document fragment corresponding to the recognition anomaly includes: merging two adjacent document fragments into one document fragment. After that, the merged document fragment is input into the document element recognition model again to obtain the re-model recognition result of the document element recognition model on the merged document fragment.
[0149] Exemplarily, for the paragraphs in the merged document fragments, the model recognition result is used again.
[0150] In one embodiment, it is determined whether there are any recognition anomalies in the initial model recognition results of multiple document fragments by: constructing a directory tree of the target document based on the initial model recognition results of multiple document fragments according to the document element recognition model; and determining whether there are any recognition anomalies in the initial model recognition results of multiple document fragments according to the directory tree.
[0151] The above embodiment provides a method for checking the abnormality of the initial model recognition result through a directory tree. In this way, the specific implementation of determining whether the initial model recognition results of multiple document fragments have recognition abnormalities according to the directory tree includes: identifying whether the directory tree has at least one of the following structural abnormality features: there are unnumbered paragraphs or paragraphs with unordered numbers in the directory tree; there are paragraphs with higher paragraph levels than the parent paragraphs of the child paragraph interval in the sub-level paragraph interval of the directory tree; the levels of paragraphs in the same numbered continuous paragraph intervals in the directory tree are inconsistent; in the case of identifying that the directory tree has at least one of the above structural abnormality features, it is determined that the initial model recognition results of multiple document fragments have recognition abnormalities; in the case of identifying that the directory tree does not have any of the above structural abnormality features, it is determined that the initial model recognition results of multiple document fragments do not have recognition abnormalities. In this embodiment, the specific implementation of adjusting the document fragments corresponding to the recognition abnormality includes: adjusting the continuous paragraphs in the target document that have at least one of the above structural abnormality features to the same document fragment.
[0152] The directory tree is a tree constructed by directory titles whose element type is a specific title type. This embodiment does not limit the specific title type, and the required title type can be set to a specific title type according to actual needs. For example, the specific title type can be set to: chapter title, section title, etc. Others, such as table titles and picture titles, can be set to not belong to a specific title type and do not participate in the construction of the directory tree.
[0153] The following explains the three abnormal structural features and the corresponding sharding adjustment strategies:
[0154] The first one: There are unnumbered paragraphs or paragraphs with random numbers in the directory tree.
[0155] Under normal circumstances, the paragraphs in the directory tree are numbered in a certain order. These numbers not only help to distinguish different paragraphs, but also clearly reflect the hierarchical relationship between paragraphs. Then, when unnumbered paragraphs or paragraphs with unordered numbers appear in the directory tree, it may mean that these paragraphs are mistakenly identified as directory titles, thus constituting a recognition anomaly.
[0156] In the case of recognition anomalies, unnumbered paragraphs or paragraphs with unordered numbers appearing in the directory tree and the continuous paragraphs of their context are adjusted to the same document segment, and secondary model recognition is performed on the document segment to more accurately understand and process these abnormal paragraphs.
[0157] The second type: There are paragraphs in the sub-paragraph interval of the directory tree whose paragraph level is higher than the parent paragraph of the sub-paragraph interval.
[0158] Among them, the sub-paragraph interval is composed of a series of consecutive paragraphs, and the paragraph levels of these paragraphs are the same, and they are not the highest paragraph level (such as level 1). Suppose there is such a sub-paragraph interval in the directory tree, which contains four paragraphs. The paragraph levels of the first two paragraphs and the fourth paragraph are all level 3, while the paragraph level of the third paragraph is level 1. Under normal circumstances, the paragraph level of the third paragraph is either level 3 (that is, the third paragraph is at the same level as the other paragraphs) or level 2 (that is, the third paragraph is at the same level as the parent paragraph of the first two paragraphs), and should not be higher than the paragraph level of the parent paragraph of the sub-paragraph interval. Then, the initial model recognition result of the third paragraph constitutes a recognition anomaly.
[0159] In the case of recognition anomalies, the continuous paragraphs that constitute the recognition anomalies (such as sub-paragraph intervals with structural abnormality features) can be adjusted to the same document segment, and secondary model recognition can be performed on the document segment to more accurately understand and process these paragraphs.
[0160] The third type: the levels of paragraphs within a range of consecutive paragraphs with the same number in the directory tree are inconsistent.
[0161] The numbering type of the paragraphs in the same numbered continuous paragraph interval is consistent, for example: number "1", number "2", number "3", etc. Under normal circumstances, the paragraph levels of the paragraphs in the same numbered continuous paragraph interval should be consistent. So when the levels of the paragraphs in the same numbered continuous paragraph interval in the directory tree are inconsistent, it is likely that the model has a deviation when identifying these paragraphs, resulting in the wrong level of the paragraphs being divided, thus constituting a recognition anomaly.
[0162] In the case of a recognition anomaly, the paragraphs in the continuous paragraph interval with the same number of the recognition anomaly are adjusted to the same document segment, and a secondary model recognition is performed on the document segment to more accurately understand and process these paragraphs.
[0163] In one embodiment, whether there are recognition anomalies in the initial model recognition results of multiple document segments is determined in the following manner: determining whether there are recognition anomalies in the initial model recognition results of the document segments according to the paragraph format attributes of the paragraphs in the document segments.
[0164] The paragraph format attributes of a paragraph include, but are not limited to, format attributes such as font, font size, alignment, paragraph spacing, etc. Determining whether the initial model recognition result of a document segment has recognition anomalies based on the paragraph format attributes of the paragraph in the document segment aims to determine whether the initial model recognition result has recognition anomalies based on the logical rationality of the paragraph format attributes.
[0165] For example, a paragraph is classified as body text in the initial model recognition, but the visual effect of the paragraph is presented as "centered" (this may be due to setting the center attribute, adding a space at the beginning of the paragraph, or setting the indentation attribute, etc.), which is logically unreasonable. Because under normal circumstances, the visual effect of the body paragraph should be left-aligned or right-aligned, not centered. Then, when the paragraph formatting attributes of the paragraph indicate that the paragraph is set to be centered, this may mean that the paragraph is actually a title, not the body text. In this case, the initial model recognition result of the paragraph constitutes a recognition anomaly.
[0166] For example, multiple consecutive paragraphs are classified as text in the initial model recognition, but there are a lot of spaces in these paragraphs, which may mean that these paragraphs actually contain notes. Similarly, if there are tabs in these paragraphs, it may mean that these paragraphs constitute a test question or a list. If there are a lot of empty underscores in these paragraphs, it may mean that these paragraphs are separators or fill-in-the-blank sections. In this case, the initial model recognition results of these paragraphs constitute recognition anomalies.
[0167] In this embodiment, the specific implementation of adjusting the document fragment corresponding to the recognition anomaly includes: adjusting the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment, and performing secondary model recognition on the document fragment. By adjusting all the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment, the purpose is to improve the model's accurate understanding and processing capabilities of these paragraphs through more comprehensive information input.
[0168] The above three embodiments respectively perform abnormal detection on the initial model recognition results of document fragmentation from different angles and provide corresponding adjustment strategies. These methods can be used alone or in combination to improve the accuracy and reliability of document recognition. In practical applications, appropriate methods and strategies can be selected according to the specific circumstances of the document and the recognition requirements, and the embodiments of the present application do not limit this.
[0169] Figure 4 A flowchart of another document processing method provided in an embodiment of the present application. Figure 4 The process shown in Figure 1 Based on the process shown, the following steps are included:
[0170] Step 401: Obtain the target document to be processed.
[0171] Step 402: Segment the target document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content.
[0172] For detailed description of steps 401 and 402, please refer to Figure 2 The relevant descriptions in the process shown will not be repeated here.
[0173] Step 403: Identify redundant content from the paragraphs in the document segment.
[0174] Step 404: input the non-redundant contents in the multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments.
[0175] The non-redundant content refers to other content in the document segment except the redundant content.
[0176] The following is a unified explanation of step 403 and step 404:
[0177] In actual application scenarios, an electronic document may contain hundreds or thousands of pages, and not all characters in the document constitute real and valid text content. The so-called "real and valid" is judged based on the final visual effect. Some characters in the document are used as placeholders, while others are used for paragraph separation, word separation, section separation, column separation, page separation and other layout purposes. Secondly, in the real and valid text content, there are also some paragraphs whose element types can be directly identified by the server. For example, the number of words required for different types of paragraphs varies, the character combination of a specific element type paragraph is fixed or can be enumerated; the structure of a specific paragraph interval is fixed or can be enumerated so that it is easy to identify, etc. These paragraphs whose element types can be directly identified by the server do not need to be identified by the model for element type. In view of this, in order to improve the recognition efficiency of the model and reduce its computational burden, the technical solution provided in the embodiment of the present application proposes: through the collaboration between the server end 102 and the model end 103, before submitting the document fragments to the model, the content in the document fragments can be filtered, streamlined, and other operations can be performed, aiming to eliminate information in the document fragments that is useless or unhelpful for the model to perform element type recognition, so as to improve the recognition efficiency of the model and reduce its computational burden.
[0178] In one embodiment, the specific implementation of identifying redundant content from paragraphs in a document fragment includes: identifying paragraphs that meet a specific element format from the paragraphs in the document fragment (for the convenience of description, the identified paragraph that meets the specific element format is referred to as the first paragraph), and determining the first paragraph as redundant content.
[0179] The specific element format may include one or more types, and different specific element formats correspond to different element types. The judgment basis of different element types is usually different.
[0180] Exemplarily, a specific element format indicates a specific paragraph length. In electronic documents, the main body often contains longer paragraphs, while elements such as titles and abstracts are relatively short. Therefore, if the content length of a paragraph far exceeds the scope of a regular title or brief description, then we can reasonably infer that this paragraph is likely to belong to the main body, rather than element types such as titles or abstracts. Accordingly, by setting a length threshold, extra-long paragraphs that may belong to the main body can be screened out from the document fragments based on the length threshold, and these extra-long paragraphs can be identified as the first paragraph, that is, redundant content, without the need to identify the element type through the model.
[0181] In addition, here is another point to add: in practical applications, the structure of electronic documents is diverse and complex, and the diversity is reflected in the different format requirements of electronic documents of different categories. Due to the diversity and complexity of the structure of electronic documents, there may be some problems in the method of determining redundant content based on paragraph length. For example, in a contract document, the title and specific content of a clause are usually integrated in one paragraph, which results in a large number of words in the paragraph and relatively complex content. If a paragraph is simply determined as a body paragraph according to the rule that the paragraph length exceeds the set length threshold, that is, the paragraph is regarded as redundant content of the document element recognition model, and it is no longer sent to the document element recognition model for further element type recognition, it is likely to miss some key information, resulting in errors in the recognition result. In order to solve this problem, as an embodiment, it is determined whether to determine the paragraph in the target document whose length exceeds the set length threshold as redundant content according to the category of the target document. This method can better meet the needs of practical applications when facing various document processing requirements.
[0182] Exemplarily, a specific element format indicates a specific content and structure. In an electronic document, the structure and content of objects such as tables, pictures, charts, text boxes, shapes, etc. are relatively fixed. For example, a table has a row and column structure, usually including a title row and a data row. Pictures are usually surrounded by borders. Charts are similar to pictures and usually include annotations such as titles, legends, and coordinate axes. Therefore, by identifying the characteristics of paragraph content and structure, paragraphs formed by these objects can be distinguished. For example, in the paragraph content, the object type of the object included in the paragraph can be determined according to the object label in the document data, such as any one of a table, an image, and a shape. These paragraphs can then be identified as the first paragraph, i.e., redundant content, without the need to perform element type identification through a model. It should be noted that the so-called paragraph formed by an object means that the paragraph content only includes objects, or it can be said that the object is a paragraph in itself. The reason for this setting is: if an object is inserted into a body paragraph as an illustration or data support, the paragraph should not be identified as the first paragraph. If a paragraph that contains both the above-mentioned objects and the main text is identified as the first paragraph, there may be recognition errors, which may lead to errors in subsequent processing (such as summary generation, information extraction, etc.). For example, the user will set an icon (picture) at the beginning of a paragraph whose element type is a title to better present the title. However, if it is simply assumed that there is a picture in the paragraph, then the element type of the paragraph is a main text paragraph, which will lead to an error in the identification of the element type of the paragraph. Therefore, for paragraph content that does not only include objects, its element type cannot be directly determined and needs to be further identified by the model.
[0183] Exemplarily, a specific element format indicates a specific format and layout. In an electronic document, some paragraphs may follow fixed format and layout requirements, such as headers, footers, date marks, etc. Therefore, by identifying the characteristics of paragraph format and layout, paragraphs of element types such as headers, footers, and date marks can be distinguished, and these paragraphs can be identified as the first paragraph, that is, redundant content, without the need to perform element type identification through the model.
[0184] In addition, document fragments may also contain empty segments, that is, paragraphs formed by space characters, which have no substantial content and therefore do not require the model to identify the element type. Therefore, empty segments can also be identified from document fragments and determined as redundant content.
[0185] Furthermore, in terms of non-redundant content, there may be some information that is not necessary for the model to perform the feature type recognition task. This information may include content that is invisible in visual presentation, such as continuous space characters and separators in a paragraph. This information occupies document space but is of no substantial use for the model to perform feature type recognition. In addition, for objects such as tables and pictures embedded in paragraphs, the model only needs to recognize their identity as embedded objects in the paragraph when processing, without paying attention to the specific content of the object itself.
[0186] Based on this, in order to further optimize the model processing flow, improve the recognition efficiency of the model and reduce its burden, the server can further streamline the non-redundant content before sending it to the model, aiming to remove information in the non-redundant content that is not helpful for the model to identify the element type. This processing method further enables the model to focus more on the core recognition task, significantly improves the overall processing efficiency of the model, and ensures the accuracy and timeliness of document element recognition.
[0187] In this regard, in one embodiment, the content to be simplified is identified from the paragraphs of the non-redundant content of the document segment, and the content to be simplified is simplified to obtain the simplified non-redundant content. After that, the document element recognition model is used to perform document recognition on the simplified non-redundant content to obtain the model recognition results of the paragraphs in the non-redundant content in the document segment. Finally, according to the model recognition results of the paragraphs in the non-redundant content and the element types of the paragraphs in the redundant content, the initial model recognition results of the paragraphs in the document segment are determined.
[0188] From the above description, it can be seen that the content to be simplified in the non-redundant content refers to the information that is not necessary for the model to identify the element type. In other words, the content that is not necessary for the document element identification model to identify the element type is identified from the paragraphs of the non-redundant content of the document segment, and the identified content is simplified to obtain the simplified non-redundant content. These contents usually include two categories. One is the content that is invisible in the visual presentation effect, such as continuous space characters and separators in a paragraph. The other is the content that the model only needs to identify as an embedded object in the paragraph during processing without paying attention to its specific content, such as tables, pictures and other objects embedded in a paragraph. The two situations are explained below:
[0189] In one embodiment, the specific implementation of identifying the content to be simplified from the paragraphs of the non-redundant content of the document fragment, and performing a simplification operation on the content to be simplified to obtain the simplified non-redundant content includes: identifying non-visual content from the paragraphs of the non-redundant content of the document fragment, determining the non-visual content as the content to be simplified, and deleting the non-visual content from the paragraphs of the non-redundant content of the document fragment to obtain the simplified non-redundant content.
[0190] The above non-visual content is the content that is invisible in the visual presentation effect, that is, the non-visual content that is not displayed in the displayed document. Non-visual content does not have semantics and is only used to adjust the document layout. The model does not need it when performing feature type recognition tasks. Therefore, the non-visual content can be directly deleted from the paragraphs of non-redundant content in the document segment to obtain streamlined non-redundant content.
[0191] Exemplarily, the specific implementation of identifying non-visual content from paragraphs of non-redundant content in document fragments and determining the non-visual content as content to be simplified includes: identifying space characters from paragraphs of non-redundant content in document fragments, and determining the space characters as content to be simplified; and / or, identifying separators from document fragments, and determining the separators as content to be simplified.
[0192] In another embodiment, content to be simplified is identified from paragraphs of non-redundant content in a document fragment, and a simplification operation is performed on the content to be simplified, and the specific implementation of obtaining the simplified non-redundant content includes: identifying elements of a preset type from paragraphs of non-redundant content in the document fragment, converting the elements of the preset type in the paragraphs into content indicator symbols, and the content indicator symbols are used to represent elements of the preset type.
[0193] The above-mentioned preset type of elements, that is, the model only needs to identify its identity as an embedded object in the paragraph when processing, without paying attention to its specific content. In other words, for the preset type of elements, the model only needs to identify its identity (such as the type and position of the content), without paying attention to the specific content therein. Therefore, the preset type of elements in the paragraph can be converted into corresponding content indicator symbols, and then the model can identify the element type according to the content indicator symbols.
[0194] Exemplarily, the specific implementation of identifying the content to be simplified from the paragraphs of the non-redundant content of the document segment, simplifying the content to be simplified, and obtaining the simplified non-redundant content includes: identifying object elements from the paragraphs of the non-redundant content of the document segment, determining the object elements as the content to be simplified, and converting the object elements into corresponding placeholders; and / or, identifying table elements from the paragraphs of the non-redundant content of the document segment, determining the table elements as the content to be simplified, and converting the table elements into the position information of the table elements in the document segment. The above-mentioned object elements include but are not limited to: objects such as pictures, charts, shapes, and text boxes. The placeholder can be a label indicating the type of object, such as the label of an image can be "img" and the label of a chart can be "tab".
[0195] In addition, in actual applications, there is a type of content to be simplified. This type of content to be simplified is interspersed in the document in an intermediate form. However, when the model performs feature type recognition tasks, it does not need to pay attention to these intermediate forms. The model is more concerned about the final form of these contents, that is, the final form displayed in the document.
[0196] In this regard, in one embodiment, the specific implementation of identifying the content to be simplified from the paragraphs of the non-redundant content of the document fragment, and performing a simplification operation on the content to be simplified to obtain the simplified non-redundant content includes: identifying the intermediate content to be processed as the final content from the paragraphs of the non-redundant content of the document fragment, and converting the intermediate content into the final content. By converting the intermediate content into the corresponding final content, it is possible to avoid the intermediate content from interfering with the model's document element recognition, ensuring that the model can focus on key information when performing the document element recognition task, thereby improving the accuracy of the model's document element recognition.
[0197] Exemplarily, domain elements are identified from paragraphs of non-redundant content in the document fragment, the domain elements are determined as content to be simplified, and the domain elements are converted into corresponding domain results.
[0198] Domain elements are used to insert dynamic content in documents, such as page numbers, dates, etc. In the final typesetting of the document, domain elements should be replaced with domain results. Therefore, domain elements are identified in paragraphs of non-redundant content and converted into corresponding domain results.
[0199] Exemplarily, revised content with revision marks is identified from paragraphs of non-redundant content of the document segment, the revised content is determined as content to be streamlined, and the revised content is converted into corresponding revised content.
[0200] Revision marks indicate that the document has been modified, such as strikethrough, underline, text of different colors, etc. In the final typesetting of the document, revision marks should be replaced with revised content. Therefore, the revised content with revision marks is identified in the paragraphs of non-redundant content, and the revised content is converted into the corresponding revised content.
[0201] In one embodiment, it is further possible to determine whether the streamlined non-redundant content is redundant content. For example, after the domain element is converted into the corresponding domain result, the paragraph where the length of the paragraph where the domain is located exceeds the set length threshold is determined to be redundant content.
[0202] In addition, the document element recognition model usually does not pay attention to the document's formatting attributes, such as font, font size, bold, italic, underline, alignment and the like, when identifying the element type of a paragraph. This is because the main goal of the document element recognition model is to understand and classify the information content in the document from a semantic level, rather than the visual presentation of the document content. Therefore, after identifying the content to be streamlined from the paragraphs of non-redundant content in the target document and streamlining the content to be streamlined, the specific implementation of obtaining the streamlined non-redundant content also includes: cleaning the formatting attributes of the non-redundant content to reduce the burden on the model, avoiding the increase in the complexity of the model's processing tasks due to the model's failure to recognize complex formatting attributes, and also resulting in a decrease in recognition accuracy.
[0203] Before sending non-redundant content to the model, the server further simplifies the non-redundant content to remove unnecessary information for the model to identify the element type. This processing method further enables the model to focus more on the core recognition task, significantly improves the overall processing efficiency of the model, and ensures the accuracy and timeliness of document element recognition.
[0204] Here is another point to add: In practical applications, the structure of electronic documents is diverse and complex, and the diversity is reflected in the different format requirements of electronic documents of different categories. Due to the diversity and complexity of the structure of electronic documents, there may be some problems in the method of determining redundant content based on paragraph length. For example, in a contract document, the title and specific content of the clause are usually integrated in one paragraph, which results in a large number of words in the paragraph and relatively complex content. If a paragraph is simply determined as a body paragraph according to the rule that the paragraph length exceeds the set length threshold, that is, the paragraph is regarded as redundant content of the document element recognition model, and it is no longer sent to the document element recognition model for further element type recognition, it is likely to miss some key information, resulting in errors in the recognition result. In order to solve this problem, as an embodiment, part of the redundant content determined according to the rule that the paragraph length exceeds the set length threshold can be sent to the document element recognition model for further recognition, which can not only reduce the recognition task of the document element recognition model to a certain extent, but also ensure the accuracy of document element recognition. Among them, it is usually chosen to send the front content of the redundant content to the document element recognition model for recognition. The reason is that in many cases, important information such as the title is located at the beginning of the paragraph. In this way, it can be ensured as much as possible that key information such as the title can be sent to the document element recognition model for recognition, thereby effectively avoiding the problem of recognition errors caused by missing information. In addition, when segmenting the front content from the redundant content, it can be segmented based on punctuation marks, such as periods, to ensure that the semantics of the part of the content given to the model is as coherent and smooth as possible. Correspondingly, the element type of the paragraph in the redundant content is also the element type recognized by the document element recognition model.
[0205] Based on the above content, in one embodiment, when paragraphs in the target document whose length exceeds a set length threshold are determined to be redundant content according to the category of the target document, part of the redundant content can also be sent to a document element recognition model for further recognition. Such processing can also reduce the recognition task of the document element recognition model to a certain extent, and ensure the accuracy of document element recognition.
[0206] Step 405: When it is determined that the initial model recognition results of multiple document segments have recognition anomalies, the document segments corresponding to the recognition anomalies are adjusted, and the adjusted document segments are re-input into the document element recognition model to obtain the document element recognition model's re-model recognition results for the adjusted document segments.
[0207] In one embodiment, when adjusting the document segments corresponding to the recognition anomalies, non-streamlined paragraphs (i.e., paragraphs that have not been de-redundanted and have not undergone non-redundant content streamlining) are used to form the adjusted document segments, which is intended to make the information in the adjusted document segments more complete, thereby improving the recognition accuracy of the model.
[0208] As for the detailed description of step 405, please refer to the relevant description in the above embodiment, which will not be repeated here.
[0209] Figure 4 In the illustrated embodiment, paragraphs of determined element types are identified as redundant content from paragraphs in a document segment, and a document element recognition model is used to perform document recognition on non-redundant content in the document segment to obtain model recognition results of paragraphs in the non-redundant content. Non-redundant content refers to other content in the document segment except redundant content. Based on the model recognition results of paragraphs in the non-redundant content and the redundant content, the initial model recognition results of paragraphs in the document segment are determined, thereby achieving collaborative work between the server and the model. This collaborative work mechanism can more effectively utilize the processing power of the model and avoid the model from processing unnecessary redundant content, which can not only improve the recognition efficiency and accuracy of the model, but also reduce the burden on the model.
[0210] at the same time, Figure 4 In the technical solution provided by the illustrated embodiment, the target document is first segmented, and then the redundant content of the document segment is processed and the non-redundant content is simplified. Compared with first processing the redundant content of the target document and simplifying the non-redundant content and then segmenting, this processing method can, on the one hand, avoid the rationality and accuracy of subsequent document segmentation being affected by the processing of redundant content. For example, if the redundant content is processed first, it may cause the part that should have been an independent segment to be merged with other parts, resulting in unreasonable segmentation. For example, if the non-redundant content is simplified first, some parts of the document may be over-simplified or merged, thereby affecting the subsequent segmentation process. On the other hand, in the case of segmentation first, the target document is divided into multiple independent parts, each of which retains the original structure and content of the document as much as possible. Subsequently, the redundant content of the document segment is processed and the non-redundant content is simplified, which can ensure that the processing process will not affect the boundaries between the subsequent segments or the structure of the original document. In short, first segmenting the target document, then processing the redundant content of the document segment and streamlining the non-redundant content can improve the rationality and accuracy of the document segmentation.
[0211] The following describes through a specific embodiment how to pre-process the copy document of the original document according to a set pre-processing method to obtain the target document processed in the embodiment of the present application.
[0212] In one embodiment, the copy document is preprocessed according to a set preprocessing method, and the specific implementation of obtaining the preprocessed document includes: identifying non-standard typesetting styles related to segmentation or paging from the copy document, converting the non-standard typesetting styles into a set standard typesetting style, and obtaining the preprocessed document.
[0213] Wherein, the set preprocessing mode includes a collection of a series of document processing operations, and these document processing operations are intended to ensure that the content in the document can be correctly segmented. In the process of preprocessing the copy document, a paragraph mapping relationship between the original document and the preprocessed document can also be established. Specifically, in the original document, a unique identifier (such as paragraph number, paragraph ID, etc.) is assigned to each paragraph. In the process of preprocessing the copy document of the original document, the original position and the modified position of each paragraph are recorded to establish a mapping relationship between the paragraph in the original document and the corresponding paragraph in the preprocessed document. In step 201, through the paragraph mapping relationship, the model recognition result of the paragraph in the preprocessed document can be corresponded back to the corresponding paragraph in the original document, thereby determining the model recognition result of the paragraph in the original document.
[0214] In one embodiment, the copy document is preprocessed according to a set preprocessing method, and the specific implementation of obtaining the preprocessed document includes: identifying non-standard typesetting styles related to segmentation or paging from the copy document, converting the non-standard typesetting styles into a set standard typesetting style, and obtaining the preprocessed document.
[0215] Among them, non-standard typesetting styles refer to segmentation or paging operations that do not meet the model recognition requirements. These operations may be due to the document creator using specific tools or specific habits. For example, the segmentation operation required by the model recognition can be based on the hard return character in the document data to determine the segmentation. Non-standard typesetting styles usually cause the model to be unable to accurately recognize the paragraph structure of the document, thereby affecting subsequent feature type recognition tasks. For example, the document creator uses space characters to achieve a segmentation effect in a certain paragraph of the document. Although this can achieve the segmentation effect visually, the document feature recognition model deployed on the model side cannot understand this segmentation achieved by space characters. Therefore, this segmentation operation is regarded as a non-standard typesetting style.
[0216] The standard typesetting style refers to the segmentation operation that meets the model recognition requirements. Such segmentation operation is usually based on the general specifications or standards in the document processing field, such as specific paragraph markers.
[0217] It can be seen that by identifying non-standard typesetting styles related to paragraphing or paging from the copy document, converting the non-standard typesetting styles into the set standard typesetting styles, and obtaining the pre-processed document, it can ensure that the non-standard typesetting styles in the copy document are corrected and converted into standard typesetting styles that the model can accurately recognize. This helps the model accurately recognize the paragraph structure of the document, thereby supporting the subsequent feature type recognition task.
[0218] The standardization of the paragraphing style used in the document (the standardization here refers to the recognition ability of the model) will directly affect the model's recognition of paragraphs in the document. In addition, the separation style used in the document is also crucial to the coherence of the model's paragraph recognition. Therefore, the following discusses the specific implementation of identifying non-standard typesetting styles related to paragraphing or paging from the copy document from the two dimensions of paragraphing style and separation style, and converting non-standard typesetting styles into the set standard typesetting style.
[0219] Among them, from the perspective of segmentation style, as an optional implementation method, non-standard typesetting styles related to segmentation or paging are identified from the copy document, and the specific implementation of converting the non-standard typesetting style into a set standard typesetting style includes: identifying non-standard segmentation styles from the copy document, and converting the non-standard segmentation styles into a set standard segmentation style.
[0220] Exemplarily, the standard segmentation style is a paragraph marker (also known as a hard return), that is, the paragraph marker is used as a standard separation mark between document paragraphs, and the document element recognition model can accurately recognize the standard separation mark as the basis for paragraph recognition.
[0221] In this embodiment, based on the recognition rules corresponding to the preset non-standard typesetting styles, the non-standard typesetting styles can be identified from the copy document based on the recognition rules; in addition, the conversion rules for converting different non-standard typesetting styles into standard typesetting styles can also be determined, and standardized conversion can be performed based on the conversion rules.
[0222] The following examples describe the following non-standard segmentation styles that may exist in the copy document and their corresponding conversion rules:
[0223] The first type: soft return segmentation
[0224] In document editing scenarios, soft returns are often used to wrap lines within the same paragraph, rather than to create new paragraphs. However, due to the user's specific editing habits or insufficient understanding of document typesetting specifications, soft returns may be mistakenly used to try to visually create a segmentation effect.
[0225] In view of this situation, the non-standard segmentation style is identified from the copy document, and the specific implementation of converting the non-standard segmentation style into the set standard segmentation style includes: identifying the soft carriage return from the copy document, and converting the soft carriage return into a paragraph marker. By converting the soft carriage return into a paragraph marker, it is helpful to restore the correct paragraph structure of the document, thereby helping the subsequent model to accurately identify the paragraphs in the copy document and then identify the element type of the paragraph.
[0226] For example, see Figure 5 , which is a diagram comparing the effects of using soft carriage returns and hard carriage returns in text content.
[0227] The second type: the separator is glued to the content paragraph
[0228] In document editing scenarios, separators (such as page breaks and section breaks) are usually used to visually or logically separate document content, and can usually also achieve segmentation in visual effects. For example, Figure 6 The string "I am a free paragraph at the top of the page" on page 2 and the string "I am a glued paragraph at the top of the page, I am part of the paragraph on the previous page" on page 3 are visually displayed as two paragraphs due to the existence of page breaks. However, if the hard return character is used as the paragraph separation criterion, the string "I am a free paragraph at the top of the page" on page 2 and the string "I am a glued paragraph at the top of the page, I am part of the paragraph on the previous page" on page 3 will still be recognized as the same paragraph (see Figure 6 , there is no hard return after the string in page 2), resulting in a difference between the segmentation based on document data and the visual effect segmentation that conforms to user intent.
[0229] That is to say, due to the user's editing habits or specific needs, these separators are sometimes attached to the paragraph content, making it look like two paragraphs visually. However, if the hard return character is used as the segmentation standard, the actual segmentation result will not be correctly separated in the document structure, that is, the two paragraphs separated by the separator will still be divided into the same paragraph.
[0230] In view of this situation, the non-standard paragraphing style is identified from the copy document, and the specific implementation of converting the non-standard paragraphing style to the set standard paragraphing style includes: identifying the separators attached to the paragraph content from the copy document, inserting paragraph markers between the separators and the attached paragraph content, so as to restore the correct paragraph structure of the document. Figure 6 , where page 1 is an example of correct paragraph structure. Figure 6As shown on page 1 of the text, the string "I am a free paragraph at the top of the page" is followed by a page break, and there is also a hard return after the page break. Based on the hard return as the segmentation standard, the string "I am a free paragraph at the top of the page" in page 1 and the string "I am a free paragraph at the top of the page" in page 2 are identified as two paragraphs. In addition, there is another correct paragraph structure: the delimiter is at the beginning of the paragraph, that is, the delimiter is after the hard return. For example, suppose Figure 6 The content of page 1 is "I am a free paragraph hard return at the top of the page", and the content of page 2 is "Separator I am a free paragraph hard return at the top of the page", which is also the correct paragraph structure and can be used to Figure 6 The string in page 1 and the string in page 2 are correctly identified as two paragraphs.
[0231] Based on this, firstly, the separator mark (such as the specific code of the page break, the identifier of the section break, etc., which vary depending on the document format) is identified from the copy document, and then, for the identified separator, it is analyzed whether it is attached to the paragraph content. Here, the attachment of the separator mark to the paragraph content is manifested as the absence of a paragraph mark between the separator and the paragraph content. For example, see Figure 6 In the example on page 2 of the article, the delimiter tag is attached to the string "I am a free paragraph at the top of the page". Another case is that there is no paragraph tag after the delimiter tag. In other words, if there is no paragraph tag before or after the delimiter tag, it can be considered that the delimiter tag is attached to the paragraph content. In this case, insert a paragraph tag (such as a hard return) between the delimiter tag and the attached paragraph content to ensure that the paragraphs can be separated correctly. For example, Figure 6 Change page 2 in to "I am a free paragraph hard return section break at the top of the page (next page)".
[0232] The third type: space or tab segment
[0233] In a document editing context, users may use spaces or tabs to try to visually separate paragraphs, but these characters do not actually form true paragraph breaks in the document structure. For example, see Figure 7 , which is a schematic diagram of the segmentation effect of space or tab characters.
[0234] In view of this situation, the specific implementation of identifying the non-standard segmentation style from the copy document and converting the non-standard segmentation style into the set standard segmentation style includes: identifying the line ending with multiple continuous spaces or tabs from the copy document, deleting the multiple continuous spaces or tabs at the end of the line, and inserting a paragraph mark at the end of the line. Exemplarily, the copy document content is traversed line by line, and it is checked whether the end of each line contains multiple continuous spaces or tabs. If continuous spaces or tabs are found, these characters are deleted and a paragraph mark is inserted at the end of the line. Specifically, when typesetting, the copy document content is traversed line by line. For example, if a line can display 20 characters, 20 characters are read from the copy document content as a line to be traversed. For the line currently traversed, if the last character position of the current line is a space character or a tab character when traversing to it, it means that the current line ends with a space character or a tab character. Then, delete the continuous spaces or tabs at the end of the line, and insert a paragraph mark at the end of the current line. Continue to read the content of the copy document that can be typeset into a line as the new current traversed line. In this way, the lines between the current line and the previous paragraph mark will be separated into a paragraph, and the next line of the current line will become the starting line of a new paragraph.
[0235] The fourth case: the text content is not segmented
[0236] In document editing scenarios, users may fail to divide text content into multiple paragraphs correctly due to negligence or specific editing habits, resulting in multiple paragraphs being merged into one paragraph. This merging is particularly obvious when the document contains numbered lists, because each numbered item should usually be considered an independent paragraph. For example, see Figure 8 , which is a schematic diagram of the effect of not correctly segmenting text content.
[0237] In view of this situation, the specific implementation of identifying the non-standard paragraphing style from the copy document and converting the non-standard paragraphing style into the set standard paragraphing style includes: identifying a paragraph including at least two numbers from the copy document, and inserting a paragraph marker before the non-first number in the paragraph. Exemplarily, the document content is traversed line by line or paragraph by paragraph to find the paragraphs containing numbers, and for each paragraph containing at least two numbers, the position of the non-first number is found. A paragraph marker is inserted before each non-first number to ensure that after the paragraph marker is inserted, each numbered item is located in a new paragraph.
[0238] In addition, when the text content is not segmented and does not contain a numbered list, the model can also be used to segment the text content. For example, the model segments the text content using contextual semantic recognition technology. This is not limited here.
[0239] From the perspective of separation style, as an optional implementation method, non-standard typesetting styles related to paragraphing or paging are identified from the copy document, and the specific implementation of converting the non-standard typesetting styles into the set standard typesetting styles includes: identifying non-standard separation styles from the copy document, and converting the non-standard separation styles into the set standard separation styles.
[0240] For example, the following non-standard separation styles may exist in the copy document:
[0241] The first type: Section / page break paging
[0242] In a document editing scenario, users may use different paging or sectioning methods to organize content, such as directly inserting page breaks or inserting blank pages (which usually introduce section breaks) to achieve paging effects. However, these different paging or sectioning methods may lead to inconsistent document structures, thus affecting the readability of the document and the efficiency and accuracy of document analysis and recognition.
[0243] In response to this situation, a non-standard separation style is identified from the copy document. The specific implementation of converting the non-standard separation style to the set standard separation style includes: identifying a section break or page break at the end of a line from the copy document, and moving the section break or page break at the end of a line to the beginning of the next line of the line to ensure consistency of the paging or sectioning method in the copy document.
[0244] The second type: paragraph break and line break
[0245] In a document editing scenario, users may sometimes achieve page breaks by simply pressing Enter to add a blank line, but this is not recommended because it will become ineffective as the document layout is adjusted. For example, see Fig. 9 , a schematic diagram of using consecutive blank lines to achieve paging effect
[0246] In response to this situation, a non-standard separation style is identified from the copy document. The specific implementation of converting the non-standard separation style to the set standard separation style includes: identifying a page ending with continuous blank lines from the copy document, inserting a page break at the beginning of the first line of the next page of the page, and deleting the continuous blank lines at the end of the page to ensure the consistency and stability of the paging method in the copy document.
[0247] Specifically, for each page of the copy document, traverse line by line. For the current traversed line, if it is found that there are no valid characters in the line, for example, all are space characters or tab characters, then continue to traverse the next line. If there are valid characters in the traversed line, stop traversing the current page and continue to traverse the next line by line. If it is traversed to the last line of the current page and it is found that there are still no valid characters in the last line, it means that the current page ends with continuous blank lines. Then, insert a page break at the beginning of the first line of the next page of the page, and delete the continuous blank lines at the end of the page. Through this processing method, page redundancy caused by continuous blank lines can be avoided, and the page division of the document can also be made clearer and more reasonable.
[0248] The third type: paragraph attribute paging
[0249] In a document editing scenario, users may use paragraph properties (such as "page break before" or "page break after") to achieve paging effects. This method is more common for professional users such as Office, but it may also be inadvertently introduced into the document due to operations such as copying and pasting, causing other users to be unaware or overwhelmed.
[0250] In view of this situation, the specific implementation of identifying the non-standard delimiting style from the copy document and converting the non-standard delimiting style into the set standard delimiting style includes: identifying the paragraphs with paragraph attributes set from the copy document, determining the first paragraph of the next page according to the paragraph attributes set for the paragraph, and inserting a page break at the beginning of the first paragraph of the next page to ensure the consistency and readability of the paging method of the copy document. Exemplarily, the copy document is traversed line by line or paragraph by paragraph to identify the paragraphs with specific paragraph attributes (such as page break before paragraph, page break after paragraph, etc.). After determining the first paragraph of the next page, a page break is inserted at the beginning of the paragraph, and the paragraph attributes originally used for paging are cleared.
[0251] By deeply analyzing the paragraph and separation styles in the copy documents, identifying the non-standard typesetting styles formed by the document creator's use of specific tools or habits, and converting these non-standard typesetting styles into the set standard typesetting styles, it can ensure that the model can accurately recognize and understand the paragraph structure of the copy documents.
[0252] The consistency and standardization of numbering are also crucial for the model to understand the logical structure of the document. In the document editing scenario, users may use a variety of numbering methods, including manual numbering, single-level automatic numbering, multi-level automatic numbering, etc., and these numbering styles may involve numbers, Chinese characters, special symbols, etc. In addition, the complex relationship between numbering and paragraphs, such as indentation and spacing, may also cause the typesetting to not meet user expectations. Therefore, unifying the numbering method and achieving controllability and consistency of typesetting is an important task in document processing.
[0253] Based on this, as an optional implementation, the specific implementation of identifying the non-standard typesetting style related to paragraphing or paging from the copy document and converting the non-standard typesetting style to the set standard typesetting style includes: identifying the non-standard numbering style from the copy document and converting the non-standard numbering style to the set standard numbering style. Exemplarily, the specific implementation of identifying the non-standard numbering style from the copy document and converting the non-standard numbering style to the set standard numbering style includes: identifying the number set with the automatic numbering style from the copy document and canceling the automatic numbering style setting for the number.
[0254] It can be seen that manual numbering is used in the copy documents to avoid the complexity brought by automatic numbering, thereby improving the reliability and consistency of the copy document layout and laying the foundation for the subsequent model to accurately understand the logical structure of the document.
[0255] In addition, there will be some non-standard content in the document. The non-standard content here refers to the content form in the document that does not conform to the set standard specifications. The set standard specifications are, for example, customized by document processing software, industry practices or users, and are intended to ensure the consistency and readability of the document. Exemplary, non-standard content includes: domain elements, revision marks, etc. Domain elements are used to insert dynamic content into the document, such as page numbers, dates, etc. In the final layout of the document, domain elements should be replaced with domain results. Modification marks indicate that the document has been modified, such as strikethroughs, underlines, texts of different colors, etc. In the final layout of the document, revision marks should be replaced with revised content. It can also be seen from this that non-standard content usually refers to the intermediate form of content generated during the document editing process, while standard content refers to the content presented in the final layout of the document.
[0256] Due to the limited computing power of the model, non-standard content may interfere with the model's paragraph recognition. In this regard, as an optional implementation method, non-standard typesetting styles related to segmentation or paging are identified from the copy document, and the specific implementation of converting the non-standard typesetting styles to the set standard typesetting styles includes: identifying non-standard content styles from the copy document, and converting the non-standard content styles to the set standard content styles. By normalizing the non-standard content styles in the copy document, it can be ensured that they will not interfere with the model's recognition.
[0257] Exemplarily, the specific implementation of identifying non-standard content styles from the copy document and converting the non-standard content styles into the set standard content styles includes: identifying domain elements from the copy document, determining domain results of the domain elements, and using the domain results to replace the domain elements in the copy document.
[0258] Exemplarily, the specific implementation of identifying non-standard content styles from a copy document and converting the non-standard content styles into a set standard content style includes: identifying revised content with revision marks from the copy document, determining the revised content of the revised content, and replacing the revised content with the revised content in the copy document.
[0259] In addition to domain elements and revision content, there may be other types of non-standard content, such as hidden text, footnotes / endnotes, comments, etc. For these contents, corresponding identification and conversion strategies can be formulated according to specific needs, and the embodiments of the present application do not limit this.
[0260] In the above embodiment, a copy document of the original document is created, the copy document is preprocessed according to a set preprocessing method, and a preprocessed document is obtained. The preprocessed document is determined as a target document to be processed, thereby ensuring that the content in the target document is correctly segmented, thereby improving the accuracy of identifying and streamlining redundant content in the document.
[0261] Fig.10 This is a block diagram of an embodiment of a document processing device provided in an embodiment of the present application. Fig.10 As shown, the device comprises:
[0262] The document acquisition module 1001 is used to acquire the target document to be processed;
[0263] The document segmentation module 1002 is used to segment the target document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content;
[0264] The fragment recognition module 1003 is used to input the multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model on the multiple document fragments;
[0265] The secondary fragmentation module 1004 is used to adjust the document fragments corresponding to the recognition anomaly when it is determined that the initial model recognition results of the plurality of document fragments have recognition anomalies;
[0266] The segment recognition module 1003 is further used to input the adjusted document segment into the document element recognition model again to obtain a model recognition result of the document element recognition model on the adjusted document segment.
[0267] In a possible implementation, the device further includes:
[0268] The correction module is used to correct the multiple document fragments according to the set correction rules after the target document is divided into multiple document fragments.
[0269] In a possible implementation manner, the correction module is specifically used to:
[0270] When it is identified that the last paragraph in the document segment ends with a specific symbol, the first N paragraphs in the next document segment of the document segment are adjusted to the document segment; and / or,
[0271] When it is identified that two adjacent document fragments include a continuous numbering interval, the two adjacent document fragments are re-segmented to segment the continuous numbering interval into the same document fragment; and / or,
[0272] When it is identified that the end of the last paragraph in the document segment does not have a punctuation mark, adjusting the first M paragraphs in the next document segment of the document segment to the document segment;
[0273] Wherein, the M and the N are positive integers.
[0274] In a possible implementation, the device further includes:
[0275] The anomaly recognition module is used to determine whether there are any recognition anomalies in the initial model recognition results of the multiple document fragments.
[0276] In a possible implementation, the abnormality identification module is specifically used to:
[0277] Obtaining initial model recognition results of partially overlapping areas in two adjacent document fragments;
[0278] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are inconsistent, determining that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0279] When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are consistent, determining that there is no recognition anomaly in the initial model recognition results of the two adjacent document fragments;
[0280] The secondary sharding module 1004 is specifically used for:
[0281] The two adjacent document fragments are merged into one document fragment.
[0282] In a possible implementation, the abnormality identification module is specifically used to:
[0283] Constructing a directory tree of the target document according to the initial model recognition results of the document element recognition model on the multiple document fragments;
[0284] Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments according to the directory tree.
[0285] In a possible implementation, the abnormality identification module is specifically used to:
[0286] Identify whether the directory tree has at least one of the following structural abnormal features: there are unnumbered paragraphs or paragraphs with unordered numbers in the directory tree; there are paragraphs with higher levels than the parent paragraphs of the child paragraph interval in the sub-level paragraph interval of the directory tree; the levels of paragraphs in the same numbered continuous paragraph interval in the directory tree are inconsistent;
[0287] In the case where it is identified that the directory tree has at least one of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments have recognition abnormalities; in the case where it is identified that the directory tree does not have any of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments do not have recognition abnormalities;
[0288] The secondary sharding module 1004 is specifically used for:
[0289] The continuous paragraphs in the target document having at least one of the above structural abnormal features are adjusted to the same document segment.
[0290] In a possible implementation, the abnormality identification module is specifically used to:
[0291] Determining whether there is a recognition anomaly in the initial model recognition result of the document segment according to the paragraph format attributes of the paragraph in the document segment;
[0292] The secondary sharding module 1004 is specifically used for:
[0293] Adjust the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment.
[0294] In a possible implementation, the device further includes:
[0295] a redundancy identification module, configured to identify redundant content from paragraphs in the document fragments before inputting the plurality of document fragments into the document element identification model;
[0296] The fragment identification module is also used to utilize the non-redundant content in the multiple document fragments to execute the step of inputting the multiple document fragments into the document element identification model, and the non-redundant content refers to other content in the document fragments except the redundant content.
[0297] like Fig.11As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0298] Memory 113, used for storing computer programs;
[0299] In one embodiment of the present application, the processor 111 is used to execute the program stored in the memory 113 to implement the document processing method provided by any of the above method embodiments, including:
[0300] Get the target document to be processed;
[0301] Segmenting the target document into a plurality of document fragments, wherein two adjacent document fragments have a partial overlapping area in terms of content;
[0302] Inputting the plurality of document fragments into a document element recognition model to obtain initial model recognition results of the document element recognition model on the plurality of document fragments;
[0303] When it is determined that the initial model recognition results of the plurality of document segments have recognition anomalies, adjusting the document segments corresponding to the recognition anomalies;
[0304] The adjusted document segments are input into the document element recognition model again to obtain a model recognition result of the adjusted document segments by the document element recognition model.
[0305] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the document processing method provided in any of the aforementioned method embodiments are implemented.
[0306] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0307] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0308] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0309] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A document processing method, characterized in that: The method comprises: Get the target document to be processed; Segmenting the target document into a plurality of document fragments, wherein two adjacent document fragments have a partial overlapping area in terms of content; Inputting the plurality of document fragments into a document element recognition model to obtain initial model recognition results of the document element recognition model on the plurality of document fragments; When it is determined that the initial model recognition results of the multiple document segments have recognition anomalies, the document segments corresponding to the recognition anomalies are adjusted, and the adjusted document segments are re-input into the document element recognition model to obtain the re-model recognition results of the document element recognition model for the adjusted document segments.
2. The method according to claim 1, characterized in that After the target document is segmented into a plurality of document fragments, the method further includes: According to the set correction rules, the multiple document fragments are corrected, so as to use the corrected multiple document fragments to execute the step of inputting the multiple document fragments into the document element recognition model to obtain the initial model recognition results of the document element recognition model for the multiple document fragments.
3. The method according to claim 2, characterized in that The correcting process of the plurality of document fragments according to the set correction rule includes: When it is identified that the last paragraph in the document segment ends with a specific symbol, the first N paragraphs in the next document segment of the document segment are adjusted to the document segment; and / or, When it is identified that two adjacent document fragments include a continuous numbering interval, the two adjacent document fragments are re-segmented to segment the continuous numbering interval into the same document fragment; and / or, When it is identified that the end of the last paragraph in the document segment does not have a punctuation mark, adjusting the first M paragraphs in the next document segment of the document segment to the document segment; Wherein, the M and the N are positive integers.
4. The method according to claim 1, characterized in that: Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by: Obtaining initial model recognition results of partially overlapping areas in two adjacent document fragments; When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are inconsistent, determining that there is a recognition anomaly in the initial model recognition results of the two adjacent document fragments; When it is recognized that the initial model recognition results of the partially overlapping areas in the two adjacent document fragments are consistent, determining that there is no recognition anomaly in the initial model recognition results of the two adjacent document fragments; The step of adjusting the document fragments corresponding to the recognition anomaly includes: The two adjacent document fragments are merged into one document fragment.
5. The method according to claim 1, characterized in that Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by: Constructing a directory tree of the target document according to the initial model recognition results of the document element recognition model on the multiple document fragments; Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments according to the directory tree.
6. The method according to claim 5, characterized in that The determining, according to the directory tree, whether there is any recognition anomaly in the initial model recognition results of the plurality of document fragments includes: Identify whether the directory tree has at least one of the following structural abnormal features: there are unnumbered paragraphs or paragraphs with unordered numbers in the directory tree; there are paragraphs with higher levels than the parent paragraphs of the child paragraph interval in the sub-level paragraph interval of the directory tree; the levels of paragraphs in the same numbered continuous paragraph interval in the directory tree are inconsistent; In the case where it is identified that the directory tree has at least one of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments have recognition abnormalities; in the case where it is identified that the directory tree does not have any of the above structural abnormality features, it is determined that the initial model recognition results of the multiple document fragments do not have recognition abnormalities; The step of adjusting the document fragments corresponding to the recognition anomaly includes: The continuous paragraphs in the target document having at least one of the above structural abnormal features are adjusted to the same document segment.
7. The method according to claim 1, characterized in that Determine whether there are recognition anomalies in the initial model recognition results of the multiple document fragments by: Determining whether there is a recognition anomaly in the initial model recognition result of the document segment according to the paragraph format attributes of the paragraph in the document segment; The step of adjusting the document fragments corresponding to the recognition anomaly includes: Adjust the paragraphs in the page to which the document fragment corresponding to the recognition anomaly belongs to the same document fragment.
8. The method according to claim 1, characterized in that Before inputting the plurality of document fragments into the document element recognition model, the method further includes: identifying redundant content from paragraphs in the document fragment; The step of inputting the plurality of document fragments into the document element recognition model is performed using non-redundant content in the plurality of document fragments, wherein the non-redundant content refers to other content in the document fragments except the redundant content.
9. A document processing device, characterized in that: The device comprises: A document acquisition module is used to acquire the target document to be processed; A document segmentation module, used for segmenting the target document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content; A fragmentation recognition module, used for inputting the plurality of document fragments into a document element recognition model to obtain initial model recognition results of the document element recognition model on the plurality of document fragments; A secondary fragmentation module, configured to adjust the document fragments corresponding to the recognition anomalies when it is determined that the initial model recognition results of the plurality of document fragments have recognition anomalies; The segment recognition module is further used to input the adjusted document segment into the document element recognition model again to obtain a re-model recognition result of the document element recognition model on the adjusted document segment.
10. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a document processing program stored in the memory to implement the document processing method according to any one of claims 1 to 8.
11. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the document processing method according to any one of claims 1 to 8.