Document processing method and device, electronic equipment and storage medium
By preprocessing and identifying electronic documents, combined with the paragraph mapping relationship between the original document and the preprocessed document, the problem of inaccurate document content division is solved, the accuracy of feature type recognition is improved, and the content and format of the original document are retained.
Patent Information
- Application Number
- CN202411974205.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-18
AI Technical Summary
The prior art cannot accurately divide the content of electronic documents into reasonable paragraphs, resulting in deviations in subsequent element type identification.
By creating a copy of the document, preprocessing is performed according to the set preprocessing method, using the document element identification model to identify paragraphs, combining the paragraph mapping relationship between the original document and the preprocessed document, the paragraph recognition results in the original document are determined and corrected to improve the recognition accuracy.
Ensure that the document content can be correctly segmented, improve the accuracy of subsequent feature types recognition, and maximize the content and format of the original document.
Smart Images

Figure CN119849449A_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, the complexity and diversity of electronic documents pose many challenges to the recognition and analysis of models. The content of original documents is usually complex and contains multiple formats and elements, such as text, tables, and pictures. The positions and combinations of these elements in the document are varied, making document segmentation and element recognition extremely difficult. Traditional document processing tools often cannot accurately divide document content into reasonable paragraphs, resulting in deviations in subsequent element type recognition. Summary of the invention
[0004] The present application provides a document processing method, device, electronic device and storage medium to solve the technical problem in the prior art that the document content cannot be accurately divided into reasonable paragraphs, resulting in deviations in the element type identification of subsequent elements.
[0005] In a first aspect, the present application provides a document processing method, the method comprising:
[0006] Creating a copy document of the original document, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document;
[0007] Using the preprocessed document and the document element recognition model, obtaining a model recognition result of a paragraph in the preprocessed document, wherein the model recognition result includes an element type of the paragraph;
[0008] Based on the paragraph mapping relationship between the original document and the preprocessed document, and the model recognition result of the paragraph in the preprocessed document, the model recognition result of the paragraph in the original document is determined.
[0009] In a possible implementation, the method further includes:
[0010] The model recognition result of the paragraph in the preprocessed document is corrected to obtain a corrected recognition result of the paragraph in the preprocessed document.
[0011] In a possible implementation manner, the step of correcting the model recognition result of the paragraph in the preprocessed document to obtain the corrected recognition result of the paragraph in the preprocessed document includes:
[0012] According to the model recognition result of the paragraph in the preprocessed document, recall processing of the recall target is performed in the preprocessed document, and the revised recognition result of the paragraph in the preprocessed document is obtained according to the recall processing result of the recall target.
[0013] In a possible implementation manner, the step of correcting the model recognition result of the paragraph in the preprocessed document to obtain the corrected recognition result of the paragraph in the original document includes:
[0014] According to the paragraph format attributes of the paragraph in the preprocessed document, the model recognition result of the paragraph in the preprocessed document is verified for credibility, and the revised recognition result of the paragraph in the preprocessed document is determined according to the credibility verification result.
[0015] In a possible implementation, the method further includes:
[0016] According to the identified element types of the paragraphs in the original document, the paragraphs in the original document are rearranged to obtain a rearranged version of the original document.
[0017] In a possible implementation manner, preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document includes:
[0018] A non-standard typesetting style related to segmentation or paging is identified from the copy document, and the non-standard typesetting style is converted into a set standard typesetting style to obtain a pre-processed document.
[0019] In a possible implementation, the identifying a non-standard typesetting style from the copy document and converting the non-standard typesetting style into a set standard typesetting style includes:
[0020] Identifying a non-standard segmentation style from the copy document, and converting the non-standard segmentation style into a set standard segmentation style; and / or,
[0021] Identifying a non-standard separation style from the copy document, and converting the non-standard separation style into a set standard separation style; and / or,
[0022] Identify a non-standard numbering style from the copy document, and convert the non-standard numbering style into a set standard numbering style;
[0023] A non-standard content style is identified from the copy document, and the non-standard content style is converted into a set standard content style.
[0024] In a possible implementation, the identifying a non-standard segmentation style from the copy document and converting the non-standard segmentation style into a set standard segmentation style includes:
[0025] Identifying a soft return character from the copy document and converting the soft return character into a paragraph marker character; and / or,
[0026] Identifying a separator that is attached to the paragraph content from the copy document, and inserting a paragraph marker between the separator and the paragraph content attached thereto; and / or,
[0027] Identifying a line ending with multiple consecutive space characters or tab characters from the copy document, deleting the multiple consecutive space characters or tab characters at the end of the line, and inserting a paragraph mark at the end of the line; and / or,
[0028] A paragraph including at least two numbers is identified from the copy document, and a paragraph marker is inserted before a number other than the first number in the paragraph.
[0029] In a possible implementation, the identifying a non-standard separation style from the copy document and converting the non-standard separation style into a set standard paging style includes:
[0030] Identifying a section break or page break at the end of a paragraph from the copy document, and moving the section break or page break at the end of the paragraph to the beginning of the next paragraph of the paragraph; and / or,
[0031] 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; and / or,
[0032] A paragraph with paragraph attributes set is identified from the copy document, the first paragraph of the next page is determined according to the paragraph attributes set for the paragraph, and a page break is inserted at the beginning of the first paragraph of the next page.
[0033] In a possible implementation, the identifying a non-standard numbering style from the copy document and converting the non-standard numbering style into a set standard numbering style includes:
[0034] A number set with an automatic numbering style is identified from the copy document, and the automatic numbering style setting is canceled for the number.
[0035] In a possible implementation manner, the identifying a non-standard content style from the copy document and converting the non-standard content style into a set standard content style includes:
[0036] identifying a domain element from the copy document, determining a domain result for the domain element, and replacing the domain element with the domain result in the copy document; and / or,
[0037] Revision content with a revision mark is identified from the copy document, revised content of the revision content is determined, and the revision content is replaced with the revised content in the copy document.
[0038] In a possible implementation manner, the using the preprocessed document and the document element recognition model to obtain a model recognition result of a paragraph in the preprocessed document includes:
[0039] identifying redundant content from paragraphs of the preprocessed document;
[0040] Using a document element recognition model to perform document recognition on non-redundant content in the preprocessed document to obtain a model recognition result of a paragraph in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content;
[0041] The model recognition result of the paragraph in the preprocessed document is determined according to the model recognition result of the paragraph in the non-redundant content and the redundant content.
[0042] In a possible implementation manner, before identifying redundant content from the paragraphs of the preprocessed document, the method further includes:
[0043] According to the set fragmentation rules, the preprocessed document is divided into multiple document fragments;
[0044] For the multiple document segments, the steps of identifying redundant content from the paragraphs of the preprocessed document and subsequent steps are performed.
[0045] In a second aspect, the present application provides a document processing device, the device comprising:
[0046] The copy processing module is used to create a copy document of the original document, and pre-process the copy document according to a set pre-processing method to obtain a pre-processed document;
[0047] A model recognition module, used to obtain a model recognition result of a paragraph in the preprocessed document using the preprocessed document and the document element recognition model, wherein the model recognition result includes an element type of the paragraph;
[0048] The result determination module is used to determine the model recognition result of the paragraph in the original document based on the paragraph mapping relationship between the original document and the preprocessed document and the model recognition result of the paragraph in the preprocessed document.
[0049] In a possible implementation, the device further includes:
[0050] The correction module is used to correct the model recognition result of the paragraph in the preprocessed document to obtain the corrected recognition result of the paragraph in the preprocessed document.
[0051] In a possible implementation, the correction module includes:
[0052] The recall unit is used to perform recall processing of the recall target in the preprocessed document according to the model recognition result of the paragraph in the preprocessed document, and obtain the corrected recognition result of the paragraph in the preprocessed document according to the recall processing result of the recall target.
[0053] In a possible implementation, the correction module includes:
[0054] The query unit is used to verify the credibility of the model recognition result of the paragraph in the preprocessed document according to the paragraph format attributes of the paragraph in the preprocessed document, and determine the corrected recognition result of the paragraph in the preprocessed document according to the credibility verification result.
[0055] In a possible implementation, the device further includes:
[0056] The rearrangement module is used to rearrange the paragraphs in the original document according to the identified element types of the paragraphs in the original document to obtain a rearranged version of the original document.
[0057] In a possible implementation manner, the replica processing module is specifically used to:
[0058] A non-standard typesetting style related to segmentation or paging is identified from the copy document, and the non-standard typesetting style is converted into a set standard typesetting style to obtain a pre-processed document.
[0059] In a possible implementation, the replica processing module includes:
[0060] A standard segmentation conversion unit, used for identifying a non-standard segmentation style from the copy document, and converting the non-standard segmentation style into a set standard segmentation style;
[0061] A standard separation conversion unit, used for identifying a non-standard separation style from the copy document, and converting the non-standard separation style into a set standard separation style;
[0062] A standard number conversion unit, used for identifying a non-standard numbering style from the copy document, and converting the non-standard numbering style into a set standard numbering style;
[0063] The standard content conversion unit is used to identify the non-standard content style from the copy document and convert the non-standard content style into a set standard content style.
[0064] In a possible implementation manner, the standard segment conversion unit is specifically used to:
[0065] Identifying a soft return character from the copy document and converting the soft return character into a paragraph marker character; and / or,
[0066] Identifying a separator that is attached to the paragraph content from the copy document, and inserting a paragraph marker between the separator and the paragraph content attached thereto; and / or,
[0067] Identify a line ending with multiple consecutive space characters or tab characters from the copy document, delete the multiple consecutive space characters or tab characters at the end of the line, and insert a paragraph mark at the end of the paragraph; and / or,
[0068] A paragraph including at least two numbers is identified from the copy document, and a paragraph marker is inserted before a number other than the first number in the paragraph.
[0069] In a possible implementation manner, the standard partition conversion unit is specifically used to:
[0070] Identifying a section break or page break at the end of a paragraph from the copy document, and moving the section break or page break at the end of the paragraph to the beginning of the next paragraph of the paragraph; and / or,
[0071] Identify a page ending with continuous blank lines from the copy document, insert a page break at the beginning of the first line of the next page of the page, and delete the continuous blank segments at the end of the page; and / or,
[0072] A paragraph with paragraph attributes set is identified from the copy document, the first paragraph of the next page is determined according to the paragraph attributes set for the paragraph, and a page break is inserted at the beginning of the first paragraph of the next page.
[0073] In a possible implementation manner, the standard number conversion unit is specifically used to:
[0074] A number set with an automatic numbering style is identified from the copy document, and the automatic numbering style setting is canceled for the number.
[0075] In a possible implementation manner, the standard content conversion unit is specifically used to:
[0076] identifying a domain element from the copy document, determining a domain result for the domain element, and replacing the domain element with the domain result in the copy document; and / or,
[0077] Revision content with a revision mark is identified from the copy document, revised content of the revision content is determined, and the revision content is replaced with the revised content in the copy document.
[0078] In a possible implementation, the model identification module includes:
[0079] A redundant refinement element is used to identify redundant content from the paragraphs of the preprocessed document; a document element recognition model is used to perform document recognition on the non-redundant content in the preprocessed document to obtain a model recognition result of the paragraphs in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content;
[0080] A model result determination unit is used to determine the model recognition result of the paragraph in the preprocessed document according to the model recognition result of the paragraph in the non-redundant content and the redundant content.
[0081] In a possible implementation, the device further includes:
[0082] A document fragmentation unit, configured to, before identifying redundant content from the paragraphs of the preprocessed document, fragment the preprocessed document into a plurality of document fragments according to a set fragmentation rule;
[0083] The redundancy reduction element is used to perform the steps of identifying redundant content from the paragraphs of the preprocessed document and subsequent steps for the multiple document fragments.
[0084] 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.
[0085] 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.
[0086] 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, by creating a copy document of the original document, preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document, and using the preprocessed document and the document element recognition model to obtain the model recognition result of the paragraph in the preprocessed document, can ensure that the content in the document can be correctly segmented, thereby improving the accuracy of the recognition result of the subsequent use of the model to identify the paragraph element type. At the same time, during the document processing process, the content and format of the original document are retained to the greatest extent, which provides a basis for the subsequent server to further analyze and verify, adjust and optimize the model recognition results based on the original content and format in the original document, so as to improve the accuracy of the element type recognition results of the paragraph in the original document that are finally determined. BRIEF DESCRIPTION OF THE DRAWINGS
[0087] 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.
[0088] 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.
[0089] 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.
[0090] Figure 1 A schematic diagram of a system architecture involved in an embodiment of the present application;
[0091] Figure 2 A flowchart of an embodiment of a document processing method provided in an embodiment of the present application;
[0092] Figure 3 A diagram comparing the effects of using soft and hard carriage returns for text content.
[0093] Figure 4 A diagram showing the attachment of separators to content and the correct segmentation structure;
[0094] Figure 5 This is a schematic diagram of the segmentation effect of a space character or a tab character;
[0095] Figure 6This is a schematic diagram showing the effect of text content not being segmented correctly;
[0096] Figure 7 A schematic diagram of using consecutive blank lines to achieve paging effect;
[0097] Figure 8 A flowchart of another document processing method provided in an embodiment of the present application;
[0098] Fig. 9 A flowchart of another document processing method provided in an embodiment of the present application;
[0099] Fig.10 A flowchart of another document processing method provided in an embodiment of the present application;
[0100] Fig.11 A flowchart of another document processing method provided in an embodiment of the present application;
[0101] Fig.12 A flowchart of another document processing method provided in an embodiment of the present application;
[0102] Fig.13 Flowchart of another document processing method provided in the embodiment of the present application
[0103] Fig.14 A block diagram of an embodiment of a document processing device provided in an embodiment of the present application;
[0104] Fig.15 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0105] 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.
[0106] 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.
[0107] In order to solve the technical problem in the prior art that the document content cannot be accurately divided into reasonable paragraphs, resulting in deviations in the element type identification of subsequent elements, the present application provides a document processing method that can enable the content in the document to be correctly segmented, thereby improving the accuracy of the recognition results of subsequent paragraph element type identification using a model.
[0108] Figure 1 Schematic diagram of a system architecture involved in an embodiment of the present application. Figure 1 As 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.
[0109] 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.
[0110] 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.
[0111] 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.
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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.
[0116] 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.
[0117] 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.
[0118] 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:
[0119] Step 201: Create a copy document of the original document, and preprocess the copy document according to a set preprocessing method to obtain a preprocessed document.
[0120] Step 202: using the preprocessed document and the document element recognition model, obtain a model recognition result of the paragraph in the preprocessed document, wherein the model recognition result includes the element type of the paragraph.
[0121] Step 203: Determine the model recognition result of the paragraph in the original document based on the paragraph mapping relationship between the original document and the preprocessed document and the model recognition result of the paragraph in the preprocessed document.
[0122] For ease of understanding and description, steps 201 to 203 are explained uniformly below:
[0123] The original document is the client (for example Figure 1 The client 101 shown in the example sends a document automatic typesetting request to the server and attaches the document that needs typesetting.
[0124] It can be seen from the description of step 201 and step 202 that when the server receives the original document from the client and the automatic typesetting request for the original document, it first creates a copy of the original document, namely the copy document, and then pre-processes and analyzes and identifies the copy document. In other words, the copy document is created for subsequent pre-processing and analysis and identification to ensure that the content and format of the original document will not be directly modified or destroyed during the entire processing process, thereby protecting the security and integrity of the original document. On the one hand, this allows the server to process documents more flexibly without worrying about irreversible changes to the original document. On the other hand, the server can subsequently further analyze and verify, adjust and optimize the model recognition results of the model end based on the original content and format in the original document, so as to improve the accuracy of the element type recognition results of the paragraphs in the original document that are finally determined.
[0125] In the technical solution of the embodiment of the present application, the key purpose of preprocessing the copy document 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. On this basis, as described in steps 201 and 202, by preprocessing the copy document, a preprocessed document in which the content is correctly segmented is obtained, and then the preprocessed document is used to identify the paragraph element type. This processing method can improve the accuracy of the paragraph element type recognition result.
[0126] In one embodiment, the copy document is preprocessed according to a set preprocessing method to obtain a preprocessed document. The set preprocessing method includes a set of document processing operations, and these document processing operations are intended to ensure that the content in the document can be correctly segmented. As for how to preprocess the copy document according to the set preprocessing method to obtain the preprocessed document, it will be explained below and will not be described in detail here.
[0127] In the process of pre-processing the copy document, a paragraph mapping relationship between the original document and the pre-processed document can also be established. Specifically, in the original document, a unique identifier (such as a paragraph number, a paragraph ID, etc.) is assigned to each paragraph. In the process of pre-processing 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 pre-processed document. In step 203, through the paragraph mapping relationship, the model recognition result of the paragraph in the pre-processed 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.
[0128] The technical solution provided by the embodiment of the present application creates a copy document of the original document, preprocesses the copy document according to a set preprocessing method, obtains a preprocessed document, and uses the preprocessed document and the document element recognition model to obtain the model recognition result of the paragraph in the preprocessed document, which can ensure that the content in the document can be correctly segmented, thereby improving the accuracy of the recognition result of the subsequent use of the model to identify the type of paragraph elements. At the same time, during the document processing process, the content and format of the original document are retained to the greatest extent, which provides a basis for the subsequent server to further analyze and verify, adjust and optimize the model recognition results based on the original content and format in the original document, so as to improve the accuracy of the element type recognition results of the paragraphs in the original document that are finally determined.
[0129] 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.
[0130] 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.
[0131] 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.
[0132] 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.
[0133] 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.
[0134] 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.
[0135] 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.
[0136] 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.
[0137] The following examples describe the following non-standard segmentation styles that may exist in the copy document and their corresponding conversion rules:
[0138] The first type: soft return segmentation
[0139] 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.
[0140] 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.
[0141] For example, see Figure 3 , which is a diagram comparing the effects of using soft carriage returns and hard carriage returns in text content.
[0142] The second type: the separator is glued to the content paragraph
[0143] 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 4 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 4 , 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.
[0144] 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.
[0145] 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 4 , where page 1 is an example of correct paragraph structure. Figure 4 As 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 4 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 4 The string in page 1 and the string in page 2 are correctly identified as two paragraphs.
[0146] 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 4 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 4 Change page 2 in to "I am a free paragraph hard return section break at the top of the page (next page)".
[0147] The third type: space or tab segment
[0148] 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 5 , which is a schematic diagram of the segmentation effect of space or tab characters.
[0149] 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.
[0150] The fourth case: the text content is not segmented
[0151] 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 6 , which is a schematic diagram of the effect of not correctly segmenting text content.
[0152] 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.
[0153] 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.
[0154] 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.
[0155] For example, the following non-standard separation styles may exist in the copy document:
[0156] The first type: Section / page break paging
[0157] 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.
[0158] 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.
[0159] The second type: paragraph break and line break
[0160] 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 Figure 7 , a schematic diagram of using consecutive blank lines to achieve paging effect
[0161] 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.
[0162] 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.
[0163] The third type: paragraph attribute paging
[0164] 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.
[0165] 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.
[0166] 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.
[0167] 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.
[0168] 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.
[0169] 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.
[0170] 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.
[0171] 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.
[0172] 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.
[0173] 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.
[0174] 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.
[0175] 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 the preprocessed document to be processed, which can ensure that the content in the preprocessed document is correctly segmented, thereby improving the accuracy of identifying and streamlining redundant content in the document.
[0176] 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 also proposes: through the collaboration between the server end 102 and the model end 103, before submitting the document to the model, the document content can be filtered, streamlined, and other operations can be performed first, aiming to eliminate information in the document that is useless or unhelpful for the model to identify the element type, so as to improve the recognition efficiency of the model and reduce its computational burden.
[0177] Figure 8 A flowchart of another document processing method provided in an embodiment of the present application. Figure 8 The process shown in Figure 2 Based on the process shown, the following steps are included:
[0178] Step 801: Obtain a preprocessed document of an original document.
[0179] Step 802: Identify redundant content from the paragraphs of the preprocessed document, where the redundant content is the paragraphs of the determined element type.
[0180] From the above description, we can know that in real and valid text content, there are also some paragraphs whose element types can be directly determined by the server based on the paragraph format. For these paragraphs whose element types can be directly determined by the server, there is no need to perform tedious analysis and identification through the model.
[0181] The real and effective text content is the text content in the document that can be rendered as visible pixels after typesetting. For example, if the tab character is set not to be displayed, the rendered document will not display the text content of the tab character during display, that is, the visible pixels corresponding to the tab character will not be displayed, but will be displayed as blank.
[0182] Therefore, in step 802, paragraphs whose element types can be determined on the server side are identified from the paragraphs of the preprocessed document, and these paragraphs are regarded as redundant content. Redundant content here refers to information that no longer needs to be repeatedly processed for the model to perform the element type identification task.
[0183] In one embodiment, the specific implementation of identifying redundant content from paragraphs of the preprocessed document includes: identifying paragraphs that meet a specific element format from the paragraphs of the preprocessed document (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.
[0184] 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.
[0185] 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 pre-processed document 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.
[0186] 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 the clause are usually integrated in one paragraph, which results in a large number of words in the paragraph and relatively complex content. If the 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 preprocessed document whose paragraph length exceeds the set length threshold as redundant content according to the category of the preprocessed document. This method can better meet the needs of practical applications when facing various document processing needs.
[0187] 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.
[0188] 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.
[0189] In addition, the preprocessed document may also contain empty paragraphs, that is, paragraphs formed by space characters, which have no substantial content, so there is no need for the model to identify the element type. Therefore, the empty paragraphs can also be identified from the preprocessed document and determined as redundant content.
[0190] Step 803: Use the document element recognition model to perform document recognition on the non-redundant content in the preprocessed document to obtain the model recognition results of the paragraphs in the non-redundant content. The non-redundant content refers to the other content in the preprocessed document except the redundant content. The model recognition results include the element type of the paragraph.
[0191] It can be seen from the description of step 803 that, in one embodiment, only the content other than the redundant content determined in the aforementioned step 802 in the preprocessed document (referred to as non-redundant content) will be sent to the model side, and the model side will call the document element recognition model to perform element type recognition on the paragraphs in this part of non-redundant content, thereby enabling the model to complete the element type recognition task more efficiently and accurately.
[0192] Step 804: Determine the final recognition result of the paragraph in the preprocessed document according to the model recognition result of the paragraph in the non-redundant content and the element type of the paragraph in the redundant content.
[0193] It can be known from the description of the above steps that the element type of the paragraph in the redundant content is determined on the server side. For example, the server side determines the element type of the first paragraph according to the specific element format satisfied by the paragraph in the redundant content (i.e., the first paragraph). The element type of the paragraph in the non-redundant content is determined by the model side. Then, according to the model recognition result of the paragraph in the non-redundant content and the element type determined by the server side for the paragraph in the redundant content, the final recognition result of the paragraph in the preprocessed document can be determined.
[0194] Exemplarily, in the process of identifying redundant content from the paragraphs of the preprocessed document, the identifier of the paragraph in the non-redundant content is determined, and then in the process of the document element recognition model performing document recognition on the non-redundant content in the preprocessed document, a mapping relationship between the paragraph identifier and the model recognition result can be established. In step 204, through the mapping relationship, the model recognition result can be mapped back to the corresponding paragraph in the preprocessed document, thereby determining the model recognition result of the paragraph in the non-redundant content in the preprocessed document.
[0195] 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, etc. 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, before sending the above-mentioned non-redundant content to the model end, the formatting attributes of the non-redundant content can also be ignored to reduce the burden on the model and avoid increasing the complexity of the model's processing tasks due to the model's failure to recognize complex formatting attributes, which also leads to a decrease in recognition accuracy.
[0196] Figure 8The process shown in the figure identifies paragraphs of determined element types from paragraphs of the preprocessed document of the original document as redundant content, and uses the document element recognition model to perform document recognition on the non-redundant content in the preprocessed document to obtain the model recognition results of the paragraphs in the non-redundant content. The non-redundant content refers to the other content in the preprocessed document except the redundant content. According to the model recognition results of the paragraphs in the non-redundant content and the redundant content, the final recognition results of the paragraphs in the preprocessed document are determined, thereby realizing the 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 of the model.
[0197] In actual application scenarios, we often encounter electronic documents of huge volume, which contain hundreds or thousands of pages and are extremely rich in 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, the relevant technology proposes 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 find the best balance between efficiency and recognition accuracy, and ensure that the document element recognition model can perform at its maximum performance with limited computing resources.
[0198] 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.
[0199] Fig. 9 A flowchart of another document processing method provided in an embodiment of the present application. Fig. 9 The process shown in Figure 2 Based on the process shown, the following steps are included:
[0200] Step 901: Obtain a preprocessed document of an original document.
[0201] Step 902: Segment the preprocessed document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content.
[0202] In one embodiment, the preprocessed document is segmented into a plurality of document segments according to a set segmentation rule.
[0203] 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 preprocessed 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.
[0204] According to the set fragmentation rules, the preprocessed 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 make the key information and contextual connections in the preprocessed document 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.
[0205] For example, the preprocessed 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.
[0206] Step 903: 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.
[0207] Step 904: 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.
[0208] For ease of understanding, step 903 and step 904 are explained uniformly below:
[0209] 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 pre-processed 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.
[0210] Fig. 9 The process shown in the figure divides the preprocessed document of the original document into multiple document fragments according to the set fragmentation rules, wherein two adjacent document fragments have a partial overlapping area in 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. A method of secondary document fragmentation and recognition is provided. 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.
[0211] exist Figure 8 and Fig. 9On the basis of the illustrated embodiment process, the present application also provides the following embodiments: firstly, the pre-processed document of the original document is segmented, and then the redundant content is processed and the non-redundant content is simplified for the document segmented. Compared with first processing the redundant content of the pre-processed 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 pre-processed 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 is processed and the non-redundant content is simplified for the document segmented, 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 preprocessed 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.
[0212] exist Figure 1 In the exemplary application scenario, the reason why the server 102 receives the model recognition result returned by the model end 103 and then uses its own algorithm and computing resources to further analyze and verify the model recognition result returned by the model end 103 is that: on the one hand, before sending the document to the model end for analysis and recognition, the server 102 usually performs some processing work on the document, such as eliminating useless or unhelpful information in the document for the model to identify the element type, so as to improve the recognition efficiency of the model and reduce its computational burden. For another example, the document (which can be the document after some information is eliminated as mentioned above) is fragmented, and the model recognition is performed on the fragments as units, aiming to find the best balance between recognition efficiency and recognition accuracy, and ensure that the document element recognition model can play the maximum performance under limited computing resources. Although these processing works are intended to improve the recognition efficiency of the model and reduce the model burden, they may also introduce some potential problems, such as the model missing recognition or recognition errors, because the model cannot obtain global information and there is an information gap with the server. On the other hand, the model cannot completely avoid the problem of limited recognition ability in the face of complex and ever-changing document structures and contents, such as failure to recognize certain specific information or inaccurate boundary demarcation of certain elements.
[0213] In view of this, the embodiments of the present application also propose to utilize the recognition results of the model on the server side, combined with a rule-based recall method, to recall and correct the elements that the model fails to accurately recognize, thereby improving the accuracy and completeness of document element type recognition.
[0214] Fig.10 A flowchart of another document processing method provided in an embodiment of the present application. Fig.10 As shown, the process includes the following steps:
[0215] Step 1001: Obtain a preprocessed document of an original document, and use a document element recognition model to determine a model recognition result of a paragraph in the preprocessed document, wherein the model recognition result includes: an element type of the paragraph determined by the document element recognition model.
[0216] Step 1002: According to the model recognition result of the paragraph in the preprocessed document and the recall rule corresponding to the set recall target, recall processing of the recall target is performed in the preprocessed document.
[0217] Recall targets refer to objects that need to be recalled by the server. In actual applications, these objects may not be accurately identified due to the limitations of the model. Recall targets can be specific document areas, such as embedded sub-document areas, chapter preamble areas, appendix areas, directory areas, etc. At the same time, recall targets can also include specific types of elements, such as the "main recipient" in official documents, "keywords" and "conclusion" in papers, etc.
[0218] Recall rules are rules formulated according to the specific needs of recall target identification. These rules may be formulated based on the structural characteristics of the recall target (such as paragraph position, format, etc.), content characteristics (such as keywords, specific sentence patterns, etc.) or comprehensive consideration of contextual information.
[0219] Recall processing of recall targets in the preprocessed document means: combining the model recognition results of the paragraphs in the preprocessed document, applying the recall rules corresponding to the recall targets, and recalling the recall targets that the document element recognition model fails to accurately identify. This may involve reclassifying the misclassified recall targets to the correct element type, or identifying the recall targets that were missed by the document element recognition model and classifying them into the correct element type recognition results.
[0220] Generally, different recall targets correspond to different recall rules. Therefore, for different recall targets, the specific recall processing procedures are also different. We will not go into details here. We will discuss the specific recall processing procedures for different recall targets in the following text.
[0221] Step 1003: Determine the element type of the paragraph in the document after preprocessing according to the recall processing result of the recall target and the model recognition result of the paragraph in the document, wherein the recall processing result includes: the element type of the paragraph determined by the recall processing.
[0222] It can be seen from the description of step 1003 that, by applying the technical solution provided in the embodiment of the present application, the element type of the paragraph determined in the recall processing result is combined with the model recognition result to form the final element type recognition result of the paragraph in the preprocessed document.
[0223] In one embodiment, for paragraphs that are set as recall targets and obtain accurate element types through recall processing, the results of the recall processing are adopted as the final element types of these paragraphs. For paragraphs that are not set as recall targets, or are set as recall targets but fail to provide clear element types through recall processing, the final element types of these paragraphs are determined based on the model recognition results.
[0224] Fig.10 The process shown in the figure performs recall processing of the recall target in the preprocessed document according to the model recognition result of the paragraph in the preprocessed document and the recall rule corresponding to the set recall target, and determines the element type of the paragraph in the preprocessed document according to the recall processing result of the recall target and the model recognition result of the paragraph in the preprocessed document. This provides a scheme for identifying the element type of the paragraph in the document by combining the recognition capability of the document element recognition model and the rule-based recall strategy. This scheme realizes the complementary advantages between the recognition capability of the document element recognition model and the rule-based recall strategy, and can recall the element types that the model cannot recognize or cannot accurately recognize from the preprocessed document, thereby improving the accuracy and completeness of document element type recognition.
[0225] exist Figure 1In the exemplary application scenario shown, the reason why the server 102 uses its own algorithm and computing resources to further analyze and verify the model recognition results returned by the model end 103 after receiving the model recognition results returned by the model end 103 is that: before sending the document to the model end for analysis and recognition, the server 102 usually performs some processing on the document, such as removing information in the document that is useless or unhelpful for the model to identify the element type, so as to improve the recognition efficiency of the model and reduce its computational burden. Such useless or unhelpful information usually includes the format attributes of the paragraphs in the document, such as font, font size, bold, italic, underline, alignment and other format attributes. The document element recognition model usually does not pay attention to the format attributes of the paragraph when identifying the element type of the 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. For another example, documents (which can be the documents after some information is removed) are segmented and model recognition is performed on the segments, aiming to find the best balance between recognition efficiency and recognition accuracy, and to ensure that the document element recognition model can perform at its best under limited computing resources. Although such processing work is aimed at improving the recognition efficiency of the model and reducing the model burden, it may also introduce some potential problems, such as model recognition errors.
[0226] In view of this, an embodiment of the present application proposes to provide a mechanism on the server side for further analyzing and verifying the model recognition result returned by the model side to improve the accuracy of the final recognition result.
[0227] Fig.11 This is a flowchart of another document processing method provided in the present application. Fig.11 As shown, the process includes the following steps:
[0228] Step 1101: Determine a model recognition result of a paragraph in an original document using a document element recognition model. The model recognition result includes: an element type of the paragraph determined by the document element recognition model.
[0229] The document element recognition model is a model used to identify the element types of paragraphs in a document (such as abstract, title, body, etc.). Figure 1 In the system architecture shown, the document element recognition model is deployed on the model end 103. Exemplarily, the document element recognition model is a deep learning model or a neural network model.
[0230] In step 1101, the server uploads the original document or the processed document to the model side, so that the model side calls the document element recognition model to recognize the element type of the paragraph. The recognition result here is recognized by the document element recognition model, so it is called the model recognition result.
[0231] In one embodiment, the specific implementation of using the document element recognition model to determine the model recognition result of the paragraph in the original document includes: creating a copy document of the original document, preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document; using the preprocessed document and the document element recognition model to obtain the model recognition result of the paragraph in the preprocessed document; based on the paragraph mapping relationship between the original document and the preprocessed document, and the model recognition result of the paragraph in the preprocessed document, determine the model recognition result of the paragraph in the original document. As for the specific implementation of this embodiment, it is explained below and will not be described in detail here.
[0232] Step 1102: According to the model recognition results of the paragraphs in the original document, the suspected body paragraphs are determined from the original document, and the suspected body paragraphs refer to the paragraphs whose model recognition results are body paragraphs.
[0233] Step 1103: verify the credibility of the model recognition result of the suspected body paragraph according to the paragraph format attributes of the suspected body paragraph in the original document, and determine the final recognition result of the suspected body paragraph according to the credibility verification result.
[0234] For ease of understanding, step 1102 and step 1103 are described uniformly below:
[0235] It can be seen from the description of step 1102 and step 1103 that further analysis and verification is performed on the part of the original document that is identified as the main text by the model. The reason for this processing is that the document element recognition model has certain particularities in its operating mechanism. Specifically, the document element model adopts a forward recognition method for other element types other than the main text, such as abstracts, directories and other element types. That is, these elements are directly identified and divided according to features and information. However, for the main text, the document element recognition model adopts a reverse recognition strategy. The so-called reverse recognition means that the document element recognition model determines the content in the document other than the target content (other clearly identified element types other than the main text) as the main text. Although this recognition method simplifies the processing flow to a certain extent, it may also bring problems with recognition accuracy, especially in some complex or structured documents, the main text part may be difficult to accurately divide from other elements directly through reverse recognition. In order to ensure the reliability and accuracy of the recognition results, the embodiment of the present application proposes to regard the text paragraphs identified by the document element recognition model as suspected text paragraphs. That is to say, the server does not directly adopt the model recognition results for the text paragraphs identified by the document element recognition model, but refers to the model recognition results and regards the text paragraphs identified by the document element recognition model as suspected text paragraphs. Subsequently, the server further conducts in-depth analysis based on the paragraph format attributes of these suspected text paragraphs in the original document, aiming to verify the credibility of the model recognition results of the suspected text paragraphs, and determine the final recognition results of the suspected text paragraphs based on the credibility verification results.
[0236] Among them, the credibility verification result includes two possible results: one is credible, and the other is doubtful. If the suspected text paragraph is judged to be credible after the credibility verification, then the server can determine the suspected text paragraph as the text paragraph, and then assign the corresponding text style to the confirmed text paragraph in the automatic typesetting process. However, if the suspected text paragraph is judged to be doubtful after the credibility verification, the server can consider that there is uncertainty in the text identity of the suspected text paragraph. In this case, the suspected text paragraph can be re-identified in order to obtain a more accurate identification result. As for how to perform secondary identification on the suspected text paragraph in doubt, it will be explained through specific embodiments in the following text, which will not be described in detail here.
[0237] So why is the credibility of the model recognition result of the suspected body paragraph verified based on the paragraph format attributes of the suspected body paragraph in the original document? The reasons include the following two aspects: On the one hand, as can be seen from the above description, before sending the document to the document element recognition model for analysis and recognition, the server usually performs some processing on the document, such as removing useless or unhelpful information in the document for the model to identify the element type, so as to improve the recognition efficiency of the model and reduce its computational burden. This part of useless or unhelpful information usually includes the format attributes of the paragraph in the document. Then, the document element recognition model does not use the format attributes of the paragraph in the document during the process of element type recognition. On the other hand, in the actual application of documents, the paragraph format attributes are not only a visual presentation method, but also an important part of the document structure. For the body paragraph, the body paragraph usually has consistent paragraph format attributes, such as uniform font, font size and alignment, etc., while the paragraphs of other element types other than the body paragraph often have their own unique characteristics in paragraph format attributes. For example, the title paragraph is usually short and may use a larger font size and bold font. Another example is that the paragraph on the cover may be right-aligned or centered and arranged vertically. It can be seen that from the perspective of paragraph format attributes, it is possible to better distinguish the main content from other types of content.
[0238] Accordingly, in the technical solution provided in the embodiment of the present application, the credibility of the model recognition result of the suspected body text paragraph is verified according to the paragraph format attributes of the suspected body text paragraph in the original document.
[0239] Fig.11 The process shown uses the document element recognition model to determine the model recognition results of the paragraphs in the original document. Based on the model recognition results of the paragraphs in the original document, the suspected body paragraphs are determined from the original document. The suspected body paragraphs refer to the paragraphs whose model recognition results are body text. Based on the paragraph format attributes of the suspected body paragraphs in the original document, the model recognition results of the suspected body paragraphs are verified for credibility, and the final recognition results of the suspected body paragraphs are determined based on the credibility verification results. This solution not only relies on the model's recognition results of the paragraph element types in the document, but also combines the paragraph format attributes to further analyze and verify the model's recognition results. This method can significantly improve the accuracy and reliability of the document element recognition results, and provide a more solid foundation for subsequent document processing, such as editing, typesetting and other processing tasks.
[0240] Fig.12 A flowchart of another document processing method provided in an embodiment of the present application. Fig.12 The process shown in the figure describes how to rearrange the original document based on any of the above embodiments. The process includes the following steps:
[0241] Step 1201: Determine the element type of the paragraph in the original document to be typeset.
[0242] Step 1202: perform paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and reset the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph to obtain a reformatted version of the original document.
[0243] Fig.12 The process shown determines the element type of the paragraphs in the original document to be typeset, performs paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and resets the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph, so as to obtain a reformatted document of the original document. Before the paragraphs in the original document are reformatted, it is possible to pre-identify and eliminate potential paragraph attributes that conflict with the style required for the reformatting, or paragraph attributes that are likely to interfere with the subsequent reformatting, thereby ensuring that the document will not cause typesetting errors due to format conflicts or interference during the reformatting process, thereby improving the quality of the document reformatting and obtaining a reformatted document that meets expectations.
[0244] Fig.13 A flowchart of another document processing method provided in an embodiment of the present application. Fig.13 The process shown in Fig.12 Based on the embodiment process, the following steps are included:
[0245] Step 1301: Determine the element type of the paragraph in the original document to be typeset.
[0246] Step 1302: perform paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and reset the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph to obtain the intermediate typesetting document of the original document.
[0247] For detailed description of step 1301 and step 1302, please refer to the relevant description in the above embodiment, which will not be repeated here.
[0248] Step 1303: Identify the incorrect typesetting styles related to segmentation or paging from the intermediate typesetting document, and correct the incorrect typesetting styles.
[0249] In the process of document typesetting, it is crucial to ensure the correctness of paragraphing and paging, which is directly related to the professionalism and readability of the document.
[0250] In one embodiment, erroneous typographical patterns related to paragraph or page breaks are identified based on preset separation rules associated with regions of the document.
[0251] For example, in the typesetting specifications of some specific categories of documents, there are clear requirements for independent paging between areas. Take thesis as an example, its structure usually includes multiple chapter pre-areas such as the cover, table of contents, abstract, etc. According to the typesetting specifications, these different chapter pre-areas need to be paginated independently, that is, each area should occupy an independent page to clearly separate the contents of each part. At the same time, the cover, as the starting page of the thesis, also needs to be an independent page.
[0252] However, in the actual typesetting process, erroneous paging or missing paging may occur. For example, erroneous paging is manifested as unnecessary paging in the same pre-chapter area, which causes the content in the same pre-chapter area to be divided, affecting the reader's reading experience. Missed paging is manifested as the content of different areas being mixed together and difficult to distinguish. In this regard, an embodiment of the present application proposes to identify erroneous typesetting styles related to segmentation or paging from the intermediate typesetting document, and correct the erroneous typesetting styles. For example, for erroneous paging, it is deleted according to the typesetting specifications to ensure that the content in the same pre-chapter area can be presented continuously. As for missed paging, page breaks are added at appropriate locations to ensure that each pre-chapter area can be an independent page, thereby meeting the requirements of the typesetting specifications.
[0253] Step 1304: perform typesetting optimization processing on the paragraphs in the intermediate typesetting document according to the set second cleaning rule, and use the original document after the typesetting optimization processing as the re-typesetting document of the original document.
[0254] In general, the second cleaning rule is used to optimize the layout of paragraphs in the original document as a whole, so that the final reformatted document is neater, clearer and more in line with the expected layout requirements.
[0255] In one embodiment, the specific implementation of typesetting optimization processing for paragraphs in the intermediate typesetting document according to the set second cleaning rule includes: according to the set second cleaning rule, identifying redundant typesetting elements from the intermediate typesetting document, and deleting redundant typesetting elements from the intermediate typesetting document.
[0256] Exemplarily, redundant layout elements include blank paragraphs between paragraphs, blank paragraphs at the beginning of a page, and extra separators, etc.
[0257] Among them, the blank paragraphs between paragraphs may be caused by the user inserting extra line breaks or paragraph separators intentionally or unintentionally when editing the document. These blank paragraphs will interrupt the coherence of the text and affect the reading experience. Therefore, the blank paragraphs between paragraphs can be cleared without being retained.
[0258] The empty paragraph at the top of a page refers to the empty paragraph at the beginning of a new page. The empty paragraph at the top of a page may be caused by the user accidentally inserting a page separator when editing a document, which conflicts with the manually added paragraph separator. It may also be caused by the user using an empty paragraph to divide pages or sections, and due to the page layout adjustment caused by the re-layout, the paragraph that was no longer at the top of the page is arranged at the beginning of a new page, and there is no other content before the paragraph, thus forming an empty paragraph. The empty paragraph at the top of a page affects the aesthetics of the page and occupies page space unnecessarily. Therefore, the empty paragraph at the top of a page can be cleared without being retained.
[0259] Extra separators, such as two repeated line breaks, may be caused by not completely clearing the formatting marks in the original document when copying and pasting text, or accidentally adding separators repeatedly during editing. These separators will interfere with the visual layout of the document and reduce readability. Therefore, you can delete the extra separators without retaining them.
[0260] In addition, in addition to the above common redundant elements of typesetting, it may also include repeated titles or subtitles, unnecessary table borders, excessive font style changes, etc. This embodiment of the present application does not limit this.
[0261] In addition, here, after the re-layout, the final visual effect of the document has been determined. In order to maintain the coherence of the text and the user's reading experience, deleting the blank paragraphs between paragraphs, the blank paragraphs at the top of the page, and the redundant separators may interrupt the coherence of the text and affect the reading experience. However, other non-standard typesetting styles are no longer concerned here. 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 the subsequent feature type recognition task. For example, the document creator uses space characters to achieve the 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.
[0262] Fig.13The process shown in the figure can effectively reduce or eliminate redundant layout elements in the document by optimizing the layout of the paragraphs in the intermediate layout document according to the set second cleaning rule, and use the original document after the layout optimization as the rearranged document of the original document, thereby improving the standardization of the rearranged document. By correcting the wrong paging or paragraphing style in the intermediate layout document, the overall layout effect of the document can be ensured to be optimal, thereby obtaining a rearranged document that better meets the layout specifications.
[0263] Fig.14 This is a block diagram of an embodiment of a document processing device provided in an embodiment of the present application. Fig.14 As shown, the device comprises:
[0264] The copy processing module 1401 is used to create a copy document of the original document, and pre-process the copy document according to a set pre-processing method to obtain a pre-processed document;
[0265] A model recognition module 1402 is used to obtain a model recognition result of a paragraph in the preprocessed document using the preprocessed document and the document element recognition model, wherein the model recognition result includes an element type of the paragraph;
[0266] The result determination module 1403 is used to determine the model recognition result of the paragraph in the original document based on the paragraph mapping relationship between the original document and the preprocessed document, and the model recognition result of the paragraph in the preprocessed document.
[0267] In a possible implementation, the device further includes:
[0268] The correction module is used to correct the model recognition result of the paragraph in the preprocessed document to obtain the corrected recognition result of the paragraph in the preprocessed document.
[0269] In a possible implementation, the correction module includes:
[0270] The recall unit is used to perform recall processing of the recall target in the preprocessed document according to the model recognition result of the paragraph in the preprocessed document, and obtain the corrected recognition result of the paragraph in the preprocessed document according to the recall processing result of the recall target.
[0271] In a possible implementation, the correction module includes:
[0272] The query unit is used to verify the credibility of the model recognition result of the paragraph in the preprocessed document according to the paragraph format attributes of the paragraph in the preprocessed document, and determine the corrected recognition result of the paragraph in the preprocessed document according to the credibility verification result.
[0273] In a possible implementation, the device further includes:
[0274] The rearrangement module is used to rearrange the paragraphs in the original document according to the identified element types of the paragraphs in the original document to obtain a rearranged version of the original document.
[0275] In a possible implementation, the replica processing module 1401 is specifically configured to:
[0276] A non-standard typesetting style related to segmentation or paging is identified from the copy document, and the non-standard typesetting style is converted into a set standard typesetting style to obtain a pre-processed document.
[0277] In a possible implementation, the copy processing module 1401 includes:
[0278] A standard segmentation conversion unit, used for identifying a non-standard segmentation style from the copy document, and converting the non-standard segmentation style into a set standard segmentation style;
[0279] A standard separation conversion unit, used for identifying a non-standard separation style from the copy document, and converting the non-standard separation style into a set standard separation style;
[0280] A standard number conversion unit, used for identifying a non-standard numbering style from the copy document, and converting the non-standard numbering style into a set standard numbering style;
[0281] The standard content conversion unit is used to identify the non-standard content style from the copy document and convert the non-standard content style into a set standard content style.
[0282] In a possible implementation manner, the standard segment conversion unit is specifically used to:
[0283] Identifying a soft return character from the copy document and converting the soft return character into a paragraph marker character; and / or,
[0284] Identifying a separator that is attached to the paragraph content from the copy document, and inserting a paragraph marker between the separator and the paragraph content attached thereto; and / or,
[0285] Identifying a line ending with multiple consecutive space characters or tab characters from the copy document, deleting the multiple consecutive space characters or tab characters at the end of the line, and inserting a paragraph mark at the end of the line; and / or,
[0286] A paragraph including at least two numbers is identified from the copy document, and a paragraph marker is inserted before a number other than the first number in the paragraph.
[0287] In a possible implementation manner, the standard partition conversion unit is specifically used to:
[0288] Identifying a section break or page break at the end of a paragraph from the copy document, and moving the section break or page break at the end of the paragraph to the beginning of the next paragraph of the paragraph; and / or,
[0289] 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; and / or,
[0290] A paragraph with paragraph attributes set is identified from the copy document, the first paragraph of the next page is determined according to the paragraph attributes set for the paragraph, and a page break is inserted at the beginning of the first paragraph of the next page.
[0291] In a possible implementation manner, the standard number conversion unit is specifically used to:
[0292] A number set with an automatic numbering style is identified from the copy document, and the automatic numbering style setting is canceled for the number.
[0293] In a possible implementation manner, the standard content conversion unit is specifically used to:
[0294] identifying a domain element from the copy document, determining a domain result for the domain element, and replacing the domain element with the domain result in the copy document; and / or,
[0295] Revision content with a revision mark is identified from the copy document, revised content of the revision content is determined, and the revision content is replaced with the revised content in the copy document.
[0296] In a possible implementation, the model identification module 1402 includes:
[0297] A redundant refinement element is used to identify redundant content from the paragraphs of the preprocessed document; a document element recognition model is used to perform document recognition on the non-redundant content in the preprocessed document to obtain a model recognition result of the paragraphs in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content;
[0298] A model result determination unit is used to determine the model recognition result of the paragraph in the preprocessed document according to the model recognition result of the paragraph in the non-redundant content and the redundant content.
[0299] In a possible implementation, the device further includes:
[0300] A document fragmentation unit, configured to, before identifying redundant content from the paragraphs of the preprocessed document, fragment the preprocessed document into a plurality of document fragments according to a set fragmentation rule;
[0301] The redundancy reduction element is used to perform the steps of identifying redundant content from the paragraphs of the preprocessed document and subsequent steps for the multiple document fragments.
[0302] like Fig.15 As 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.
[0303] Memory 113, used for storing computer programs;
[0304] 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:
[0305] Creating a copy document of the original document, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document;
[0306] Using the preprocessed document and the document element recognition model, obtaining a model recognition result of a paragraph in the preprocessed document, wherein the model recognition result includes an element type of the paragraph;
[0307] Based on the paragraph mapping relationship between the original document and the preprocessed document, and the model recognition result of the paragraph in the preprocessed document, the model recognition result of the paragraph in the original document is determined.
[0308] 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.
[0309] 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.
[0310] 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.
[0311] 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.
[0312] 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: Creating a copy document of the original document, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document; Using the preprocessed document and the document element recognition model, obtaining a model recognition result of a paragraph in the preprocessed document, wherein the model recognition result includes an element type of the paragraph; Based on the paragraph mapping relationship between the original document and the preprocessed document, and the model recognition result of the paragraph in the preprocessed document, the model recognition result of the paragraph in the original document is determined.
2. The method according to claim 1, characterized in that The method further comprises: The model recognition result of the paragraph in the preprocessed document is corrected to obtain a corrected recognition result of the paragraph in the preprocessed document.
3. The method according to claim 2, characterized in that The step of correcting the model recognition result of the paragraph in the preprocessed document to obtain a corrected recognition result of the paragraph in the preprocessed document includes: According to the model recognition result of the paragraph in the preprocessed document, recall processing of the recall target is performed in the preprocessed document, and the revised recognition result of the paragraph in the preprocessed document is obtained according to the recall processing result of the recall target.
4. The method according to claim 2, characterized in that: The step of correcting the model recognition result of the paragraph in the preprocessed document to obtain a corrected recognition result of the paragraph in the original document includes: According to the paragraph format attributes of the paragraph in the preprocessed document, the model recognition result of the paragraph in the preprocessed document is verified for credibility, and the revised recognition result of the paragraph in the preprocessed document is determined according to the credibility verification result.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: According to the identified element types of the paragraphs in the original document, the paragraphs in the original document are rearranged to obtain a rearranged version of the original document.
6. The method according to claim 1, characterized in that The preprocessing of the copy document according to the set preprocessing method to obtain the preprocessed document includes: A non-standard typesetting style related to segmentation or paging is identified from the copy document, and the non-standard typesetting style is converted into a set standard typesetting style to obtain a pre-processed document.
7. The method according to claim 6, characterized in that The step of identifying a non-standard typesetting style related to segmentation or paging from the copy document and converting the non-standard typesetting style into a set standard typesetting style includes: Identifying a non-standard segmentation style from the copy document, and converting the non-standard segmentation style into a set standard segmentation style; and / or, Identifying a non-standard separation style from the copy document, and converting the non-standard separation style into a set standard separation style; and / or, Identify a non-standard numbering style from the copy document, and convert the non-standard numbering style into a set standard numbering style; A non-standard content style is identified from the copy document, and the non-standard content style is converted into a set standard content style.
8. The method according to claim 7, characterized in that The step of identifying a non-standard segmentation style from the copy document and converting the non-standard segmentation style into a set standard segmentation style includes: Identifying a soft return character from the copy document and converting the soft return character into a paragraph marker character; and / or, Identifying a separator that is attached to the paragraph content from the copy document, and inserting a paragraph marker between the separator and the paragraph content attached thereto; and / or, Identifying a line ending with multiple consecutive space characters or tab characters from the copy document, deleting the multiple consecutive space characters or tab characters at the end of the line, and inserting a paragraph mark at the end of the line; and / or, A paragraph including at least two numbers is identified from the copy document, and a paragraph marker is inserted before a number other than the first number in the paragraph.
9. The method according to claim 7, characterized in that: The step of identifying a non-standard separation style from the copy document and converting the non-standard separation style into a set standard separation style includes: Identifying a section break or page break at the end of a paragraph from the copy document, and moving the section break or page break at the end of the paragraph to the beginning of the next paragraph of the paragraph; and / or, 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; and / or, A paragraph with paragraph attributes set is identified from the copy document, the first paragraph of the next page is determined according to the paragraph attributes set for the paragraph, and a page break is inserted at the beginning of the first paragraph of the next page.
10. The method according to claim 7, characterized in that The step of identifying a non-standard numbering style from the copy document and converting the non-standard numbering style into a set standard numbering style includes: A number set with an automatic numbering style is identified from the copy document, and the automatic numbering style setting is canceled for the number.
11. The method according to claim 7, characterized in that The step of identifying a non-standard content style from the copy document and converting the non-standard content style into a set standard content style includes: identifying a domain element from the copy document, determining a domain result for the domain element, and replacing the domain element with the domain result in the copy document; and / or, Revision content with a revision mark is identified from the copy document, revised content of the revision content is determined, and the revision content is replaced with the revised content in the copy document.
12. The method according to claim 1, characterized in that The method of obtaining a model recognition result of a paragraph in the preprocessed document by using the preprocessed document and the document element recognition model includes: identifying redundant content from paragraphs of the preprocessed document; Using a document element recognition model to perform document recognition on non-redundant content in the preprocessed document to obtain a model recognition result of a paragraph in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content; The model recognition result of the paragraph in the preprocessed document is determined according to the model recognition result of the paragraph in the non-redundant content and the redundant content.
13. The method according to claim 12, characterized in that Before identifying redundant content from the paragraphs of the preprocessed document, the method further includes: According to the set fragmentation rules, the preprocessed document is divided into multiple document fragments; For the multiple document segments, the steps of identifying redundant content from the paragraphs of the preprocessed document and subsequent steps are performed.
14. A document processing device, characterized in that: The device comprises: The copy processing module is used to create a copy document of the original document, and pre-process the copy document according to a set pre-processing method to obtain a pre-processed document; A model recognition module, used to obtain a model recognition result of a paragraph in the preprocessed document using the preprocessed document and the document element recognition model, wherein the model recognition result includes an element type of the paragraph; The result determination module is used to determine the model recognition result of the paragraph in the original document based on the paragraph mapping relationship between the original document and the preprocessed document and the model recognition result of the paragraph in the preprocessed document.
15. 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 13.
16. 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 13.