Document processing method and device, electronic equipment and storage medium

By determining the paragraph feature type in document re-arrangement and cleaning and resetting attributes, the problem that traditional methods are difficult to deal with complex paragraph attributes is solved, and high-quality document re-arrangement is achieved.

CN119849447APending Publication Date: 2025-04-18ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411974199.8
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

Technical Problem

Traditional document re-typed methods are difficult to deal with the complex and changeable paragraph attribute problems in the original document and are prone to typesetting errors.

Method used

By determining the feature type of the paragraph in the document to be typed, cleaning the paragraph attributes according to the set cleaning rules, and resetting the paragraph attributes according to the feature type, the rearranged document is obtained.

Benefits of technology

Effectively pre-identify and eliminate potential paragraph attribute conflicts, avoid typography errors, and improve the quality and accuracy of document retyping.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849447A_ABST
    Figure CN119849447A_ABST
Patent Text Reader

Abstract

The invention relates to a document processing method and device, electronic equipment and a storage medium. The method comprises the steps of determining element types of paragraphs in a to-be-typeset original document; performing paragraph attribute cleaning processing on paragraphs in the original document according to a set first cleaning rule, and resetting paragraph attributes for the cleaned paragraphs according to element types of the paragraphs to obtain a reset document of the original document. Therefore, the quality of document resetting can be improved, and the resetting document conforming to expectation is obtained.
Need to check novelty before this filing date? Find Prior Art

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 popularization of information-based office, electronic editing and typesetting of documents have become an indispensable part of daily work.

[0003] Original documents often contain multiple types of paragraphs, such as titles, text, lists, quotes, and image captions. Each type of paragraph has its own specific format requirements and property settings when typesetting. However, in actual operations, there are often improper or redundant paragraph property settings in original documents. These non-standard properties may conflict with the expected typesetting style, or cause format confusion in the subsequent re-typesetting process, thus affecting the overall aesthetics and readability of the document. Summary of the invention

[0004] The present application provides a document processing method, device, electronic device and storage medium to solve the technical problem that traditional document reformatting methods are difficult to cope with the complex and changeable paragraph attributes in the original document, thus easily causing typesetting errors.

[0005] In a first aspect, the present application provides a document processing method, the method comprising:

[0006] Determine the element type of the paragraph in the original document to be typeset;

[0007] The paragraphs in the original document are cleaned for paragraph attributes according to the set first cleaning rule, and the paragraph attributes of the cleaned paragraphs are reset according to the element type of the paragraph to obtain a rearranged version of the original document.

[0008] In a possible implementation, performing paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph, includes:

[0009] Traversing the paragraphs in the original document one by one;

[0010] For the currently traversed paragraph, when it is determined to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph in the original document is cleaned, and the paragraph attribute of the cleaned paragraph is reset according to the element type of the paragraph;

[0011] The method further comprises:

[0012] For the currently traversed paragraph, if it is determined not to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph attributes are reset according to the element type of the paragraph.

[0013] In a possible implementation, performing paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph, includes:

[0014] The paragraphs in the original document are cleaned for paragraph attributes according to the set first cleaning rule, and the style attributes corresponding to the element type of the paragraph are set for the cleaned paragraphs according to the element type of the paragraph.

[0015] In a possible implementation, the method further includes:

[0016] Determine the target format properties;

[0017] The format attributes of the paragraph after the style attributes are set are set according to the target format attributes.

[0018] In a possible implementation, determining the target format attribute includes:

[0019] A format attribute corresponding to the element type of the paragraph is acquired as a target format attribute.

[0020] In a possible implementation, determining the target format attribute includes:

[0021] The format attribute set for the paragraph in the original document is acquired as a target format attribute.

[0022] In a possible implementation, determining the target format attribute includes:

[0023] The style attribute set for the paragraph in the original document is obtained, and the format attribute defined in the style attribute is used as the target format attribute.

[0024] In a possible implementation manner, after resetting the paragraph attributes of the cleaned paragraph according to the element type of the paragraph, the method further includes:

[0025] The original document after resetting the paragraph attributes is used as the intermediate typesetting document, the paragraphs in the intermediate typesetting document are optimized according to the set second cleaning rules, and the original document after the typesetting optimization is used as the re-typesetting document of the original document.

[0026] In a possible implementation, performing typesetting optimization processing on the paragraphs in the intermediate typesetting document according to the set second cleaning rule includes:

[0027] According to a set second cleaning rule, identifying redundant typesetting elements from the intermediate typesetting document;

[0028] In the intermediate typeset document, the typeset redundant elements are deleted.

[0029] In a possible implementation, the method further includes:

[0030] Identifying, from the intermediate typeset document, incorrect typeset styles associated with paragraph breaks or page breaks;

[0031] Correct the erroneous typesetting style.

[0032] In a possible implementation manner, determining the element type of a paragraph in the original document to be typeset includes:

[0033] Creating a copy document of the original document to be typeset, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document;

[0034] 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;

[0035] 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.

[0036] 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:

[0037] identifying redundant content from paragraphs of the preprocessed document;

[0038] 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;

[0039] 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.

[0040] In a possible implementation manner, before identifying redundant content from the paragraphs of the preprocessed document, the method further includes:

[0041] According to the set fragmentation rules, the preprocessed document is divided into multiple document fragments;

[0042] For the multiple document segments, the steps of identifying redundant content from the paragraphs of the preprocessed document and subsequent steps are performed.

[0043] In a second aspect, the present application provides a document processing device, the device comprising:

[0044] An element type determination module, used to determine the element type of a paragraph in an original document to be typeset;

[0045] The rearrangement module is used to 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 rearranged version of the original document.

[0046] In a possible implementation, the rearrangement module is specifically used to:

[0047] Traversing the paragraphs in the original document one by one;

[0048] For the currently traversed paragraph, when it is determined to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph in the original document is cleaned, and the paragraph attribute of the cleaned paragraph is reset according to the element type of the paragraph;

[0049] For the currently traversed paragraph, if it is determined not to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph attributes are reset according to the element type of the paragraph.

[0050] In a possible implementation, the rearrangement module includes:

[0051] The style setting unit is used to perform paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule, and set style attributes corresponding to the element type of the paragraph for the cleaned paragraph according to the element type of the paragraph.

[0052] In a possible implementation, the rearrangement module further includes:

[0053] A format determination unit, used for determining target format attributes;

[0054] The format setting unit is used to set the format attribute of the paragraph after the style attribute is set according to the target format attribute.

[0055] In a possible implementation manner, the format determination unit is specifically configured to:

[0056] A format attribute corresponding to the element type of the paragraph is acquired as a target format attribute.

[0057] In a possible implementation manner, the format determination unit is specifically configured to:

[0058] The format attribute set for the paragraph in the original document is acquired as a target format attribute.

[0059] In a possible implementation manner, the format determination unit is specifically configured to:

[0060] The style attribute set for the paragraph in the original document is obtained, and the format attribute defined in the style attribute is used as the target format attribute.

[0061] In a possible implementation, the device further includes:

[0062] The typesetting optimization module is used to reset the paragraph attributes of the cleaned paragraph according to the element type of the paragraph, use the original document after the reset paragraph attributes as the intermediate typesetting document, perform typesetting optimization on the paragraphs in the intermediate typesetting document according to the set second cleaning rules, and use the original document after the typesetting optimization as the reformatted document of the original document.

[0063] In a possible implementation, the typesetting optimization module is specifically used to:

[0064] According to a set second cleaning rule, identifying redundant typesetting elements from the intermediate typesetting document;

[0065] In the intermediate typeset document, the typeset redundant elements are deleted.

[0066] In a possible implementation, the device further includes:

[0067] An error correction module, used for identifying erroneous typesetting styles related to segmentation or paging from the intermediate typesetting document;

[0068] Correct the erroneous typesetting style.

[0069] In a possible implementation manner, the element type determination module includes:

[0070] A copy processing unit, used for creating a copy document of the original document to be typeset, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document;

[0071] A model recognition unit, used to obtain a model recognition result of a paragraph in the preprocessed document by using the preprocessed document and the document element recognition model, wherein the model recognition result includes an element type of the paragraph;

[0072] A result determination unit 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.

[0073] In a possible implementation, the model recognition unit includes:

[0074] a redundancy reduction subunit, configured to identify redundant content from paragraphs of the preprocessed document; perform document recognition on non-redundant content in the preprocessed document using a document element recognition model to obtain a model recognition result of paragraphs in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content;

[0075] The model result determination subunit 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.

[0076] In a possible implementation, the device further includes:

[0077] A document segmentation subunit, used for segmenting the preprocessed document into a plurality of document segments according to a set segmentation rule before identifying redundant content from the paragraphs of the preprocessed document;

[0078] The redundancy reduction subunit 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.

[0079] In a third aspect, the present application provides a 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.

[0080] 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.

[0081] The above-mentioned technical scheme 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 determining the element type of the paragraph in the original document to be typeset, performs paragraph attribute cleaning processing on the paragraph in the original document according to the set first cleaning rule, and resets the paragraph attributes of the cleaned paragraph according to the element type of the paragraph, to obtain a reformatted document of the original document. Before reformatting the paragraphs in the original document, 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] 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.

[0083] 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.

[0084] 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.

[0085] Figure 1 A schematic diagram of a system architecture involved in an embodiment of the present application;

[0086] Figure 2 A flowchart of an embodiment of a document processing method provided in an embodiment of the present application;

[0087] Figure 3 A flowchart of another document processing method provided in an embodiment of the present application;

[0088] Figure 4 A flowchart of another document processing method provided in an embodiment of the present application;

[0089] Figure 5 A flowchart of an embodiment of the present application for preprocessing a copy document of an original document according to a set preprocessing method, and determining a model recognition result of a paragraph in the original document using the preprocessed document;

[0090] Figure 6 A diagram showing the attachment of separators to content and the correct segmentation structure;

[0091] Figure 7 This is a schematic diagram of the segmentation effect of a space character or a tab character;

[0092] Figure 8 This is a schematic diagram showing the effect of text content not being segmented correctly;

[0093] Fig. 9 A schematic diagram of using consecutive blank lines to achieve paging effect;

[0094] Fig.10 A flowchart of another document processing method provided in an embodiment of the present application;

[0095] Fig.11 A flowchart of another document processing method provided in an embodiment of the present application;

[0096] Fig.12 A flowchart of another document processing method provided in an embodiment of the present application;

[0097] Fig.13 A flowchart of another document processing method provided in an embodiment of the present application;

[0098] Fig.14 A flowchart of another document processing method provided in an embodiment of the present application;

[0099] Fig.15 A block diagram of an embodiment of a document processing device provided in an embodiment of the present application;

[0100] Fig.16 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0101] 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.

[0102] 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.

[0103] In order to solve the technical problem that traditional document reformatting methods in the prior art are difficult to cope with the complex and changeable paragraph attributes in the original document, and thus easily lead to typesetting errors, the present application provides a document processing method, device, electronic device and device, which can improve the quality of document reformatting and obtain a reformatted document that meets expectations.

[0104] 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.

[0105] 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.

[0106] 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.

[0107] 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.

[0108] 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.

[0109] 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.

[0110] 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.

[0111] 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.

[0112] 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.

[0113] 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.

[0114] 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:

[0115] Step 201: Determine the element type of the paragraph in the original document to be typeset.

[0116] When performing structural analysis and processing on the original document to be typeset, it is crucial to clarify the element type of each paragraph in order to determine the typesetting style to be applied to the paragraph. Here, the element type of a paragraph includes information such as the sub-document to which the paragraph belongs, the interval to which the paragraph belongs, the name of the paragraph, and the level of the paragraph.

[0117] Among them, the subdocument to which a paragraph belongs refers to the specific document part where the paragraph is located. Different subdocuments may have different typesetting requirements, such as font, font size, line spacing, etc. For example, in an original document containing embedded subdocuments, paragraphs in the embedded subdocument and paragraphs in the main document can apply different typesetting styles, and paragraphs in different embedded subdocuments can also apply different typesetting styles. For example, there are titles at the level of Title 1 in both the main document and the subdocument, but different styles can be set in the main document and the subdocument, and even the level of Title 1 in the subdocument can be set to be actually lower than the level of Title 1 in the main document. Therefore, clarifying the subdocument to which a paragraph belongs helps to accurately apply the corresponding typesetting style and ensure that the typesetting effect of the document meets user expectations.

[0118] The interval to which a paragraph belongs refers to the specific location or range of the paragraph in the document. The interval information will directly affect the layout and style of the typesetting, for example, whether the paragraph needs to be paged, whether the paragraph is located at the beginning, middle or end of the page, the paragraph's font, font size, line spacing, alignment, etc.

[0119] The name or type of a paragraph (such as body paragraph, title paragraph, table of contents paragraph, footnote, etc.) directly determines its layout style. Generally, you can establish an association between the name or type of a paragraph and the layout style. Different types of paragraphs may require different font styles, font sizes, colors, alignments, indents, and spacing.

[0120] Paragraph level refers to the level or importance of a paragraph in a document structure. For example, in a multi-level heading system, the first-level heading may be a chapter title, the second-level heading may be a subsection title, and the body paragraphs belong to the lowest level. Paragraphs at different levels usually have different typographic styles to reflect their hierarchy and logical structure. For example, the higher the heading level, the larger and bolder the font is to highlight its importance; while the body paragraphs may use a more concise and unified typographic style.

[0121] In some embodiments, paragraph levels can be set for different title styles, such as: first-level titles include: chapter title, section title, title one and other title styles; second-level titles include: title two and other title styles; third-level titles include: title three and other title styles.

[0122] It can be seen that determining the element types of paragraphs in the original document to be typeset is crucial to the subsequent typesetting work. By accurately identifying and processing these element types, the accuracy and aesthetics of the document typesetting results can be ensured.

[0123] As for how to determine the element type of the paragraph in the original document to be typeset, it will be explained through specific embodiments below and will not be described in detail here.

[0124] Step 202: 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.

[0125] Before explaining step 202, the important terms and concepts involved in the embodiment of the present application are first explained:

[0126] Paragraph attributes usually include three types of attributes: style attributes, format attributes, and outline attributes. Style attributes, format attributes, and outline attributes are three different concepts, and there is a certain relationship between them.

[0127] Specifically, format attributes refer to the layout rules directly applied to text or paragraphs, which are usually used to fine-tune the appearance and layout of text. Format attributes include but are not limited to: font attributes (defining the font type, font size, color, etc. of the text), font format attributes (such as bold, italic, underline, strikethrough, etc., character spacing), paragraph format attributes (such as line spacing, indentation, paragraph spacing), etc. Format attributes are usually applied directly through the format toolbar or menu in the document editing software. Users can fine-tune the text or paragraph as needed to achieve the ideal layout effect.

[0128] Style attributes are a combination of a set of preset formatting attributes, such as font, paragraph alignment, line spacing, indentation (defining the first line indent, hanging indent, or left and right indents of paragraph text), bullets, and numbering. After applying style attributes to a paragraph, the paragraph will have the formatting attributes corresponding to the style attributes. In actual applications, style attributes are usually created, modified, and applied through the style manager in the document editing software. At the same time, users can also save commonly used typesetting rules as styles for quick application when needed.

[0129] Outline properties are mainly used to organize and present the structure of a document, which is usually reflected through the title style. In document editing software, outline levels are usually associated with title styles (such as "Title 1", "Title 2", etc.), and each title style corresponds to a specific outline level. By applying different title styles, you can easily create a document's directory structure and outline view.

[0130] In actual applications, users can quickly apply a set of preset formatting attributes by creating and modifying styles, thereby improving typesetting efficiency. At the same time, users can also fine-tune text or paragraphs by directly adjusting formatting attributes to meet specific typesetting needs. In short, style attributes and formatting attributes in paragraph properties are two interrelated but different concepts, which together form the basis of document typesetting.

[0131] The first cleaning rule refers to the criterion or standard followed when performing paragraph attribute cleaning, and is mainly used to remove paragraph attributes that conflict (or interfere) with the style attribute to be set. The conflicting paragraph attributes include at least one of the following: a paragraph attribute that is repeated with the paragraph attribute set with the style attribute to be set, a style attribute that belongs to the style set of the style attribute to be set but is different from the style attribute to be set, and a style attribute that does not belong to the style set of the style attribute to be set. Among them, the style attribute to be set is the style attribute to be applied to the paragraph; the style set of the style attribute to be set refers to a set of styles used for typesetting the original document. The style set includes various preset style attributes, and each style attribute is set with a style name and its corresponding format attribute combination. Generally, different style names correspond to different format attribute combinations. When the paragraph to be typeset has a style attribute, but the style name of the style attribute is not in the preset style set, it is determined that the style attribute of the paragraph to be typeset does not belong to the style attribute of the style set of the style attribute to be set; when the paragraph to be typeset has a style attribute, and the style name of the style attribute is in the preset style set, it is determined that the style attribute of the paragraph to be typeset belongs to the style attribute of the style set of the style attribute to be set. If the style attribute of the paragraph to be typeset belongs to the style attribute in the style set of the style attribute to be set, but is different from the style attribute to be set, then due to the different format attributes corresponding to the style attribute, there may be a problem of duplication or conflict of format attributes, and the style attributes of the paragraph to be typeset need to be cleaned up.

[0132] In one embodiment, the first cleaning rule covers the following key aspects:

[0133] (1) When to clean up paragraph attributes.

[0134] That is, it is clear under what circumstances the paragraph attributes of a paragraph should be cleaned. Generally, when the paragraph attributes currently set for a paragraph conflict with the style attributes expected or required for re-layout, or when it is determined that the paragraph attributes currently set for a paragraph are likely to interfere with the subsequent re-layout, it involves cleaning the paragraph attributes of the paragraph. For example, inconsistent font, font size settings, inconsistent alignment settings and other layout issues.

[0135] (2) Which paragraph attributes are to be cleaned?

[0136] That is, it is clear whether to clean up style attributes, format attributes or outline attributes. Style attributes usually refer to a series of predefined format combinations, such as title styles, body styles, etc., which can be globally applied to multiple elements in a document. Format attributes are personalized format settings for a single element (such as a specific paragraph, text block, etc.). Outline attributes are used to organize and display the structure of a document. In actual applications, you can choose to clean up one or more of these attributes according to specific circumstances and needs.

[0137] (3) Which styles in the style attributes need to be cleaned up, and which styles in the style attributes need to be restored to format attributes, so as to make more detailed format adjustments to the paragraphs.

[0138] When deciding to clean style attributes, you need to further clarify the specific styles to be cleaned, such as deleting unnecessary font styles, font size settings, color configurations, etc., to eliminate potential format conflicts. At the same time, for some styles, it may also involve restoring them to format attributes in order to make more detailed format adjustments to the paragraphs.

[0139] It can be seen that by performing paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, it is possible to pre-identify and eliminate potential paragraph attributes that conflict with the style required for the rearrangement or paragraph attributes that are likely to interfere with the subsequent rearrangement before the paragraphs in the original document are rearranged. Afterwards, according to the element type of the paragraph, the paragraph attributes of the cleaned paragraphs are reset to obtain the rearranged document of the original document, which can ensure that the document will not have typesetting errors caused by format conflicts or interference during the rearrangement process, thereby improving the quality of the document rearrangement.

[0140] In the process of re-formatting the original document, the paragraph attributes are reset for the cleaned paragraph according to the element type of the paragraph to obtain the re-formatted document of the original document. In this regard, in one embodiment, the correspondence between the element name and the style attribute is pre-set. When the paragraph attributes are reset for the cleaned paragraph according to the element type of the paragraph, the corresponding style attribute can be found from the above correspondence through the element name of the paragraph, and then the corresponding style attribute is applied to the paragraph. Among them, the correspondence between the element name and the style attribute depends on the category of the document (referring to the expected re-formatted document). For documents of different categories, the correspondence between the element name and the style attribute may be different. For example, in academic papers, elements such as titles, abstracts, texts and references have specific style attributes such as fonts, font sizes and line spacing; while in official documents, these elements may use different styles to reflect their professionalism and readability. Usually, this processing method not only improves the flexibility of document re-formatting processing, but also ensures that the re-formatted documents of different categories meet their unique style.

[0141] The technical solution provided by the embodiment of the present application determines the element type of the paragraphs in the original document to be typeset, performs paragraph attribute cleaning processing 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, the technical solution can 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.

[0142] In one embodiment, the specific implementation of performing paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph includes:

[0143] The paragraphs in the original document are traversed one by one; for the currently traversed paragraph, when it is determined to perform paragraph attribute cleaning on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph in the original document is subjected to paragraph attribute cleaning, and the paragraph attribute of the cleaned paragraph is reset according to the element type of the paragraph. In addition, for the currently traversed paragraph, when it is determined not to perform paragraph attribute cleaning on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph attribute of the paragraph is reset according to the element type of the paragraph.

[0144] It can be seen from the description in the above embodiments that when the paragraphs in the original document are cleaned for paragraph attributes, they are cleaned paragraph by paragraph, not for all the paragraphs in the original document. There are two reasons for this: one reason is that batch cleaning may cause some visual effects to be unable to be completely restored. Format attributes are distributed in multiple locations such as word attributes, line attributes, paragraph attributes, style attributes, and numbering attributes. If they are directly cleaned in batches, there will be a risk of being unable to be completely restored when restoring some non-target attributes. Another aspect is that the attribute composition of each paragraph seems to be the same, but there are actually differences in the possible implementation methods. Therefore, in practical applications, it is more appropriate to clean and set the target attributes (referring to the format attributes that need to be cleaned, and the above-mentioned non-target attributes are the relative concepts of the target attributes, referring to the format attributes that do not need to be cleaned) as needed, and the priority relationship between attributes should be considered. Generally, format attributes will be superimposed, and style attributes have a lower priority than format attributes. Here, the priority of style attributes is lower than format attributes, which means that when an element is affected by both style attributes and format attributes, format attributes will cover or take precedence over style attributes. For example, the paragraph properties of a paragraph "This is a paragraph of text" are <Style 1: Font 1, Font Size 1; Format Properties: Font 2> This is a paragraph of text. Both Style 1 and Format Properties set font properties, but because Format Properties take precedence over Style Properties, the final typesetting style applied to the paragraph is: Font 2, Font Size 1.

[0145] Then, by cleaning up the paragraph attributes of each paragraph in the original document, more precise paragraph attribute cleaning control can be achieved and format confusion can be effectively avoided, thereby ensuring the accuracy and quality of the document reformatting, so that the final reformatted document is more in line with the expected typesetting requirements.

[0146] It can also be seen from the above embodiments that not all paragraphs need to have their paragraph attributes cleaned before applying style attributes. In some cases, paragraph attributes do not need to be cleaned, but style attributes can be applied directly. The fact that no paragraph attribute cleaning is required usually means that the paragraph attributes currently set for the paragraph do not conflict with the style attributes that are expected or required for rearrangement, or that the paragraph attributes currently set for the paragraph usually do not interfere with subsequent rearrangement.

[0147] Accordingly, in one embodiment, the specific implementation of performing paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule, and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraph includes: performing paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule, and setting the style attributes corresponding to the element type of the paragraph for the cleaned paragraphs according to the element type of the paragraph. Here, there are two situations for the results of performing paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule, one is that cleaning is required, and the other is that cleaning is not required. In either case, the style attributes corresponding to the element type of the paragraph are set for the cleaned paragraphs.

[0148] Furthermore, in some scenarios, simply setting the style attributes corresponding to the element type of the cleaned paragraphs may not result in a reformatted document that meets the typesetting expectations. In this case, formatting, as a more direct and flexible way, can fine-tune the paragraph format to achieve a more precise typesetting effect.

[0149] Based on this, in one embodiment, after setting the style attributes corresponding to the element type of the paragraph after the cleaning process, the target format attributes are determined, and the format attributes of the paragraph after the style attributes are set are set according to the target format attributes.

[0150] In one embodiment, the specific implementation of determining the target format attribute includes: obtaining a format attribute corresponding to the element type of the paragraph as the target format attribute.

[0151] In another embodiment, the specific implementation of determining the target format attribute includes: obtaining the format attribute set for the paragraph in the original document as the target format attribute.

[0152] In yet another embodiment, the specific implementation of determining the target format attributes includes: acquiring the style attributes set for the paragraph in the original document, and using the format attributes defined in the style attributes as the target format attributes.

[0153] The above embodiments are discussed below in detail:

[0154] The first case: the current paragraph applies the default format and default style in the original document. The default format and default style here refer to the format and style automatically assigned in the document template used when editing the original document. It can also be understood that when the user edits the current paragraph, he only enters the content of the paragraph and does not set any additional paragraph attributes for the current paragraph. Whether it is the setting of style attributes or format attributes, it generally defaults to the body style. In this case, since there is also a body style in the set to be set, it can be considered that the paragraph attributes set for the current paragraph in the original document will not interfere with the subsequent typesetting, and there is no conflict with the style attributes expected or required for re-layout. In this case, there is no need to clean the paragraph attributes of the current paragraph. After clarifying the element type of the current paragraph, the style attributes corresponding to the element type of the current paragraph can be set directly according to the element type of the current paragraph to meet the expected requirements of the re-layout.

[0155] In the first case, you can further overlay format attribute settings on the current paragraph as needed to fine-tune the paragraph format of the current paragraph, thereby achieving a more precise typesetting effect.

[0156] For example, there is a type of element in an official document called "primary addressee". Although the "primary addressee" is classified as the main text in terms of content, it has specific typesetting rules, which requires that the first line has no indentation. In order to take into account the special typesetting requirements of the "primary addressee" and the uniformity of the text style, the technical solution provided in the embodiment of the present application can be applied. First, the style attributes of the text are set for the "primary addressee", and then the indentation settings of the "primary addressee" are specially adjusted by superimposing additional format attributes, that is, the first line indentation is canceled. This processing method ensures that the "primary addressee" is consistent with the main text in terms of font, font size, color, etc., thereby maintaining the coherence of the overall style of the text, while also accurately meeting the personalized typesetting requirements of the "active object" element.

[0157] This corresponds to the above-mentioned embodiment: the format attribute corresponding to the element type of the paragraph is acquired as the target format attribute.

[0158] The second case: the current paragraph applies the built-in style in the original document, and there is no additional formatting. The built-in style here refers to the style options pre-defined and provided in the document editing software, which are the style attributes in the style set of the above-mentioned style attributes to be set. It can also be understood that when the user edits the current paragraph, he not only enters the content of the paragraph, but also selects a built-in style attribute such as "Title One" for the current paragraph. In this case, since the user does not make additional formatting adjustments, the paragraph attributes of the current paragraph are completely determined by the style attributes selected by the user, and there is no interference from other special formats. Then in this case, since the built-in style is a style in the style set of the above-mentioned style attributes to be set, and the style attributes of the paragraph are the style attributes to be set, it can be considered that the paragraph attributes set in the original document for the current paragraph will not interfere with the subsequent typesetting, and there is no conflict with the expected or required style attributes for re-layout, so there is no need to clean the paragraph attributes of the current paragraph. After clarifying the element type of the current paragraph, the style attributes corresponding to the element type of the paragraph can be set for the current paragraph directly according to the element type of the current paragraph to meet the expected requirements of the re-layout.

[0159] In the second case, you can further overlay format attribute settings on the current paragraph as needed to fine-tune the paragraph format of the current paragraph, thereby achieving a more precise typesetting effect.

[0160] For example, the format attribute corresponding to the element type of the paragraph is obtained as the target format attribute, and the format attribute of the paragraph after the style attribute is set is set according to the target format attribute.

[0161] For specific examples, please refer to the example in the first case above, which will not be repeated here.

[0162] The third case:

[0163] The current paragraph applies the default style in the original document and applies additional formatting. The default style here refers to the style automatically assigned in the document template used when editing the original document. The additional formatting means that the user has fine-tuned the format of the paragraph through formatting while applying the default style. In this case, since the user has made additional formatting adjustments, the paragraph properties of the current paragraph are determined by the default style and the formatting additionally set by the user, so the formatting set by the user needs to be considered in subsequent typesetting. In this case, it can be considered that the paragraph properties set for the current paragraph in the original document may interfere with subsequent typesetting. In order to smoothly carry out the rearrangement, the paragraph properties of the current paragraph can be cleared first so that the style can be set from scratch.

[0164] It should be noted that there are two situations for additional formatting settings: setting the formatting attributes of a paragraph and setting the formatting attributes of a part of a paragraph.

[0165] 1) Set the formatting attributes of the paragraph

[0166] Setting the formatting attributes of a paragraph means that the formatting attributes are used to set an entire paragraph. In this application, the style attributes to be set are applied to an entire paragraph. At this time, if the formatting attributes of the paragraph to be set conflict with the style attributes to be set, the formatting attributes of the paragraph to be set in the original document need to be cleaned up.

[0167] 2) Set the formatting attributes of the part in the paragraph

[0168] Setting the format attributes of a part in a paragraph means that the format attributes are used to set a part in the paragraph, such as a part of the text, a part of the object, etc. In this case, in one embodiment, the user's setting intention should be retained, and even if the format attributes of the part in the paragraph conflict with the style attributes to be set, they should be retained instead of cleared.

[0169] In this example, performing paragraph attribute cleaning on the paragraphs in the original document refers to deleting the format attributes or style attributes of the set paragraphs.

[0170] After the element type of the current paragraph is clarified, the style attribute corresponding to the element type of the paragraph can be set for the current paragraph directly according to the element type of the current paragraph to meet the expected requirements of the rearrangement.

[0171] Furthermore, since the user has special requirements for the typesetting style of the current paragraph, after setting the style attributes, the current paragraph is further personalized in terms of the format attributes of the current paragraph in the original document, so as to restore the format additionally set by the user and meet the user's special needs. For this, the format attributes set for the paragraph in the original document are obtained as the target format attributes, and the format attributes of the paragraph after the style attributes are set are set according to the target format attributes.

[0172] As an additional note, in the third case, some styles can be selectively cleared. For example, the formats that conflict between the style attributes to be set and the target format attributes are font and font size. For example, the style attributes to be set are Songti, size 4, and the target format attributes are Kaiti, size 4. Then, only the font and font size formats can be cleared to eliminate format conflicts or interference. After that, set the style attributes for the current paragraph, and set the format attributes of the paragraph after the style attributes are set according to the target format attributes. The final typesetting effect is Kaiti, size 4, while other paragraph attributes except font and font size (such as bold, italic, indentation and spacing, etc.) depend on the style attributes.

[0173] It can be seen from the above description that for the third case, the application of the technical solution provided by the embodiment of the present application can not only maintain the consistency of the typesetting style as a whole, but also accurately meet the user's personalized typesetting needs.

[0174] The fourth case: the current paragraph applies the built-in style in the original document, and applies additional formatting. It can also be understood that when the user edits the current paragraph, not only does he select a built-in style attribute such as "Title One" for the current paragraph, which is a style attribute in the style set of the above-mentioned style attributes to be set, but he also performs additional formatting. For example, suppose the default font color of the "Title One" style is black, but the user wants the font color of the paragraph to be blue. Therefore, after selecting the "Title One" style, the user changes the font color to blue through formatting. At this point, the paragraph properties of the paragraph are determined by the "Title One" style attribute and the user-defined blue font format attribute.

[0175] In this case, it can be considered that the paragraph attributes set in the original document for the current paragraph may interfere with the subsequent typesetting, because the subsequent typesetting needs to consider both the built-in style and the user-defined format. Then, in order to smoothly carry out the rearrangement, the style attributes and format attributes of the current paragraph can be cleaned up first, so as to set the style from the beginning. After clarifying the element type of the current paragraph (such as "Heading 1"), the corresponding style attributes can be set for the current paragraph according to the typesetting requirements of the element type.

[0176] Furthermore, since the user has special requirements for the typesetting style of the current paragraph (such as blue font color), after setting the style attributes, the current paragraph is further personalized according to the format attributes in the original document to restore the format additionally set by the user and meet the user's special needs. For this, the format attributes set for the paragraph in the original document are obtained as the target format attributes, and the format attributes of the paragraph after the style attributes are set are set according to the target format attributes.

[0177] Through this process, we can ensure that the reformatted document not only meets the overall typesetting requirements, but also retains the user's special formatting settings for specific paragraphs. This can ensure the consistency of the document and meet the user's personalized needs.

[0178] In addition to the above four situations, there is also a special situation, whose particularity is manifested as being unable to accurately determine the element type of a paragraph, and this situation often originates from the introduction of user-defined styles, i.e., does not belong to the style set of style attributes to be set. In the face of this situation, the present application embodiment proposes a relatively conservative typesetting strategy, i.e., does not re-typeset, but retains the style features of the original text as much as possible. In order to achieve this goal, the paragraph attributes of the paragraph can be first cleaned and restored to the common body paragraph style to avoid subsequent format interference that may occur, and then, the style attributes that the paragraph is set in the original document are obtained, and the format attributes defined in the style attributes are used as the target format attributes in the process of re-typesetting, and these target format attributes are directly applied to the corresponding paragraphs, so as to retain the style style of the original text. In this way, while ensuring the readability and consistency of the document, the personalized settings of the user are also respected and retained.

[0179] In addition, in addition to the style attributes, format attributes or outline attributes of the paragraphs in the original text that may interfere with the subsequent typesetting and cause typesetting errors, some content in the original text may also interfere with the subsequent typesetting. These contents include but are not limited to: spaces at the beginning of paragraphs, meaningless separators, blank paragraphs between paragraphs, etc. Among them, the spaces at the beginning of paragraphs affect the indentation of paragraphs, meaningless separators affect subsequent paging, and blank paragraphs between paragraphs affect the spacing and may also affect subsequent paging. In this regard, when traversing the paragraphs in the original document one by one, once these contents that may interfere with the subsequent typesetting are found, these contents will be cleaned up to avoid affecting the quality of subsequent typesetting.

[0180] From the above specific embodiments and the process of resetting paragraph attributes in the reformatting process provided in the embodiments of the present application in combination with different situations, it can be seen that the application of the technical solution provided in the embodiments of the present application can ensure that the document will not cause typesetting errors due to format conflicts or interferences during the reformatting process in various complex situations, thereby improving the quality of document reformatting and obtaining a reformatted document that meets expectations.

[0181] In addition, the above embodiment is aimed at the parts of the original document that need to participate in the re-layout. In actual applications, there may be some parts in the original document that do not need to participate in the re-layout, such as the cover area, empty paragraphs, etc. For these parts that do not need to participate in the re-layout, some processing operations still need to be performed to ensure that the final re-layout document is neat and meets the expected layout requirements.

[0182] For example, for the paragraphs on the cover, first clear their original style attributes to avoid unexpected changes in the style of the cover paragraphs due to the influence of the same-name style during the subsequent typesetting process. Secondly, for paragraphs that do not participate in the re-layout but have substantial content (such as the paragraphs on the cover), after clearing the style attributes, it is also necessary to restore the original style attributes of the paragraphs in the form of setting format attributes. Specifically, obtain the style attributes set for the paragraphs in the original document, use the format attributes defined in the style attributes as the target format attributes, and apply these target format attributes directly to the corresponding paragraphs during the re-layout process to ensure the consistency of the original visual effects and presentation methods in the document.

[0183] For empty paragraphs in the original document, if the empty paragraphs have outline levels, blank lines will appear in the generated table of contents, thus destroying the coherence and integrity of the table of contents. Therefore, for empty paragraphs, their outline attributes can be cleaned to ensure that empty paragraphs will not be mistakenly included in the table of contents, thereby maintaining the clarity and accuracy of the table of contents.

[0184] In addition, for the parts of the original document that need to be re-formatted, other typeset methods are also involved. Specifically, special typesetting operations for special body content. When processing the original document, you will encounter some content that is classified as body text but belongs to special body paragraphs. The particularity of this type of content is usually reflected in the different styles from general body paragraphs. Therefore, when typeset the original document, for this type of special body paragraph, you cannot simply apply the general body text style rules, but need to handle it separately.

[0185] In one embodiment, the separate processing of special text paragraphs can be divided into the following cases:

[0186] The first situation is: if there are clear typesetting specifications, typesetting should be carried out according to the clear typesetting specifications. For example, the recipients of official documents, abstracts, keywords and other paragraphs in papers will have clear font, font size, font shape, font color, font effect, font spacing and other font attribute requirements, as well as alignment, indentation, paragraph spacing, line spacing and other paragraph attribute requirements.

[0187] The second situation is that multiple text paragraphs belong to a table structure interval, and cannot be typed through a single segment attribute setting. For example: signature information, contract information, communication information, appendix description, notes, test questions, roster, etc. This type of text paragraph interval belonging to a table structure needs to be typed separately. Furthermore, for this type of text paragraph interval, according to the number of structural entities contained in the interval, it can be divided into a single body structure and a multi-body structure, or, according to the number of fields appearing in a paragraph, it can be divided into a single column structure and a multi-column structure. These two types can appear in cross-combination.

[0188] For this type of text paragraph interval, when typesetting, first, ensure the layout relationship between this interval and the context, and treat it as a whole for typesetting; secondly, ensure the paragraph structure relationship within this interval, and use tabs to reconstruct the table structure.

[0189] The third situation is: for unplanned or unknown special format text paragraphs or intervals, a conservative strategy of "no processing" is adopted, that is, the format and layout of the original text are retained, and the original overall style and style are maintained as much as possible.

[0190] In addition, if there are some structural features inside, such as continuous symbol separation, alignment processing can be performed within the interval to ensure the consistency and neatness of the entire interval.

[0191] The above embodiment can ensure the consistency of the document format and the clarity of the content after the reformatting by individually typeset the special text paragraphs, thereby improving the overall quality of the document.

[0192] Figure 3 A flowchart of another document processing method provided in an embodiment of the present application. Figure 3 The process shown is based on the above embodiment process and includes the following steps:

[0193] Step 301: Determine the element type of the paragraph in the original document to be typeset.

[0194] Step 302: 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.

[0195] For detailed description of step 301 and step 302, please refer to the relevant description in the above embodiment, which will not be repeated here.

[0196] Step 303: 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.

[0197] 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.

[0198] 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.

[0199] Exemplarily, redundant layout elements include blank paragraphs between paragraphs, blank paragraphs at the beginning of a page, and extra separators, etc.

[0200] 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.

[0201] 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.

[0202] 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.

[0203] 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.

[0204] 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.

[0205] Figure 3 The process shown, by performing typesetting optimization processing on the paragraphs in the intermediate typeset document according to the set second cleaning rule, and using the original document after the typesetting optimization processing as the reformatted document of the original document, can effectively reduce or eliminate redundant typesetting elements in the document, thereby improving the standardization of the reformatted document.

[0206] Figure 4 A flowchart of another document processing method provided in an embodiment of the present application. Figure 4 The process shown is based on the above embodiment process and includes the following steps:

[0207] Step 401: Determine the element type of the paragraph in the original document to be typeset.

[0208] Step 402: 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.

[0209] For detailed description of step 401 and step 402, please refer to the relevant description in the above embodiment, which will not be repeated here.

[0210] Step 403: Identify the incorrect typesetting styles related to segmentation or paging from the intermediate typesetting document, and correct the incorrect typesetting styles.

[0211] 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.

[0212] 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.

[0213] 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.

[0214] 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.

[0215] Step 404: 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.

[0216] For a detailed description of step 404, please refer to the relevant description in the above embodiment, which will not be repeated here. Figure 4 The process shown can ensure the best overall typesetting effect of the document by correcting the incorrect paging or paragraphing styles in the intermediate typesetting document, thereby obtaining a re-typesetting document that is more in line with typesetting specifications.

[0217] Finally, through Figure 5 The illustrated embodiment describes how to preprocess a copy of an original document according to a set preprocessing method, and use the preprocessed document to determine the model recognition result of a paragraph in the original document. Figure 5 As shown, the following steps are included:

[0218] Step 501: Create a copy document of the original document, and preprocess the copy document according to a set preprocessing method to obtain a preprocessed document.

[0219] Step 502: Using the preprocessed document and the document element recognition model, obtain a model recognition result of the paragraphs in the preprocessed document.

[0220] Step 503: 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.

[0221] For ease of understanding and description, steps 501 to 503 are explained uniformly below:

[0222] 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.

[0223] It can be seen from the description of step 501 and step 502 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 side 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.

[0224] 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 501 and 502, 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.

[0225] 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.

[0226] 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 paragraph number, 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 503, 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.

[0227] 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.

[0228] 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.

[0229] 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.

[0230] 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.

[0231] 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.

[0232] 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.

[0233] 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.

[0234] 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.

[0235] The following examples describe the following non-standard segmentation styles that may exist in the copy document and their corresponding conversion rules:

[0236] The first type: soft return segmentation

[0237] 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.

[0238] 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.

[0239] For example, see Figure 6 , which is a diagram comparing the effects of using soft carriage returns and hard carriage returns in text content.

[0240] The second type: the separator is glued to the content paragraph

[0241] 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 7 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 7 , 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.

[0242] 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.

[0243] 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 7 , where page 1 is an example of correct paragraph structure. Figure 7 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 7 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 7 The string in page 1 and the string in page 2 are correctly identified as two paragraphs.

[0244] 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 7In 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 7 Change page 2 in to "I am a free paragraph hard return section break at the top of the page (next page)".

[0245] The third type: space or tab segment

[0246] 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 8 , which is a schematic diagram of the segmentation effect of space or tab characters.

[0247] 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.

[0248] The fourth case: the text content is not segmented

[0249] 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 Fig. 9 , which is a schematic diagram of the effect of not correctly segmenting text content.

[0250] 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.

[0251] 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.

[0252] 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.

[0253] For example, the following non-standard separation styles may exist in the copy document:

[0254] The first type: Section / page break paging

[0255] 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.

[0256] 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.

[0257] The second type: paragraph break and line break

[0258] In a document editing scenario, users may sometimes achieve page breaks by simply pressing Enter to add a blank line, but this is not recommended because it will become ineffective as the document layout is adjusted. For example, see Fig.10 , a schematic diagram of using consecutive blank lines to achieve paging effect

[0259] 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.

[0260] 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.

[0261] The third type: paragraph attribute paging

[0262] 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.

[0263] 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.

[0264] 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.

[0265] 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.

[0266] 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.

[0267] 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.

[0268] 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.

[0269] 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.

[0270] 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.

[0271] 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.

[0272] 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.

[0273] Figure 5 The process shown, by creating a copy of the original document, preprocessing the copy document according to the set preprocessing method, obtaining 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 final recognition result of the element type of the paragraph in the original document.

[0274] 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.

[0275] Fig.11 A flowchart of another document processing method provided in an embodiment of the present application. Fig.11 The process shown in Figure 2 Based on the process shown, the following steps are included:

[0276] Step 1101: Obtain a preprocessed document of the original document.

[0277] Step 1102: Identify redundant content from the paragraphs of the preprocessed document, where the redundant content is the paragraphs of the determined element type.

[0278] 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.

[0279] 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.

[0280] Therefore, in step 1102, 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.

[0281] 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.

[0282] 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.

[0283] 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.

[0284] 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.

[0285] 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.

[0286] 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.

[0287] 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.

[0288] Step 1103: 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.

[0289] It can be seen from the description of step 1103 that, in one embodiment, only the content other than the redundant content determined in the aforementioned step 1102 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.

[0290] Step 1104: 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.

[0291] 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.

[0292] 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 1104, 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.

[0293] 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.

[0294] Fig.11The 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.

[0295] 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.

[0296] 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.

[0297] Fig.12 A flowchart of another document processing method provided in an embodiment of the present application. Fig.12 The process shown in Figure 2 Based on the process shown, the following steps are included:

[0298] Step 1201: Obtain the preprocessed document of the original document.

[0299] Step 1202: Segment the preprocessed document into a plurality of document segments, wherein two adjacent document segments have a partial overlapping area in terms of content.

[0300] In one embodiment, the preprocessed document is segmented into a plurality of document segments according to a set segmentation rule.

[0301] 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.

[0302] 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.

[0303] 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.

[0304] Step 1203: 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.

[0305] Step 1204: 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.

[0306] For ease of understanding, step 1203 and step 1204 are explained uniformly below:

[0307] 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 1203 and 1204, the multiple document fragments formed by segmenting the pre-processed document according to the set fragmentation rules are first input into the trained document element recognition model 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.

[0308] Fig.12 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.

[0309] exist Fig.11 and Fig.12On 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.

[0310] 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.

[0311] 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.

[0312] Fig.13 A flowchart of another document processing method provided in an embodiment of the present application. Fig.13 As shown, the process includes the following steps:

[0313] Step 1301: Obtain a preprocessed document of the original document, and use a document element recognition model to determine a model recognition result of a paragraph in the preprocessed document. The model recognition result includes: an element type of the paragraph determined by the document element recognition model.

[0314] Step 1302: 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.

[0315] 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.

[0316] 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.

[0317] 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.

[0318] 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.

[0319] Step 1303: Determine 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 document, wherein the recall processing result includes: the element type of the paragraph determined by the recall processing.

[0320] It can be seen from the description of step 1303 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.

[0321] 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.

[0322] Fig.13 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.

[0323] 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.

[0324] 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.

[0325] Fig.14 This is a flowchart of another document processing method provided in the present application. Fig.14 As shown, the process includes the following steps:

[0326] Step 1401: Use the document element recognition model to determine the model recognition result of the paragraph in the original document. The model recognition result includes: the element type of the paragraph determined by the document element recognition model.

[0327] 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.

[0328] In step 1401, 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.

[0329] In one embodiment, the specific implementation of determining the model recognition result of the paragraph in the original document using the document element recognition model 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.

[0330] Step 1402: 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.

[0331] Step 1403: perform credibility verification on 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.

[0332] For ease of understanding, step 1402 and step 1403 are described uniformly below:

[0333] It can be seen from the description of step 1402 and step 1403 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.

[0334] 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.

[0335] 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.

[0336] 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.

[0337] Fig.14 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.

[0338] Fig.15 This is a block diagram of an embodiment of a document processing device provided in an embodiment of the present application. Fig.15 As shown, the device comprises:

[0339] An element type determination module 151 is used to determine the element type of a paragraph in an original document to be typeset;

[0340] The reformatting module 152 is used to 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 document of the original document.

[0341] In a possible implementation, the rearrangement module 152 is specifically configured to:

[0342] Traversing the paragraphs in the original document one by one;

[0343] For the currently traversed paragraph, when it is determined to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph in the original document is cleaned, and the paragraph attribute of the cleaned paragraph is reset according to the element type of the paragraph;

[0344] For the currently traversed paragraph, if it is determined not to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph attributes are reset according to the element type of the paragraph.

[0345] In a possible implementation, the rearrangement module 152 includes:

[0346] The style setting unit is used to perform paragraph attribute cleaning processing on the paragraphs in the original document according to the set first cleaning rule, and set style attributes corresponding to the element type of the paragraph for the cleaned paragraph according to the element type of the paragraph.

[0347] In a possible implementation, the rearrangement module 152 further includes:

[0348] A format determination unit, used for determining target format attributes;

[0349] The format setting unit is used to set the format attribute of the paragraph after the style attribute is set according to the target format attribute.

[0350] In a possible implementation manner, the format determination unit is specifically configured to:

[0351] A format attribute corresponding to the element type of the paragraph is acquired as a target format attribute.

[0352] In a possible implementation manner, the format determination unit is specifically configured to:

[0353] The format attribute set for the paragraph in the original document is acquired as a target format attribute.

[0354] In a possible implementation manner, the format determination unit is specifically configured to:

[0355] The style attribute set for the paragraph in the original document is obtained, and the format attribute defined in the style attribute is used as the target format attribute.

[0356] In a possible implementation, the device further includes:

[0357] The typesetting optimization module is used to reset the paragraph attributes of the cleaned paragraph according to the element type of the paragraph, use the original document after the reset paragraph attributes as the intermediate typesetting document, perform typesetting optimization on the paragraphs in the intermediate typesetting document according to the set second cleaning rules, and use the original document after the typesetting optimization as the reformatted document of the original document.

[0358] In a possible implementation, the typesetting optimization module 152 is specifically used to:

[0359] According to a set second cleaning rule, identifying redundant typesetting elements from the intermediate typesetting document;

[0360] In the intermediate typeset document, the typeset redundant elements are deleted.

[0361] In a possible implementation, the device further includes:

[0362] An error correction module, used for identifying erroneous typesetting styles related to segmentation or paging from the intermediate typesetting document;

[0363] Correct the erroneous typesetting style.

[0364] In a possible implementation, the element type determination module 151 includes:

[0365] A copy processing unit, used for creating a copy document of the original document to be typeset, and preprocessing the copy document according to a set preprocessing method to obtain a preprocessed document;

[0366] A model recognition unit, used to obtain a model recognition result of a paragraph in the preprocessed document by using the preprocessed document and the document element recognition model, wherein the model recognition result includes an element type of the paragraph;

[0367] A result determination unit 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.

[0368] In a possible implementation, the model recognition unit includes:

[0369] a redundancy reduction subunit, configured to identify redundant content from paragraphs of the preprocessed document; perform document recognition on non-redundant content in the preprocessed document using a document element recognition model to obtain a model recognition result of paragraphs in the non-redundant content, wherein the non-redundant content refers to other content in the preprocessed document except the redundant content;

[0370] The model result determination subunit 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.

[0371] In a possible implementation, the device further includes:

[0372] A document segmentation subunit, used for segmenting the preprocessed document into a plurality of document segments according to a set segmentation rule before identifying redundant content from the paragraphs of the preprocessed document;

[0373] The redundancy reduction subunit 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.

[0374] like Fig.16 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.

[0375] Memory 113, used for storing computer programs;

[0376] 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:

[0377] Determine the element type of the paragraph in the original document to be typeset;

[0378] The paragraphs in the original document are cleaned for paragraph attributes according to the set first cleaning rule, and the paragraph attributes of the cleaned paragraphs are reset according to the element type of the paragraph to obtain a rearranged version of the original document.

[0379] 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.

[0380] 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.

[0381] 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.

[0382] 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.

[0383] 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: Determine the element type of the paragraph in the original document to be typeset; The paragraphs in the original document are cleaned for paragraph attributes according to the set first cleaning rule, and the paragraph attributes of the cleaned paragraphs are reset according to the element type of the paragraph to obtain a rearranged version of the original document.

2. The method according to claim 1, characterized in that The step of performing paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraphs, includes: Traversing the paragraphs in the original document one by one; For the currently traversed paragraph, when it is determined to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph in the original document is cleaned, and the paragraph attribute of the cleaned paragraph is reset according to the element type of the paragraph; The method further comprises: For the currently traversed paragraph, if it is determined not to perform paragraph attribute cleaning processing on the paragraph according to the set first cleaning rule and the paragraph attribute of the paragraph in the original document, the paragraph attributes are reset according to the element type of the paragraph.

3. The method according to claim 1, characterized in that The step of performing paragraph attribute cleaning on the paragraphs in the original document according to the set first cleaning rule, and resetting the paragraph attributes of the cleaned paragraphs according to the element type of the paragraphs, includes: The paragraphs in the original document are cleaned for paragraph attributes according to the set first cleaning rule, and the style attributes corresponding to the element type of the paragraph are set for the cleaned paragraphs according to the element type of the paragraph.

4. The method according to claim 3, characterized in that The method further comprises: Determine the target format properties; The format attributes of the paragraph after the style attributes are set are set according to the target format attributes.

5. The method according to claim 4, characterized in that The determining of the target format attribute comprises: A format attribute corresponding to the element type of the paragraph is acquired as a target format attribute.

6. The method according to claim 4, characterized in that The determining of the target format attribute comprises: The format attribute set for the paragraph in the original document is acquired as a target format attribute.

7. The method according to claim 4, characterized in that The determining of the target format attribute comprises: The style attribute set for the paragraph in the original document is obtained, and the format attribute defined in the style attribute is used as the target format attribute.

8. The method according to claim 1, characterized in that After resetting the paragraph attributes of the cleaned paragraph according to the element type of the paragraph, the method further includes: The original document after resetting the paragraph attributes is used as the intermediate typesetting document, the paragraphs in the intermediate typesetting document are optimized according to the set second cleaning rules, and the original document after the typesetting optimization is used as the re-typesetting document of the original document.

9. The method according to claim 8, characterized in that The performing typesetting optimization processing on the paragraphs in the intermediate typesetting document according to the set second cleaning rule includes: According to a set second cleaning rule, identifying redundant typesetting elements from the intermediate typesetting document; In the intermediate typeset document, the typeset redundant elements are deleted.

10. The method according to claim 8, characterized in that The method further comprises: Identifying, from the intermediate typeset document, incorrect typeset styles associated with paragraph breaks or page breaks; Correct the erroneous typesetting style.

11. The method according to any one of claims 1 to 10, characterized in that: The step of determining the element type of a paragraph in the original document to be typeset includes: Creating a copy document of the original document to be typeset, 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.

12. The method according to claim 11, 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: An element type determination module, used to determine the element type of a paragraph in an original document to be typeset; The rearrangement module is used to 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 rearranged version of the original 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.

Citation Information

Cited By

  • Data cleaning and transcription method and device, electronic equipment and storage medium

    CN120124107A