Document processing method and device, electronic equipment and storage medium

By determining the element types and original indentation representation of document paragraphs, a target paragraph layout strategy is formulated, which solves the problems of insufficient format compatibility and personalized support of AI paragraph indentation typesetting schemes, achieves accurate paragraph indentation typesetting, and improves user experience.

CN121835592APending Publication Date: 2026-04-10ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing AI-powered paragraph indentation and formatting solutions are inadequate in terms of format compatibility, demand adaptability, and personalized support, failing to achieve accurate paragraph indentation and formatting and impacting user experience.

Method used

By determining the element type and original indentation representation of each paragraph in the document to be processed, the target paragraph layout strategy for each paragraph is determined based on this information, and paragraph layout processing is performed based on this strategy, including cleaning up original indentation-related information and setting the corresponding paragraph layout style.

Benefits of technology

It achieves differentiated indentation requirements for different content types, preserves the user's original layout intention, breaks through the limitations of fixed templates, and provides accurate, neat, and user-expected paragraph indentation layout effects, improving the practicality and user experience of AI document layout.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121835592A_ABST
    Figure CN121835592A_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 and original indentation representation quantities of paragraphs in a to-be-processed document; determining a target paragraph layout strategy corresponding to each paragraph according to the element type and / or the original indentation representation quantity; based on the target paragraph layout strategy, paragraph layout processing is conducted on each paragraph, and a processed document is obtained. Therefore, the technical problem that an existing AI paragraph indentation typesetting scheme is insufficient in demand adaptability and personalized support is effectively solved, an accurate and regular paragraph indentation typesetting effect meeting user expectation is achieved, and AI document typesetting practicability and user experience are remarkably improved.
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 and device, electronic equipment and storage medium. BACKGROUND

[0002] Paragraph indentation is a core element of document formatting, which reflects the content logical relationship through visual hierarchy (such as the distinction between title and body, list item and content), directly affects the readability of the document, and is a necessary link for the formatting of various documents (official documents, papers, reports, etc.). The current paragraph indentation processing faces multiple technical challenges: First, the user indentation implementation is chaotic and difficult to be compatible. User editing habits differ, resulting in various indentation methods, including space simulation, tab characters, paragraph property settings, and numbered property association. Non-uniform implementation methods make the original indentation data format chaotic, and if it cannot be normalized, it may cause subsequent formatting distortion. Second, the user indentation requirements are difficult to adapt to differences. Different content (title, body, quotation) has different indentation requirements (such as canceling indentation for titles, first-line indentation for bodies, and hanging indentation for list items). Even the same type of content (such as the same body), may have multiple demands (such as 2-character / 4-character first-line indentation) under different documents or user preferences, and traditional formatting is difficult to meet the flexible requirements.

[0003] However, the current AI (Artificial Intelligence) document formatting mostly uses "template style fixed matching" to process paragraph indentation, that is, configuring a unique indentation template for each type of element (primary title, body, etc.), and binding the template to the same type of element for unified processing during formatting. This method has obvious defects: the same type of element indentation is forced to be uniform, and cannot be adapted to different requirements; and it may ignore the user's original reasonable indentation intention, and even destroy the original hierarchical relationship of the document, resulting in a large deviation between the formatting result and the user's expectation. SUMMARY

[0004] The present application provides a document processing method, device, electronic equipment and storage medium to solve the technical problem that the existing AI paragraph indentation formatting scheme has obvious deficiencies in format compatibility, requirement adaptability and personalized support, and cannot achieve accurate paragraph indentation formatting, affecting user experience.

[0005] In a first aspect, the present application provides a document processing method, which comprises: determining the element type and original indentation representation of each paragraph in the to-be-processed document; determining the target paragraph layout strategy corresponding to each paragraph according to the element type and / or the original indentation representation; performing paragraph layout processing on each paragraph based on the target paragraph layout strategy to obtain a processed document.

[0006] In a possible implementation, the original indentation representation of each paragraph in the document to be processed is determined, including: identifying original indentation related information of each paragraph in the document to be processed, the original indentation related information including at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute; converting the identified original indentation related information into the original indentation representation according to a preset standard unit.

[0007] In a possible implementation, in a case where the element type of the paragraph is a first type of element type, the determining, according to the element type and / or the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs includes: determining a preset first indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing paragraph layout processing on the paragraph based on the first indentation strategy, including: cleaning up original indentation related information of the paragraph, the original indentation related information including at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute; setting a preset paragraph layout style corresponding to the element type of the paragraph on the cleaned-up paragraph.

[0008] In a possible implementation, in a case where the element type of the paragraph is a second type of element type, the determining, according to the element type and / or the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs includes: determining a preset second indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing paragraph layout processing on the paragraph based on the second indentation strategy, including: cleaning up original indentation related information of the paragraph, the original indentation related information including at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute; setting a preset paragraph layout style corresponding to the element type of the paragraph on the cleaned-up paragraph; determining whether to set a first-line indentation for the paragraph according to whether there is body text between the paragraph and a previous title of the paragraph and an alignment mode of the preset paragraph layout style.

[0009] In a possible implementation, the determining, according to whether there is body text between the paragraph and a previous title of the paragraph and an alignment mode of the preset paragraph layout style, of whether to set a first-line indentation for the paragraph includes: In a case where there is text between the paragraph and the upper-level title of the paragraph, and the alignment mode of the preset paragraph layout style is a default alignment mode, a specified first-line indentation amount is set for the paragraph; In a case where there is no text between the paragraph and the upper-level title of the paragraph, or there is no text between the paragraph and the upper-level title of the paragraph and the alignment mode of the preset paragraph layout style is not the default alignment mode, it is determined that no first-line indentation is set for the paragraph.

[0010] In a possible implementation, in a case where the element type of the paragraph is a third type of element type, the determining, according to the element type and / or the original indentation characterization amount, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: The target paragraph layout strategy corresponding to each of the paragraphs is determined according to the element type and the original indentation characterization amount.

[0011] In a possible implementation, the determining, according to the element type and the original indentation characterization amount, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: In a case where the original indentation characterization amount indicates that the first-line indentation amount of the paragraph is the same as the rest-line indentation amount, a preset fourth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph is processed according to the fourth indentation strategy, comprising: In a case where the first-line indentation amount and the rest-line indentation amount are both a first value, a specified first-line indentation amount is set for the paragraph. In a case where the first-line indentation amount and the rest-line indentation amount are both greater than the first value, a first nearest adsorption strategy is used to adjust the first-line indentation amount of the paragraph. The rest-line indentation amount of the paragraph is adjusted to be consistent with the current first-line indentation amount.

[0012] In a possible implementation, the determining, according to the element type and the original indentation characterization amount, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: In a case where the original indentation characterization amount indicates that the first-line indentation amount of the paragraph is greater than the rest-line indentation amount, a preset fifth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph is processed according to the fifth indentation strategy, comprising: A second nearest adsorption strategy is used to adjust the rest-line indentation amount of the paragraph. set a specified first-line indentation for the paragraph, in a case where the adjusted remaining-line indentation is the first value; or adjust the first-line indentation of the paragraph to be consistent with the current remaining-line indentation, in a case where the adjusted remaining-line indentation is greater than the first value.

[0013] In a possible implementation, the determining, according to the element type and the original indentation representation, of the target paragraph layout strategy corresponding to each of the paragraphs comprises: determining a difference between the remaining-line indentation and the first-line indentation of the paragraph, in a case where the original indentation representation indicates that the first-line indentation of the paragraph is less than the remaining-line indentation; determining the target paragraph layout strategy corresponding to the paragraph according to the difference.

[0014] In a possible implementation, the determining, according to the difference, of the target paragraph layout strategy corresponding to the paragraph comprises: determining a preset sixth indentation strategy as the target paragraph layout strategy corresponding to the paragraph, in a case where the difference is less than a second value; performing, based on the sixth indentation strategy, paragraph layout processing on the paragraph, comprising: adjusting the first-line indentation of the paragraph by using a first nearest adsorption strategy; adjusting the remaining-line indentation of the paragraph to be consistent with the current first-line indentation.

[0015] In a possible implementation, the determining, according to the difference, of the target paragraph layout strategy corresponding to the paragraph comprises: determining a preset seventh indentation strategy as the target paragraph layout strategy corresponding to the paragraph, in a case where the difference is greater than or equal to a second value; performing, based on the seventh indentation strategy, paragraph layout processing on the paragraph, comprising: adjusting the first-line indentation of the paragraph by using a first nearest adsorption strategy; setting a specified remaining-line indentation for the paragraph, the specified remaining-line indentation being a sum of the current first-line indentation of the paragraph and a preset indentation.

[0016] In a possible implementation, the adjusting, by using the first nearest adsorption strategy, of the first-line indentation of the paragraph comprises: comparing the first-line indentation of the paragraph with a set of preset first-line target adsorption values; adjusting the first-line indentation of the paragraph to be the first-line target adsorption value that is the nearest neighbor of the first-line indentation according to a preset nearest neighbor rule.

[0017] In a possible implementation, the adjusting the remaining line indentation of the paragraph according to the second nearest adsorption strategy comprises: comparing the remaining line indentation of the paragraph with a set of preset remaining line target adsorption values; adjusting the remaining line indentation of the paragraph to the remaining line target adsorption value that is the nearest neighbor of the remaining line indentation according to a preset nearest neighbor rule.

[0018] In a possible implementation, after the paragraph layout processing of each of the paragraphs based on the target paragraph layout strategy, the method further comprises: performing an indentation alignment processing on the text paragraphs belonging to the same numbered interval.

[0019] In a possible implementation, after the paragraph layout processing of each of the paragraphs based on the target paragraph layout strategy, the method further comprises: adjusting the hanging indentation setting of the paragraph according to the difference between the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing.

[0020] In a possible implementation, the adjusting the hanging indentation setting of the paragraph according to the difference between the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing comprises: maintaining the current paragraph layout attribute of the paragraph in the case that one of the following conditions is met: the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are the same, the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are different and the first line of the paragraph does not have a section title; in the case that the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are different and the first line of the paragraph has a section title, setting the hanging indentation of the paragraph according to the length of the section title.

[0021] In a second aspect, the present application provides a document processing device, which comprises: a first determining module configured to determine the element type and the original indentation representation of each paragraph in a document to be processed; a second determining module configured to determine the target paragraph layout strategy corresponding to each of the paragraphs according to the element type and / or the original indentation representation; a paragraph layout module configured to perform a paragraph layout processing on each of the paragraphs based on the target paragraph layout strategy, to obtain a processed document.

[0022] In a possible implementation, the first determining module determines the original indentation representation of each paragraph in the document to be processed, which comprises: The original indentation related information of each paragraph in the document to be processed is identified, and the original indentation related information includes at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute. The identified original indentation related information is converted into the original indentation representation according to a preset standard unit.

[0023] In a possible implementation, when the element type of the paragraph is a first type of element type, the second determination module is specifically configured to: determine a preset first indentation strategy as the target paragraph layout strategy corresponding to the paragraph; The paragraph layout module includes: a cleaning unit configured to clean original indentation related information of the paragraph, the original indentation related information including at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute; a setting unit configured to set a preset paragraph layout style corresponding to the element type of the paragraph to the cleaned paragraph.

[0024] In a possible implementation, when the element type of the paragraph is a second type of element type, the second determination module is specifically configured to: determine a preset second indentation strategy as the target paragraph layout strategy corresponding to the paragraph; The paragraph layout module includes: a cleaning unit configured to clean original indentation related information of the paragraph, the original indentation related information including at least one of a paragraph indentation attribute, a first character invisible character, and a numbered indentation attribute; a setting unit configured to set a preset paragraph layout style corresponding to the element type of the paragraph to the cleaned paragraph; a first line indentation setting unit configured to determine whether to set a first line indentation for the paragraph according to whether there is body text between the paragraph and a previous title of the paragraph and an alignment mode of the preset paragraph layout style.

[0025] In a possible implementation, the first line indentation setting unit is specifically configured to: in a case where there is body text between the paragraph and the previous title of the paragraph and the alignment mode of the preset paragraph layout style is a default alignment mode, set a specified first line indentation amount for the paragraph; in a case where there is no body text between the paragraph and the previous title of the paragraph, or there is no body text between the paragraph and the previous title of the paragraph and the alignment mode of the preset paragraph layout style is not the default alignment mode, determine not to set a first line indentation for the paragraph.

[0026] In a possible implementation, in a case where the element type of the paragraph is a third type of element type, the second determining module is specifically configured to: determine a target paragraph layout strategy corresponding to each of the paragraphs according to the element type and the original indentation representation.

[0027] In a possible implementation, the second determining module is specifically configured to: in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is the same as the rest-line indentation amount of the paragraph, determine a preset fourth indentation strategy as the target paragraph layout strategy corresponding to the paragraph; The paragraph layout module is specifically configured to: in a case where the first-line indentation amount and the rest-line indentation amount are both a first value, set a specified first-line indentation amount for the paragraph; in a case where the first-line indentation amount and the rest-line indentation amount are both greater than the first value, adjust the first-line indentation amount of the paragraph by using a first nearest adsorption strategy; adjust the rest-line indentation amount of the paragraph to be consistent with the current first-line indentation amount.

[0028] In a possible implementation, the second determining module is specifically configured to: in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is greater than the rest-line indentation amount of the paragraph, determine a preset fifth indentation strategy as the target paragraph layout strategy corresponding to the paragraph; The paragraph layout module comprises: a first adjusting unit configured to adjust the rest-line indentation amount of the paragraph by using a second nearest adsorption strategy; a second adjusting unit configured to, in a case where the adjusted rest-line indentation amount is a first value, set a specified first-line indentation amount for the paragraph, or in a case where the adjusted rest-line indentation amount is greater than the first value, adjust the first-line indentation amount of the paragraph to be consistent with the current rest-line indentation amount.

[0029] In a possible implementation, the second determining module comprises: a difference calculating unit configured to, in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is less than the rest-line indentation amount of the paragraph, determine a difference between the rest-line indentation amount and the first-line indentation amount; a strategy determining unit configured to determine a target paragraph layout strategy corresponding to the paragraph according to the difference.

[0030] In a possible implementation, the strategy determining unit is specifically configured to: determining a sixth preset indentation strategy as the target paragraph layout strategy corresponding to the paragraph when the difference is less than a second value; The paragraph layout module comprises: The third adjustment unit is configured to adjust the first-line indentation of the paragraph according to a first nearest adsorption strategy. The fourth adjustment unit is configured to adjust the remaining-line indentation of the paragraph to be consistent with the current first-line indentation.

[0031] In a possible implementation, the strategy determination unit is specifically configured to: determining a seventh preset indentation strategy as the target paragraph layout strategy corresponding to the paragraph when the difference is greater than or equal to the second value; The paragraph layout module comprises: The third adjustment unit is configured to adjust the first-line indentation of the paragraph according to a first nearest adsorption strategy. The fifth adjustment unit is configured to set a specified remaining-line indentation for the paragraph, the specified remaining-line indentation being a sum of the current first-line indentation of the paragraph and a preset indentation.

[0032] In a possible implementation, the third adjustment unit is specifically configured to: comparing the first-line indentation of the paragraph with a group of preset first-line target adsorption values; adjusting the first-line indentation of the paragraph to a first-line target adsorption value nearest to the first-line indentation according to a preset nearest neighbor rule.

[0033] In a possible implementation, the first adjustment unit is specifically configured to: comparing the remaining-line indentation of the paragraph with a group of preset remaining-line target adsorption values; adjusting the remaining-line indentation of the paragraph to a remaining-line target adsorption value nearest to the remaining-line indentation according to a preset nearest neighbor rule.

[0034] In a possible implementation, the apparatus further comprises: The first reprocessing module is configured to perform indentation alignment processing on text paragraphs belonging to the same numbering interval after the paragraph layout processing is performed on each of the paragraphs based on the target paragraph layout strategy.

[0035] In a possible implementation, the apparatus further comprises: The second reprocessing module is configured to adjust the hanging indentation setting of the paragraph according to a difference between the first-line indentation and the remaining-line indentation of the paragraph after the paragraph layout processing is performed on each of the paragraphs based on the target paragraph layout strategy.

[0036] In a possible implementation, the second reprocessing module is specifically configured to: In a case where one of the following conditions is met, the current paragraph layout attribute of the paragraph is maintained: the first line indentation of the paragraph after the paragraph layout processing is the same as the indentation of the remaining lines, the first line indentation of the paragraph after the paragraph layout processing is different from the indentation of the remaining lines, and the first line of the paragraph does not have a section title; In a case where the first line indentation of the paragraph after the paragraph layout processing is different from the indentation of the remaining lines, and the first line of the paragraph has a section title, the hanging indentation is set for the paragraph according to the length of the section title.

[0037] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the processor is configured to execute a document processing program stored in the memory to implement the document processing method of any one of the first aspect.

[0038] In a fourth aspect, the present application provides a storage medium, the storage medium stores one or more programs, the one or more programs can be executed by one or more processors to implement the document processing method of any one of the first aspect.

[0039] The above technical solution provided by the embodiments of the present application has the following advantages compared with the prior art: the method provided by the embodiments of the present application determines the element type and the original indentation representation of each paragraph in the to-be-processed document, determines the target paragraph layout strategy corresponding to each paragraph according to the element type and / or the original indentation representation, and performs paragraph layout processing on each paragraph based on the target paragraph layout strategy to obtain a processed document, which can adapt to the differentiated indentation requirements of different content types, and can also adapt to the typesetting strength requirements of different document categories according to the original indentation characteristics, breaking through the limitations of the fixed template "one size fits all"; finally, each paragraph is processed based on the targeted target strategy, rather than forcibly unified in the same element style, which can not only preserve the user's reasonable original typesetting intention (such as intentional special hanging indentation), but also realize differentiated and accurate paragraph indentation typesetting, effectively solving the deficiencies of the prior art in demand adaptability and personalized support, and finally realizing accurate, neat and user-expected paragraph indentation typesetting effect, significantly improving the practicality and user experience of AI document typesetting. BRIEF DESCRIPTION OF DRAWINGS

[0040] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the application.

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0042] One or more embodiments are illustrated by the drawings in the corresponding figures, which do not constitute a limitation on the embodiments, and elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified. The drawings in the figures do not constitute a proportional limit.

[0043] Figure 1 A schematic diagram of a system architecture related to the embodiments of the present application; Figure 2 An embodiment flowchart of a document processing method provided by the embodiments of the present application; Figure 3 An example diagram of a sub-document structure; Figure 4 A schematic diagram of visual presentation forms of multiple paragraph indents and paragraph spaces; Figure 5 An embodiment flowchart of another document processing method provided by the embodiments of the present application; Figure 6 A schematic diagram of a typesetting effect realized by applying the document processing method provided by the embodiments of the present application; Figure 7 An embodiment flowchart of another document processing method provided by the embodiments of the present application; Figure 8 A schematic diagram of a typesetting effect realized by applying the document processing method provided by the embodiments of the present application; Figure 9 A schematic diagram of a typesetting effect realized by applying the document processing method provided by the embodiments of the present application; Figure 10 An embodiment flowchart of another document processing method provided by the embodiments of the present application; Figure 11 A schematic diagram of a typesetting effect realized by applying the document processing method provided by the embodiments of the present application; Figure 12 A schematic diagram of a typesetting effect realized by applying the document processing method provided by the embodiments of the present application; Figure 13 An embodiment block diagram of a document processing device provided by the embodiments of the present application; Figure 14 A structural schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0044] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0045] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present application. For the purpose of simplicity, the elements and settings of particular examples in the following description will be described with reference to specific arrangements. It will be clear, however, that this is simply for the purposes of providing a thorough and complete disclosure and is not intended to limit the present application. Moreover, the present application can repeat reference numerals and / or letters in various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and / or settings discussed.

[0046] In order to solve the technical problems that the AI paragraph indentation typesetting scheme in the prior art has obvious deficiencies in format compatibility, requirement adaptability and personalized support, cannot realize accurate paragraph indentation typesetting, and affects user experience, the present application provides a document processing method and device, electronic equipment and storage medium, which can realize accurate, regular and user-expected paragraph indentation typesetting effect, and significantly improve the practicality and user experience of AI document typesetting.

[0047] Figure 1 A schematic diagram of a system architecture related to the embodiments of the present application is shown. As shown in Figure 1 The system architecture 100 can include a client 101, a server 102, a model end 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 end 103, and can include a wireless link, a wired link or an optical fiber cable, etc., which is not limited by the present application.

[0048] The client 101 can 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 can be various electronic devices with a display screen, including but not limited to smartphones, tablet computers, laptop computers, desktop computers, servers, etc. When the device is software, it can be installed in the above-mentioned electronic devices.

[0049] The service end 102 is the core processing unit of the entire system architecture 100, and can be deployed with various algorithms and relatively powerful computing resources. Among them, the algorithms can involve multiple fields such as data processing, machine learning, and deep learning, for processing data uploaded by the client 101 or requests sent, and performing specific computing tasks such as document parsing, document preprocessing, and strategy scheduling. The computing resources can include high-performance computing clusters, GPU acceleration cards, etc., which are used to support fast execution and efficient processing of algorithms.

[0050] 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, the document element recognition model and the natural language processing model 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, and body) of the paragraph in the input document. When the service end 102 receives the request of the client 101 and needs to call the model, the request is forwarded to the model end 103, and the model end 103 performs inference calculation using the deployed model to output the corresponding result. In addition, as the algorithm continues to advance and the data continues to accumulate, the models deployed on the model end 103 can be updated or optimized regularly. For example, the model end 103 supports automatic updating and version control of the model, ensuring that the model can always maintain the latest performance and accuracy. For example, the service end 102 is responsible for managing the models on the model end 103, including uploading, updating, deleting, version controlling, and calling the models, etc.

[0051] It can be understood that, Figure 1 The number of networks and devices in the system architecture 100 is only illustrative. According to actual needs, the system architecture 100 can include any number of networks and devices, and the embodiments of the present application do not limit this.

[0052] In some examples, at least two of the client 101, the service end 102, and the model end 103 can be the same device, and different ends in the same device can also transmit data to each other through wireless or wired connection.

[0053] Figure 2 An embodiment flowchart of a document processing method provided by the embodiments of the present application. In an embodiment, the method is applied to a service end, for example, the service end 102 as shown in Figure 1 . As shown in Figure 2 , the method includes the following steps: Step 201, determining the element type of each paragraph in the to-be-processed document and the original indentation representation.

[0054] In an embodiment, the to-be-processed document mentioned above refers to the original document, for example, the document that needs to be typeset when the client 101 sends the automatic typesetting request of the document to the service end 102.

[0055] In another embodiment, the target document is not the original document, but a preprocessed copy of the original document. Exemplarily, preprocessing the copy of the original document includes, but is not limited to: identifying soft returns from the copy and converting them into paragraph marks to restore the correct paragraph structure; identifying separators attached to paragraph content from the copy and inserting paragraph marks between the separators and their attached paragraph content to restore the correct paragraph structure; identifying lines ending with multiple consecutive spaces or tabs from the copy, deleting the consecutive spaces or tabs at the end of the line, and inserting a paragraph mark at the end of the line; and so on. This application does not limit this approach.

[0056] In summary, the key purpose of preprocessing a copy of the original document is to ensure that the content in the document can be correctly segmented. Correct segmentation is an important prerequisite for the subsequent model to identify the element types of paragraphs in the document, and it is also an important prerequisite for correctly formatting paragraphs after the element types of paragraphs are determined.

[0057] In another embodiment, the target document is a portion of the original document or the preprocessed document described above, such as one or several pages. An exemplary application scenario here could be: when the paragraph layout of certain pages (such as a poorly formatted appendix page or a frequently revised technical parameter page) in the original or preprocessed document is significantly abnormal, while the layout of other parts is relatively normal, then the pages containing these paragraphs can be isolated and the method provided in this application embodiment can be applied for paragraph layout processing to ensure that the paragraph indentation and alignment of this local area conform to the preset layout specifications, while not affecting the original layout of other parts of the document.

[0058] Furthermore, in one embodiment, for complex scenarios where the document to be processed contains sub-documents, the method provided in this application is executed on a per-sub-document basis, that is, first identifying the embedded sub-documents and embedded-parallel sub-documents in the document to be processed (see [link to specific structure]). Figure 3 (As shown in the example of embedded sub-documents and embedded-parallel sub-document structures), each sub-document is then treated as an independent document to be processed, and paragraph indentation and alignment are performed one by one to ensure that the internal format of each sub-document is consistent while not interfering with each other's independent formatting logic.

[0059] Meanwhile, before typesetting a single sub-document, three types of content that do not need to be adapted to the general indentation alignment rule can be excluded first: first, the areas such as the cover and the table of contents have clear typesetting requirements. For example, the cover of a paper needs to present the specific layout of the title, the author, and the affiliated unit, and the table of contents needs to maintain the corresponding format of the chapter title and the page number. If the indentation of such areas is forcibly adjusted, the preset specification will be damaged, and therefore, the processing of the present method does not need to be performed. Second, the main text with scene-based typesetting requirements, such as the signing information of the contractor and the contractor in the contract, the main recipient in the official document, the title of the clause “in view of”, the caption title below the chart, the appendix description corresponding to the attachment list, and the seal information at the end of the text, need to maintain their inherent format characteristics (for example, the signing information is clearly segmented, and the seal information is right-aligned), and only need to apply the basic text style without additional adjustment of the indentation. Third, the paragraph interval of the multi-level numbering (including the manually input hand-written numbering and the automatically generated numbering of the document) needs to be excluded from the processing, and the original indentation and the matching relationship of the numbering need to be maintained, because the multi-level numbering has clear level attributes, and the change of the paragraph indentation will directly affect the level regularity of the numbering style. If the indentation is forcibly intervened, the correlation logic between the numbering and the content will be easily broken.

[0060] In the technical scheme provided by the embodiments of the present application, the element type of the paragraph covers not only the basic elements common to various types of documents, but also the exclusive elements in specific scenarios. The common elements include the document title, the sub-title, the chapter title, the attachment title, the main text title, and the main text. The exclusive elements in specific scenarios include the main recipient in the official document, the seal information, the signing information in the contract, and the keywords and the concluding remarks in the paper. The embodiments of the present application do not limit the coverage of the element type of the paragraph.

[0061] In an embodiment, a document element identification model is used to identify the element type of each paragraph in the to-be-processed document. The document element identification model is a model used to identify the element type of the paragraph in the document. Figure 1 In the system architecture shown, the document element identification model is deployed on the model end 103.

[0062] The original indentation representation of the paragraph refers to a quantitative index capable of reflecting the original visual indentation effect of the paragraph, which includes the indentation directly defined by the document format attribute (such as the first-line indentation, the hanging indentation, the text front indentation, and the numbering indentation), and the equivalent indentation amount simulated by the invisible character at the beginning of the paragraph (such as the half-space, the tab character, and the tab position setting), for example, 4 half-spaces at the beginning of the paragraph, and 1 tab character with a width of 2 characters, which belong to the category of visual indentation.

[0063] In an embodiment, the original indentation representation of each paragraph in the document to be processed is determined by: identifying original indentation related information of each paragraph in the document to be processed, wherein the original indentation related information comprises at least one of paragraph indentation attribute, invisible character at the beginning of a paragraph, and numbered indentation attribute; and converting the identified original indentation related information into the original indentation representation according to a preset standard unit.

[0064] In this embodiment, the original indentation related information of each paragraph is first comprehensively identified, which includes three types of content: first, paragraph indentation attribute (such as first line indentation of 2 characters, hanging indentation of 2 characters), second, invisible character at the beginning of a paragraph (such as tab character, space, and corresponding character width setting, such as 5 tab characters), and third, numbered indentation attribute (such as automatic numbering or 2-character indentation of multi-level numbering). Subsequently, the original indentation related information is uniformly converted according to a preset standard unit, and finally the original indentation representation is obtained.

[0065] As an optional implementation, the preset standard unit is "character", and then non-character units (such as centimeters, pounds) or invisible character quantities can be converted into equivalent character numbers to ensure the consistency and comparability of the indentation data.

[0066] Herein, the examples of Figure 4 are combined, Figure 4 demonstrates various visual presentation forms of paragraph indentation and paragraph blank. Among them, "X" corresponds to the quantitative representation of first line indentation (for example, taking the number of characters as the reference dimension), and "Y" corresponds to the quantitative representation of hanging indentation or paragraph blank.

[0067] Figure 4 In the first paragraph in the order from top to bottom, the label is "X=0 first line=0; Y=0 hanging=0; X=Y paragraph=0", and the original indentation related information of the paragraph is: first line indentation of 0 characters, hanging indentation of 0 characters, paragraph indentation of 0 characters, numbered indentation of 0 characters, and no invisible character at the beginning of a paragraph. After conversion, the original indentation representation of the paragraph is: first line indentation of 0 characters, and the remaining lines (lines other than the first line) indentation of 0 characters.

[0068] Figure 4 In the second paragraph in the order from top to bottom, the label is "X>0 first line=X; Y=0 hanging=0; X>Y paragraph=0", and the original indentation related information of the paragraph is: first line indentation of X characters, hanging indentation of 0 characters, paragraph indentation of 0 characters, numbered indentation of 0 characters, and no invisible character at the beginning of a paragraph. After conversion, the original indentation representation of the paragraph is: first line indentation of X characters, and the remaining lines (lines other than the first line) indentation of 0 characters.

[0069] Figure 4In the third paragraph from top to bottom, it is marked as "X=0 first line=0; Y>0 hanging=Y; XY, the original indentation information of this paragraph is: first line indentation 0 characters, hanging indentation Y characters, paragraph indentation 0 characters, numbering indentation 0 characters, no paragraph invisible characters. After conversion, the original indentation representation of this paragraph is obtained: first line indentation 0 characters, the rest of the lines (except the first line) indentation Y characters.

[0070] Figure 4 In the fourth paragraph group from top to bottom, it is marked as "X>0 first line=0; Y>0 hanging=0; X=Y paragraph=X=Y", the original indentation information of this paragraph is: first line indentation 0 characters, hanging indentation 0 characters, paragraph indentation X characters, numbering indentation 0 characters, no paragraph invisible characters. After conversion, the original indentation representation of this paragraph is obtained: first line indentation X characters, the rest of the lines (except the first line) indentation Y (Y=X) characters.

[0071] Figure 4 In the last paragraph group from top to bottom, it is marked as "X>0 first line=0; Y>0 hanging=Y-X; XY, the original indentation information of this paragraph is: first line indentation 0 characters, hanging indentation (Y-X) characters, paragraph indentation X characters, numbering indentation 0 characters, no paragraph invisible characters. After conversion, the original indentation representation of this paragraph is obtained: first line indentation X characters, the rest of the lines (except the first line) indentation Y (Y>X) characters.

[0072] Through Figure 4 As can be seen from the examples of different paragraph layouts, whether the original indentation is directly defined by the paragraph format attribute or simulated by the paragraph invisible characters, the accurate original indentation representation can be obtained by identifying the related information such as paragraph indentation attribute, paragraph invisible character, numbering indentation attribute, and converting it into the standard unit of "characters", which provides a unified and comparable quantitative basis for the subsequent step of "determining the target paragraph layout strategy".

[0073] Step 202, according to the element type and / or the original indentation representation, determine the target paragraph layout strategy corresponding to each paragraph respectively.

[0074] The target paragraph layout strategy refers to the specific typesetting rule determined for each paragraph to guide the paragraph layout processing in order to achieve the uniformity of paragraph format and the preservation of reasonable user typesetting habits. This rule clearly specifies the specific requirements of the indentation amount (such as the number of characters of first line indentation, the number of characters of the rest of the lines indentation) and / or the paragraph alignment mode (such as left alignment, center alignment, right alignment, etc.) that the paragraph should adopt.

[0075] In step 202, the target paragraph layout strategy is determined in combination with two types of information: one is the element type of the paragraph (such as document title, chapter title; text type: text title, text text, main object, signing information, etc.), which clearly defines the inherent layout requirements of different elements; the second is the original indentation representation of the paragraph, that is, the original indentation value of the reference paragraph, which preserves the user's potential layout habits (such as the original first line indentation of a paragraph is 3 characters, although it is not a standard value, but based on the "near adsorption" logic, the target indentation is determined to be 4 characters, rather than directly forced to be 2 characters).

[0076] As to how to determine the target paragraph layout strategy of each paragraph according to the element type and / or original indentation representation, different embodiments will be explained in detail in the following, which will not be described here.

[0077] In step 203, based on the target paragraph layout strategy, each paragraph is processed respectively to obtain the processed document.

[0078] In step 203, according to the target layout strategy corresponding to each paragraph, differential paragraph layout processing is carried out one by one. For example, for the large title type (such as document title, chapter title), the invisible characters at the beginning of the paragraph, redundant formats and other contents affecting indentation alignment are cleaned according to the strategy, and then the template preset style is applied (such as document title is centered and aligned, text is indented by 0 characters before and after, chapter title is left aligned and the paragraph is left blank); for text text, the indentation is adjusted according to the "2 character interval near adsorption" strategy (such as the original first line indentation is 1.5 characters, which is adjusted to 2 characters, and the original first line indentation is 3.5 characters, which is adjusted to 4 characters), the indentation of paragraphs in the same number interval is pulled, and the hanging indentation is improved according to the layout in the paragraph (such as the first line and the remaining lines are indented differently, which are kept, and the same is processed as a hanging effect); for special text (such as signing information, notes), the basic style of text text is applied first, and then the original format is retained or adjusted as needed (such as signing information is left aligned and the paragraphs are left blank); for unknown content (filtered text), only the font size of the text text is set according to the strategy, and the original indentation and alignment are not changed; for the exception area (cover, table of contents, header), it is strictly processed according to the strategy without any layout processing.

[0079] Through the above targeted processing, the processed document with uniform format, clear level and maximum preservation of the user's original indentation relationship is finally obtained, which improves the applicability and layout effect of AI document layout.

[0080] As to how to process each paragraph based on the target paragraph layout strategy to obtain the processed document, different embodiments will be explained in detail in the following, which will not be described here.

[0081] The technical solution provided in this application determines the element type and original indentation representation of each paragraph in the document to be processed. Based on the element type and / or the original indentation representation, it determines the target paragraph layout strategy corresponding to each paragraph. Based on the target paragraph layout strategy, it processes the paragraph layout separately to obtain the processed document. This provides a method that can adapt to the differentiated indentation requirements of different content types and adapt to the typesetting requirements of different document categories according to the original indentation characteristics, breaking through the limitations of fixed templates. Finally, it processes each paragraph separately based on a targeted target strategy, rather than forcibly unifying the style of similar elements. This preserves the user's reasonable original typesetting intention (such as intentionally set special hanging indentation) and achieves differentiated and precise paragraph indentation typesetting. It effectively solves the shortcomings of existing solutions in terms of demand adaptability and personalized support, and finally achieves accurate, regular paragraph indentation typesetting effect that meets user expectations, significantly improving the practicality and user experience of AI document typesetting.

[0082] The above has been approved. Figure 2 The process shown above provides an overall explanation of the technical solutions provided in the embodiments of this application. The following sections will explain in detail the different needs in actual typesetting scenarios.

[0083] First scenario: In one embodiment, when the element type of a paragraph is a first type of element type, a target paragraph layout strategy corresponding to each paragraph is determined based on the element type and / or the original indentation representation, including: determining a preset first indentation strategy as the target paragraph layout strategy corresponding to the paragraph. Further, based on the first indentation strategy, paragraph layout processing is performed on the paragraph, including: cleaning up the original indentation-related information of the paragraph, and setting a preset paragraph layout style corresponding to the element type of the paragraph on the cleaned paragraph.

[0084] In this embodiment, the first type of element includes headings, such as document titles, subtitles, chapter titles, and attachment titles. For these elements, the core of the automatic formatting logic is to achieve format uniformity and visual prominence of heading elements by "cleaning up redundant formatting and applying preset styles".

[0085] Specifically, the large title type paragraph can have "redundant format" added by user's misoperation, such as redundant space / tab (indentation simulated by invisible characters) at the beginning of the paragraph, improper setting of paragraph indentation attribute (such as first line indentation of 2 characters), redundant indentation of numbering system, etc. These original indentation related information will destroy the simplicity and visual prominence of the large title, therefore, the original indentation related information of the large title type paragraph is first comprehensively cleaned up. The "comprehensive cleaning" here specifically covers three types of original indentation related information: first, the indentation attribute of the paragraph itself, second, the invisible characters at the beginning of the paragraph, and third, the indentation attribute associated with numbering.

[0086] After the original indentation related information of the large title type paragraph is comprehensively cleaned up, the large title type paragraph is applied with the preset paragraph layout style matching the element type. For example, the document title can be preset as "center alignment, first line indentation of 0 characters, 3 lines of white space before and after the paragraph, 2 font size and bold Songti" and the chapter title can be preset as "left alignment, first line indentation of 0 characters, 2 lines of white space before the paragraph, 3 font size and bold black".

[0087] Through the unified "preset paragraph layout style", the consistency of the format of the large title type paragraph in different documents is ensured, and the large title is visually distinguished from the main text, highlighting its "hierarchical identification" function. As can be seen, through the logic of "cleaning up redundant format and applying preset style", the embodiment solves the inconsistency problem of large title type elements caused by user's random format operation, so that the AI typesetting can give the large title a standard and eye-catching visual presentation.

[0088] The second case: In an embodiment, in a case where the element type of the paragraph is the second element type, according to the element type and / or the original indentation representation, a target paragraph layout strategy corresponding to each paragraph is determined, including: determining the preset second indentation strategy as the target paragraph layout strategy corresponding to the paragraph. Further, based on the second indentation strategy, the paragraph is processed for paragraph layout, including: cleaning up the original indentation related information of the paragraph, setting the preset paragraph layout style corresponding to the element type of the paragraph for the cleaned paragraph; determining whether to set the first line indentation for the paragraph according to whether there is main text between the paragraph and the upper level title of the paragraph and the alignment mode of the preset paragraph layout style.

[0089] Specifically, the decision to set a first-line indent for a paragraph is based on whether there is body text between the paragraphs and their parent headings, as well as the alignment of the preset paragraph layout style. Specifically: if there is body text between the paragraphs and their parent headings, and the preset paragraph layout style uses the default alignment, then a specified first-line indent is set for the paragraph; if there is no body text between the paragraphs and their parent headings, or if there is no body text between the paragraphs and their parent headings, and the preset paragraph layout style uses a different alignment than the default alignment, then no first-line indent is set for the paragraph. The default alignment refers to left alignment.

[0090] In this embodiment, the second type of element includes body headings, which are hierarchical elements between main headings and pure body text, such as subheadings under chapters and list item headings. For these elements, the core of the automatic formatting logic is to achieve the formatting connection and hierarchical distinction between these elements and the context through "basic formatting specifications and intelligent first-line indentation determination." Therefore, the core of the second indentation strategy is to ensure both formatting consistency and to take into account the formatting logic of the paragraphs above and below (especially the body text and the superior headings).

[0091] Specifically, based on the second indentation strategy, paragraph layout processing for body heading paragraphs involves three sub-steps: Step 1, thoroughly clean up the original indentation information of body heading paragraphs; Step 2, apply a preset paragraph layout style matching the element type to the body heading paragraphs, for example, the preset body heading style is "left-aligned, 12pt bold, 0.5-line margin before paragraph". This step ensures the standardization of basic formatting, making the visual style consistent for similar elements (such as all body headings); Step 3, determine whether to set a first-line indent for the body heading paragraph based on whether there is body text between the body heading paragraph and its parent heading, and the alignment of the preset paragraph layout style.

[0092] In step 3, whether to set a first-line indent for body heading paragraphs depends on two conditions: first, whether there is body text between the paragraph and the previous heading; and second, whether the default paragraph layout style alignment is left-aligned. There are two cases here: Scenario 1: There is body text between the main heading and its parent heading, and the default paragraph layout style is left-aligned. In this case, set a specified first-line indent for the main heading to create the effect of a first-line indent. The reason for this is that this type of main heading is "continuation content after the existing body text under the parent heading," and using a first-line indent to indicate the "paragraph start" conforms to the reading habits of body text type layout.

[0093] Case 2: There is no text between the main title and the upper title, or there is no text and the default paragraph layout style is not left-justified (such as center-justified or right-justified). In this case, the first line indentation is not set for the main title. The reason for this processing is that: this kind of main title is the "direct follow-up" of the upper title (such as the list title immediately below the title, the brief description), and indentation will destroy the "close association with the upper title"; in the case of non-left-justified (such as center), indentation will interfere with the visual regularity of the center (such as the indentation of the center sub-title will cause the whole to be skewed), so there is no need to set the first line indentation.

[0094] Third case: In an embodiment, in the case where the element type of the paragraph is the third type of element type, the target paragraph layout strategy corresponding to each paragraph is determined according to the element type and / or the original indentation representation, including: determining the target paragraph layout strategy corresponding to each paragraph according to the element type and the original indentation representation.

[0095] In this embodiment, the third type of element type includes the main text. Among them, the main text content is the core part of the document, and users often form differentiated indentation settings according to reading habits, content logic (such as paragraph level, emphasis), for example, some users are used to indenting the first line by 2 characters, some may form 1.5 characters or 3 characters indentation due to manual adjustment, and some may simulate non-standard indentation (such as 4 half-space spaces corresponding to 2 characters) through paragraph space and tab characters. These original indentations carry the user's layout intention, and if only the "element type" is used to force a single indentation rule (such as changing all to 2 characters), it will destroy the user's reading habits and content logic association. Therefore, for the third type of element type, when determining the target paragraph layout strategy, two types of information are considered: one is the element type, which clearly defines the basic layout framework (such as the main text needs to be left-justified, with consistent spacing between paragraphs, and clear levels), and the other is the original indentation representation, which flexibly adjusts the details. For example, if the original first line indentation representation is 1.5 characters, the target indentation is set to 2 characters; if it is 3.5 characters, it is set to 4 characters; if it is 5 characters (which may be simulated by 10 half-space spaces), it is determined whether to keep 5 characters or adjust to 4 characters according to the content logic (to avoid excessive deviation from the standard). This processing method not only guarantees the basic format uniformity of the main text (such as alignment and paragraph spacing) through the element type, but also retains the user's reasonable layout habits through the original indentation representation, solving the problem of "single element type rule cannot adapt to complex main text scenarios", and achieving the layout effect of "retaining flexibility in specifications and respecting individuality in uniformity".

[0096] Specifically, for the layout processing of the main text paragraph, it can be discussed according to the relationship between the first line indentation and the indentation of the remaining lines: Case 1, In one embodiment, see Figure 5 The flowchart shown includes the following steps: Step 501: When the first-line indentation of the original indentation indicator paragraph is the same as the indentation of the remaining lines, the preset fourth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. Further, based on the fourth indentation strategy, if both the first-line indentation and the indentation of the remaining lines are the first value, step 502 is executed; if both the first-line indentation and the indentation of the remaining lines are greater than the first value, step 503 is executed.

[0097] Step 502: Set a specified first-line indent for the paragraph.

[0098] Step 503: Adjust the first-line indent of the paragraph using the first nearest-neighbor adsorption strategy; adjust the indent of the remaining lines of the paragraph to match the current first-line indent.

[0099] The general premise for applying Case 1 is that "the indentation of the first line of the paragraph is consistent with the indentation of the remaining lines" (i.e., there is no difference in the indentation of the entire paragraph, and there is no difference in the indentation level between the first line and the remaining lines). Under this premise, it is further subdivided into the following two processing scenarios: Scenario (1): If the first line indentation and the indentation of the remaining lines are all equal to the first value (e.g., 0 characters, corresponding to the initial state of no indentation in the whole paragraph), then directly set the first line indentation of the paragraph (e.g., 2 characters) to conform to the conventional typesetting specification of "first line indentation" of the main text. Through standardized settings, the paragraph has a clear starting mark, avoiding the blurring of reading boundaries caused by no indentation in the whole paragraph.

[0100] For ease of understanding, see [link to relevant documentation]. Figure 6 Example, Figure 6 In the first paragraph arranged from top to bottom, the original first-line indentation is equal to the indentation of the remaining lines and is 0 (corresponding to the unprocessed state shown on the left side of the diagram). At this time, set a specified first-line indentation X for the paragraph (such as 2 characters or other values ​​that conform to the regular text layout specifications, corresponding to the final state after adjustment on the right side of the diagram).

[0101] Scenario (2): If the indentation of the first line and the indentation of the remaining lines are both greater than the first value (for example, both are 3 characters, which is a non-standard uniform indentation state), then the first nearest snapping strategy is used to adjust the indentation of the first line, and then the indentation of the remaining lines of the paragraph is adjusted to be consistent with the adjusted indentation of the first line.

[0102] One optional implementation is to use a first proximity snapping strategy to adjust the first-line indentation of a paragraph. This includes: comparing the paragraph's first-line indentation with a set of preset target snapping values; and adjusting the paragraph's first-line indentation to the target snapping value that is closest to the first-line indentation, according to a preset nearest neighbor rule. The core of this first proximity snapping strategy is "not forcing a one-size-fits-all approach." It corrects non-standard indentations manually set by the user (such as 1.5 characters, 3 characters, etc.) through standardized target values, while preserving the user's original indentation level intention (such as whether it leans towards a 2-character or 4-character range) to the greatest extent possible through "nearest neighbor selection," avoiding excessive deviation from the user's reading habits due to forced uniformity.

[0103] Specifically, a set of "first-line target snap values" is pre-defined. These values ​​are standardized indentation amounts that conform to typesetting standards (e.g., 2 characters, 4 characters, 6 characters, etc., usually based on a 2-character interval, adapting to the text formatting needs of most documents). The original first-line indentation of the paragraph (the actual indentation value converted to character units) is compared with this set of "first-line target snap values". According to the preset nearest neighbor rule, the value that is closest to the original first-line indentation value is selected from the preset first-line target snap values ​​as the adjusted first-line indentation.

[0104] Therefore, the principle of the processing logic in scenario (2) is that it corrects the irregularity of non-standard indentation by "adapting to the nearest standard" while fully preserving the user's original layout intention of "uniform indentation throughout the paragraph". Compared with directly forcing the application of a single standard, "adapting to the nearest standard" can minimize the interference with user habits and achieve a balance between "standard format" and "respect for habits".

[0105] For better understanding, please continue to refer to [link / reference]. Figure 6 Example, Figure 6 In the example, the second paragraph from top to bottom originally had the same first-line indentation as the indentations of the remaining lines, all being 1 character (corresponding to the unprocessed state shown on the left side of the diagram). To address this, the first proximity snapping strategy was used to adjust the first-line indentation of the paragraph to 2 characters. Then, the indentations of the remaining lines of the paragraph were adjusted to match the current first-line indentation, which is also 2 characters (corresponding to the final state after adjustment on the right side of the diagram). This achieves a layout effect of "uniform and compliant indentation throughout the paragraph".

[0106] Figure 6In the case of the last paragraph in the order from top to bottom, the original first line indentation is equal to the indentation of the remaining lines and is 3 characters (corresponding to the unprocessed state presented on the left side of the diagram), and for this, the first nearest adsorption strategy is used to adjust the first line indentation of the paragraph to 4 characters, and then the remaining line indentation of the paragraph is adjusted to be consistent with the current first line indentation, that is, also 4 characters (corresponding to the adjusted final state on the right side of the diagram), so as to realize the typesetting effect of "uniform indentation of the whole paragraph and in line with the specification".

[0107] Figure 5 The technical solution provided by the embodiments shown is aimed at the scenario of "the first line indentation of a paragraph being consistent with the indentation of the remaining lines". Through the fourth indentation strategy and the first nearest adsorption strategy, two common indentation problems are accurately corrected: for a paragraph with no indentation (such as 0 characters) throughout the paragraph, a specified first line indentation (such as 2 characters) is set to give a clear paragraph starting mark, solving the problem of ambiguous boundaries when reading; for a paragraph with non-standard uniform indentation (such as 1 character and 3 characters), the "nearest adsorption" mechanism is used to standardize it into a standardized style (such as 1 character adsorbed to 2 characters and 3 characters adsorbed to 4 characters) in line with the conventional text typesetting, avoiding visual confusion caused by chaotic indentation values and ensuring the neatness of the document format. At the same time, the "one-size-fits-all" forced uniform mode is abandoned, and the "nearest adsorption" mechanism, while standardizing the indentation, maximizes the preservation of the original typesetting intention of the user's "uniform indentation throughout the paragraph", neither denying the user's operation habits nor reducing the interference of format adjustment on the reading experience through reasonable value matching, achieving a balance between "standardization" and "individuality". This solution can flexibly cover different users' original indentation settings, rather than being limited to a single case, significantly improving the adaptation ability of the technical solution to actual typesetting scenarios, ultimately laying a foundation for the consistency and smoothness of the overall document typesetting and improving the AI document typesetting applicability and user experience.

[0108] Case 2, In an embodiment, referring to the flowchart shown in the figure, the following steps are included: Figure 7 The flowchart shown in the figure includes the following steps: Step 701, in the case where the original indentation representation indicates that the first line indentation of a paragraph is greater than the indentation of the remaining lines, a fifth preset indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph.

[0109] Step 702, based on the fifth indentation strategy, the second nearest adsorption strategy is used to adjust the indentation of the remaining lines of the paragraph; in the case where the adjusted indentation of the remaining lines is a first value, step 703 is performed; in the case where the adjusted indentation of the remaining lines is greater than the first value, step 704 is performed.

[0110] Step 703, a specified first line indentation is set for the paragraph.

[0111] Step 704, adjust the first line indentation of the paragraph to be consistent with the current indentation of the remaining lines.

[0112] The general premise for the application of Case 2 is that the first line indentation of the paragraph is greater than the indentation of the remaining lines (i.e., the first line indentation exceeds the remaining lines, forming a hierarchical difference of "first line highlighting", which is common in the user's habit of emphasizing the beginning of the paragraph), under this premise, first adjust the indentation of the remaining lines of the paragraph by the second nearest adsorption strategy, and then adjust the first line indentation according to the adjusted indentation of the remaining lines. The reason for such processing is as follows: first, in the text formatting logic, the indentation state of the remaining lines (such as whether to top the grid or to conform to the standardized spacing) directly determines the basic visual framework of the paragraph. By adjusting the indentation of the remaining lines to a standard value (such as a preset target value of 0 characters, 2 characters, etc.) through the second nearest adsorption strategy, it can avoid format confusion caused by "inconsistent reference" during subsequent first line indentation adjustment, and provide a clear reference for subsequent first line processing. Second, this sequence can accurately preserve the user's core formatting intention. In Case 2, the user's core demand is to "highlight the first line to emphasize the beginning of the paragraph", rather than deliberately set a non-standard indentation of the remaining lines. First adjusting the remaining lines corrects "unnecessary format deviation" (such as mistakenly setting 1.5 characters, 2.5 characters, etc.), rather than negating the user's intention. Subsequent adjustment of the first line based on the standard remaining line can meet the demand of "highlighting the first line" (such as setting the first line to 2 characters when the remaining line is 0 characters), while avoiding the hierarchical imbalance caused by non-standard remaining lines. Third, it can achieve a balance between "standardization and flexibility". If the first line is adjusted first, the remaining line is still in a non-standard state, which may result in a contradiction of "standard first line but chaotic remaining line" (such as first line 2 characters, remaining line 1.5 characters). First setting the remaining line reference, and then adapting the first line, can ensure that the indentation relationship between the first line and the remaining line conforms to the formatting specification (such as first line 2 characters + remaining line 0 characters, first line 2 characters + remaining line 2 characters), and does not deviate from the user's original habit of "relatively highlighting the first line". Finally, it achieves the effect of "clear hierarchy and neat format" in the layout.

[0113] Specifically, it is divided into the following two processing scenarios: Scenario (1): After adjusting the indentation of the remaining lines by the second nearest adsorption strategy, if the adjustment result is the first value (for example, 0 characters, which conforms to the normal specification of "remaining line top grid" in the text), set the specified first line indentation for the paragraph (such as 2 characters).

[0114] First of all, as an optional implementation, adjusting the indentation of the remaining lines of the paragraph by the second nearest adsorption strategy includes: comparing the indentation of the remaining lines of the paragraph with a set of preset remaining line target adsorption values; according to the preset nearest neighbor rule, adjust the indentation of the remaining lines of the paragraph to the remaining line target adsorption value that is the nearest neighbor of the indentation of the remaining lines.

[0115] Consistent with the aforementioned "first nearest adsorption strategy", a set of "remaining line target adsorption values" are pre-configured, which are standard indentation amounts conforming to the typesetting specifications (e.g. 0 characters, 2 characters, 4 characters, 6 characters, etc., usually with a 2-character interval to adapt to the text typesetting needs of most documents); the original remaining line indentation amount of the paragraph (converted into the actual indentation value in character units) is compared with the set of "remaining line target adsorption values". According to the pre-set nearest neighbor rule, the value closest to the original remaining line indentation amount is selected from the pre-set remaining line target adsorption values as the adjusted remaining line indentation amount.

[0116] It should be noted here that in the first nearest adsorption strategy, the starting value of the first line target adsorption value is 2 characters, while in the second nearest adsorption strategy, the starting value of the remaining line target adsorption value is 0 characters. The difference in the starting value of the target adsorption value in these two strategies is based on the general specifications of Chinese document typesetting, the functional positioning of different lines of a paragraph, and the core goal of the two types of indentation strategies: the first nearest adsorption strategy is for "first line indentation", and the core function of the first line is to identify the start of the paragraph. In the general specifications of Chinese typesetting, the first line of a text paragraph is indented by 2 characters, which is the default standard in the industry (such as most document types such as official documents, papers, reports, etc. follow this convention), which can clearly distinguish the boundaries of different paragraphs and avoid visual confusion when reading. Setting the starting value of the first line target adsorption value to 2 characters can directly match the most common basic typesetting needs, and subsequent settings of 4 characters, 6 characters, etc. with a 2-character interval (to adapt to deep text under multi-level headings, quoted paragraphs, etc.) can also ensure the hierarchical and normative nature of first line indentation, and always focus on the core function of "highlighting the start of the paragraph". The second nearest adsorption strategy is for "remaining line indentation", and the core function of the remaining line is to carry the main content of the paragraph, which needs to ensure the visual coherence and neatness of the text. In Chinese typesetting, the remaining lines of a text paragraph are usually in the form of "top margin (0 character indentation)", which allows the main content of the paragraph to be closely connected and avoids the dispersion of text caused by additional indentation. Setting the starting value of the remaining line target adsorption value to 0 characters can directly cover the needs of "remaining line top margin" in most regular scenarios; even if there are special scenarios (such as hanging indentation, subsequent text after list items), subsequent settings of 2 characters, 4 characters, etc. with a 2-character interval can also adapt to special typesetting needs, while forming a reasonable separation with the 2-character starting value of the first line (such as the combination of first line 2 characters + remaining line 0 characters, which is the most standard indentation style for Chinese text), ensuring that the functional positioning of the first line and the remaining line does not overlap, and the typesetting logic is clearer.

[0117] For ease of understanding, see the example of Figure 8 , Figure 8In the first paragraph in the order from top to bottom, the original first-line indentation is 1 and the rest of the lines is 0 (corresponding to the left side of the diagram in the unprocessed state), for which, first, the second nearest adsorption strategy is used to adjust the rest of the lines of the paragraph to 0 (here it can also be said to remain unchanged); then, the specified first-line indentation of the paragraph is set to 2 characters (corresponding to the right side of the diagram in the adjusted final state), so as to achieve the "first-line indentation of 2 characters and the rest of the lines in the top position (0 characters) of the standard first-line indentation" layout effect.

[0118] Figure 8 In the second paragraph in the order from top to bottom, the original first-line indentation is 1.5 (here it is only assumed) and the rest of the lines is 1 (corresponding to the left side of the diagram in the unprocessed state), for which, first, the second nearest adsorption strategy is used to adjust the rest of the lines of the paragraph to 0; then, the specified first-line indentation of the paragraph is set to 2 characters (corresponding to the right side of the diagram in the adjusted final state), so as to achieve the "non-standard indentation" correction to the "first-line indentation of 2 characters and the rest of the lines in the top position (0 characters) of the standard first-line indentation" layout effect.

[0119] Continuing to refer to the examples of Figure 9 , Figure 9 In the first paragraph in the order from top to bottom, the original first-line indentation is 1.5 and the rest of the lines is 0 (corresponding to the left side of the diagram in the unprocessed state), for which, first, the second nearest adsorption strategy is used to adjust the rest of the lines of the paragraph to 0; then, the specified first-line indentation of the paragraph is set to 2 characters (corresponding to the right side of the diagram in the adjusted final state), so as to achieve the "non-standard indentation" correction to the "first-line indentation of 2 characters and the rest of the lines in the top position (0 characters) of the standard first-line indentation" layout effect.

[0120] Figure 9 In the first paragraph in the order from top to bottom, the original first-line indentation is 2 and the rest of the lines is 1 (corresponding to the left side of the diagram in the unprocessed state), for which, first, the second nearest adsorption strategy is used to adjust the rest of the lines of the paragraph to 0; then, the specified first-line indentation of the paragraph is set to 2 characters (corresponding to the right side of the diagram in the adjusted final state), so as to achieve the "non-standard indentation" correction to the "first-line indentation of 2 characters and the rest of the lines in the top position (0 characters) of the standard first-line indentation" layout effect.

[0121] Scenario (2): After adjusting the rest of the lines indentation using the second nearest adsorption strategy, if the adjustment result is greater than the first value (indicating that the user may want the entire paragraph to maintain a certain indentation but the first line to be more prominent), the first-line indentation is adjusted to be consistent with the current rest of the lines indentation, achieving the effect of "uniform indentation of the entire paragraph and coordinated levels".

[0122] The processing logic in scenario (2) is that: both the non-standard indentation of the remaining lines is corrected by the "second nearest adsorption" and the first line indentation is flexibly processed according to the adjustment result. When the remaining lines conform to the "top specification", the paragraph starting mark is strengthened by specifying the first line indentation; when the remaining lines have reasonable indentation, the format imbalance is avoided by unifying the first line and the remaining line indentation. Compared with the forced application of a single rule, this strategy more accurately adapts to the user's "first line highlighting" layout habit, minimizes the interference with the reading experience while standardizing the format, and achieves the balance between "clear hierarchy" and "habit compatibility".

[0123] For ease of understanding, continue to refer to Figure 8 the example, Figure 8 the third paragraph in the order from top to bottom, the original first line indentation is 3, and the remaining line indentation is 2.5 (here only assumed) (corresponding to the left side of the diagram presenting the unprocessed state), for this, first adopt the second nearest adsorption strategy, adjust the remaining line indentation of the paragraph to 2, which is greater than the first value; then, adjust the first line indentation to be consistent with the current remaining line indentation, that is, the first line indentation is also adjusted to 2 characters (corresponding to the right side of the diagram after adjustment The final state), so as to realize the "uniform indentation of all lines and coordinated hierarchy" layout effect.

[0124] Figure 8 In the example, the last paragraph in the order from top to bottom, the original first line indentation is 5, and the remaining line indentation is 4.5 (here only assumed) (corresponding to the left side of the diagram presenting the unprocessed state), for this, first adopt the second nearest adsorption strategy, adjust the remaining line indentation of the paragraph to 4, which is greater than the first value; then, adjust the first line indentation to be consistent with the current remaining line indentation, that is, the first line indentation is adjusted to 4 characters (corresponding to the right side of the diagram after adjustment The final state), so as to realize the "uniform indentation of all lines and coordinated hierarchy" layout effect.

[0125] Continue to refer to Figure 9 the example, Figure 9 the third paragraph in the order from top to bottom, the original first line indentation is 3, and the remaining line indentation is 2 (corresponding to the left side of the diagram presenting the unprocessed state), for this, first adopt the second nearest adsorption strategy, adjust the remaining line indentation of the paragraph to 2 (here it can also be said to remain unchanged), which is greater than the first value; then, adjust the first line indentation to be consistent with the current remaining line indentation, that is, the first line indentation is also adjusted to 2 characters (corresponding to the right side of the diagram after adjustment The final state), so as to realize the "uniform indentation of all lines and coordinated hierarchy" layout effect.

[0126] Figure 9The last paragraph in the text, arranged from top to bottom, originally has a first-line indent of 5 and the remaining line indents of 4 (corresponding to the unprocessed state shown on the left side of the diagram). To address this, the second proximity snapping strategy is first used to adjust the indents of the remaining lines of the paragraph to 4 (which can also be said to remain unchanged), which is greater than the first value. Then, the first-line indent is adjusted to be consistent with the current indents of the remaining lines, that is, the first-line indent is also adjusted to 4 characters (corresponding to the final state after adjustment on the right side of the diagram), thereby achieving a layout effect of "uniform indentation throughout the paragraph and coordinated hierarchy".

[0127] Figure 7 The illustrated process addresses the scenario where the first line indentation of a paragraph is greater than the indentation of the remaining lines. Through the fifth indentation strategy—"first correcting the indentation of the remaining lines by using the second indentation strategy, then adjusting the first line indentation as needed"—it avoids the chaos caused by non-standard indentation of the remaining lines (such as 1 character or 2.5 characters) leading to a lack of benchmark for subsequent first line adjustments. This establishes a clear reference for the indentation relationship between the first and remaining lines, fundamentally resolving the formatting contradiction of "standard first line but messy remaining lines." Simultaneously, it anchors and preserves the user's core layout intentions, satisfying the habit of "relatively prominent first line" while avoiding the imbalance caused by excessive prominence of the first line (such as 3 characters for the first line and 1 character for the remaining lines). Ultimately, it achieves a clear and standardized layout effect, significantly improving the applicability and format regularity of AI document layout.

[0128] Situation 3 In one embodiment, see Figure 10 The flowchart shown includes the following steps: Step 1001: If the indentation of the first line of the original indentation representation paragraph is less than the indentation of the remaining lines, determine the difference between the indentation of the remaining lines and the indentation of the first line. If the difference is less than a second value, proceed to step 1002; if the difference is greater than or equal to the second value, proceed to step 1004.

[0129] Step 1002: Determine the preset sixth indentation strategy as the target paragraph layout strategy corresponding to the paragraph.

[0130] Step 1003: Based on the sixth indentation strategy, adjust the first-line indentation of the paragraph using the first proximity snapping strategy; adjust the indentation of the remaining lines of the paragraph to be consistent with the current first-line indentation.

[0131] Step 1004: Determine the preset seventh indentation strategy as the target paragraph layout strategy corresponding to the paragraph.

[0132] Step 1005: Based on the seventh indentation strategy, adjust the first-line indentation of the paragraph using the first proximity snapping strategy; set a specified indentation for the remaining lines of the paragraph, where the specified indentation is the sum of the current first-line indentation and the preset indentation.

[0133] The general premise for case 3 is that the first line of the paragraph has a smaller indentation than the rest of the lines (i.e., the rest of the lines have a larger indentation than the first line, creating a hierarchical difference that may be due to intentional user settings or accidental indentation deviations). For this scenario, the core processing logic is to first determine the difference between the indentation of the rest of the lines and the first line, and then, based on the relationship between the difference and a second value (such as 1 character, serving as a threshold to distinguish between unintentional deviations and intentional formatting), select the corresponding indentation strategy.

[0134] The essence of the design of this embodiment is to distinguish between unintentional deviations and intentional formatting: when the difference is small, the indentation difference is more likely to be an operational error (rather than a user's deliberate design), and by using the sixth indentation strategy to uniformly indent, the format regularity is avoided due to minor deviations; when the difference is large, the indentation difference is more likely to carry the user's special formatting needs (such as emphasizing subsequent content), and by using the seventh indentation strategy to preserve the hierarchical difference and standardize the interval, both the user's intention and the avoidance of visual confusion caused by non-standard values are achieved. This processing method neither blindly unifies and destroys useful formatting design, nor tolerates non-standard values to affect the overall format, ultimately achieving a precise balance between standardization and individuality. Specifically, there are two processing scenarios: Scenario (1): the difference between the indentation of the rest of the lines and the first line is less than the second value (e.g., the difference is 1 character, which is less than 2 characters), at this time it is determined to be "unnecessary indentation deviation" (which may be caused by user manual adjustment errors), and the sixth indentation strategy is used. Specifically, first, adjust the first line indentation using the first nearest absorption strategy (e.g., the original first line indentation of 1 character is adjusted to the first line indentation of 2 characters, the original first line indentation of 3 characters is adjusted to the first line indentation of 4 characters, ensuring that the first line conforms to the standardized interval); then, adjust the indentation of the rest of the lines to be consistent with the current first line indentation (e.g., after adjusting the first line to 2 characters, the rest of the lines are also set to 2 characters). This processing can eliminate meaningless indentation differences and achieve the formatting effect of "uniform indentation of all lines".

[0135] For ease of understanding, see the example in Figure 11 , Figure 11 , the first paragraph in the order from top to bottom, the original first line indentation is 0, and the rest of the lines indentation is 0.5 (here it is only assumed) (corresponding to the unprocessed state presented on the left side of the diagram), the difference between the two is 0.5, which is less than the second value, for which the first nearest absorption strategy is used to adjust the first line indentation of the paragraph to 2; then, adjust the first line indentation to be consistent with the current rest of the line indentation, i.e., adjust the first line indentation to 2 characters (corresponding to the adjusted final state on the right side of the diagram), to achieve the formatting effect of "uniform indentation of all lines".

[0136] Figure 11In the third paragraph from top to bottom, the original first-line indentation is 3.5 (this is just an assumption), and the rest of the line indentation is 4 (corresponding to the left side of the diagram presented in the untreated state), the difference between the two is 0.5, which is less than the second value, for this, first adopt the first nearest adsorption strategy, adjust the first-line indentation of the paragraph to 4; Then, adjust the rest of the line indentation of the paragraph to be consistent with the current first-line indentation, that is, the rest of the line indentation is also adjusted to 4 characters (corresponding to the right side of the diagram after adjustment Final state), so as to realize the typesetting effect of "full paragraph indentation uniformity".

[0137] Figure 11 In the third paragraph from top to bottom, the original first-line indentation is 3.5 (this is just an assumption), and the rest of the line indentation is 4 (corresponding to the left side of the diagram presented in the untreated state), the difference between the two is 0.5, which is less than the second value, for this, first adopt the first nearest adsorption strategy, adjust the first-line indentation of the paragraph to 4; Then, adjust the rest of the line indentation of the paragraph to be consistent with the current first-line indentation, that is, the rest of the line indentation is also adjusted to 4 characters (corresponding to the right side of the diagram after adjustment Final state), so as to realize the typesetting effect of "full paragraph indentation uniformity".

[0138] Scenario (2): The difference between the rest of the line indentation and the first-line indentation is greater than or equal to the second value (such as a difference of 3 characters, greater than or equal to 2 characters), at this time, it is determined that the user has intentionally set a special typesetting (such as hanging indentation, commonly used in list items, quotations and other scenarios that need to highlight subsequent content), adopt the seventh indentation strategy. Specifically, first of all, adjust the first-line indentation with the first nearest adsorption strategy; Then, set the rest of the line indentation to the sum of the current first-line indentation and the preset indentation (standardized interval that maintains a fixed hierarchical difference). Among them, the preset indentation can be a preset fixed number of characters, such as 2 characters, which is suitable for most hanging indentation scenarios, or it can be set according to the character length occupied by the numbered area in the first line / section title, so as to realize the typesetting effect of "hanging indentation and numbered / section title highlighting", and improve the user's reading experience.

[0139] For easy understanding, see Figure 12 example, Figure 12 In the first paragraph from top to bottom, the original first-line indentation is 0, and the rest of the line indentation is 1 (corresponding to the left side of the diagram presented in the untreated state), the difference between the two is 1, which is equal to the second value, for this, first adopt the first nearest adsorption strategy, adjust the first-line indentation of the paragraph to 2; Then, set the rest of the line indentation to the sum of the current first-line indentation and the preset indentation (such as a character), realize the typesetting effect of "hanging indentation and numbered / section title highlighting".

[0140] Figure 12In the second paragraph from top to bottom, the original first-line indentation is 1.5 (only assumed here), and the rest of the lines is 2.5 (only assumed here) (corresponding to the untreated state presented on the left side of the diagram), the difference between the two is 1, which is equal to the second value, so first adopt the first nearest adsorption strategy to adjust the first-line indentation of the paragraph to 2; Then set the specified rest of the line indentation for the paragraph, which is the current first-line indentation of the paragraph (2 characters) plus the preset indentation (1.5 characters), that is, 3.5 characters, so as to achieve the typesetting effect of "hanging indentation and numbered / section title highlighting". Figure 12 In the third paragraph from top to bottom, the original first-line indentation is 3.5 (only assumed here), and the rest of the lines is 5 (corresponding to the untreated state presented on the left side of the diagram), the difference between the two is 1.5, which is greater than the second value, so first adopt the first nearest adsorption strategy to adjust the first-line indentation of the paragraph to 4; Then set the specified rest of the line indentation for the paragraph, which is the current first-line indentation of the paragraph (4 characters) plus the preset indentation (1.5 characters), that is, 5.5 characters, so as to achieve the typesetting effect of "hanging indentation and numbered / section title highlighting".

[0141] Figure 12 The flow is for the scene of "the first-line indentation of the paragraph is less than the rest of the line indentation", and the core is to accurately distinguish between "unintentional indentation deviation" and "intentional special typesetting" by comparing the difference between the first-line indentation and the rest of the line indentation with the second value: when the difference is small, the sixth strategy is used to standardize the first line and synchronize the rest of the line after the first nearest adsorption, eliminating the small differences caused by operation errors and ensuring the uniformity of the whole paragraph format; When the difference is large, the seventh strategy is used to standardize the first line, and the rest of the line is set according to "first line + preset indentation (fixed characters or length of numbering / title)", which not only retains the special intention of hanging indentation, but also avoids the confusion of non-standard level difference, and overall balances standardization and individuality, without destroying useful typesetting and tolerating non-standard format, effectively improving the document neatness and adaptability, and meeting the user experience of AI document typesetting. Figure 12 Finally, the present application also provides the following embodiments:

[0142] In an embodiment, after performing paragraph layout processing on each paragraph based on the target paragraph layout strategy, the method further includes: performing indentation alignment processing on the text paragraphs belonging to the same numbering interval. Figure 10

[0143] Finally, the present application also provides the following embodiments: In an embodiment, after performing paragraph layout processing on each paragraph based on the target paragraph layout strategy, the method further includes: performing indentation alignment processing on the text paragraphs belonging to the same numbering interval.

[0144] This embodiment is a "secondary optimization" after the single paragraph completes the target layout strategy processing, the core is to solve the problem of indentation difference after the single paragraph is processed, and it is suitable for the typesetting requirements of hierarchical content with numbering in the document (such as chapter text, list paragraph). Among them, "the same numbering interval" refers to the text paragraphs belonging to the same numbering level or the same numbering sequence.

[0145] Specifically, after each paragraph is individually processed by the target strategy to adjust the indentation, the indentation reference of the paragraphs in the same numbering interval (such as the first line indentation of most paragraphs in the interval or the standard indentation value conforming to the level specification) is further extracted, and the indentation of all paragraphs in the interval is uniformly adjusted to the reference value.

[0146] For example, the first line indentation of the three text paragraphs under "1.1 Technical Parameters" is 2 characters, 2.5 characters, and 1.8 characters respectively after individual processing, and is uniformly adjusted to 2 characters after the alignment processing, which not only avoids the format confusion caused by individual processing of the same level, but also strengthens the correspondence between the numbering level and the indentation of the document, making the overall typesetting more regular.

[0147] In another embodiment, after each paragraph is processed based on the target paragraph layout strategy, the method further comprises: adjusting the hanging indentation setting of the paragraph according to the difference between the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing. Among them, according to the difference between the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing, the hanging indentation setting of the paragraph is adjusted, which includes: in the case of meeting one of the following conditions, the current paragraph layout attribute of the paragraph is maintained: the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are the same, the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are different, and the first line of the paragraph does not have a section title; in the case that the first line indentation and the remaining line indentation of the paragraph after the paragraph layout processing are different, and the first line of the paragraph has a section title, the paragraph is set with a hanging indentation according to the length of the section title.

[0148] This embodiment is also a "secondary optimization" after the single paragraph completes the target layout strategy processing, and the core is to solve the problem of whether to supplement the hanging indentation after the paragraph layout processing, so as to distinguish whether the paragraph contains a section title and flexibly adapt to different typesetting scene requirements.

[0149] The processing logic combines the two conditions of "difference in indentation of the first line and the remaining lines of the paragraph" and "whether the first line contains a section title". On the one hand, if the first line and the remaining lines of the paragraph have the same indentation after processing (e.g., both are 2 characters), or the indentation is different but the first line does not contain a section title (e.g., the first line is 2 characters and the remaining lines are 0 characters, which is the normal text), the current paragraph layout attribute is maintained. This is because the former does not need additional indentation, and the indentation difference of the latter already meets the normal layout logic, and forcibly setting the hanging indentation will destroy the reading habit. On the other hand, if the first line and the remaining lines of the paragraph have different indentation after processing, and the first line contains a section title (e.g., the first line contains a short title such as "Note:" or "Tip:", or a label such as "1. Risk point:"), the length of the section title is used to set the hanging indentation. For example, if the length of the section title "Note:" is 2 characters, the hanging indentation is set to 2 characters, so that the title is displayed at the top of the page and the subsequent text is arranged from the 2nd character, avoiding overlapping of the title and the content of the text or confusion of the indentation. The final layout effect can be seen in the related examples of Figure 12 .

[0150] This processing does not interfere with the normal layout of the regular paragraph, and can standardize the visual structure of the paragraph with a section title, making the hierarchical relationship between the title and the text clearer and improving the reading comfort of the document.

[0151] Figure 13 An embodiment block diagram of a document processing device according to an embodiment of the present application is provided. As shown in Figure 13 , the device includes: A first determination module 1301 is configured to determine the element type and the original indentation representation of each paragraph in the to-be-processed document. A second determination module 1302 is configured to determine the target paragraph layout strategy corresponding to each paragraph according to the element type and / or the original indentation representation. A paragraph layout module 1303 is configured to perform paragraph layout processing on each paragraph based on the target paragraph layout strategy, to obtain a processed document.

[0152] In a possible implementation, the first determination module 1301 determines the original indentation representation of each paragraph in the to-be-processed document, including: Identifying the original indentation related information of each paragraph in the to-be-processed document, the original indentation related information including at least one of paragraph indentation attribute, invisible character at the beginning of the paragraph, and numbering indentation attribute; Converting the identified original indentation related information into the original indentation representation according to a preset standard unit.

[0153] In a possible implementation, in the case where the element type of the paragraph is a first element type, the second determination module 1302 is specifically configured to: The preset first indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph layout module 1303 includes: The cleaning unit is used to clean up the original indentation-related information of the paragraph, which includes at least one of paragraph indentation attributes, invisible characters at the beginning of the paragraph, and number indentation attributes. The setting unit is used to set a preset paragraph layout style corresponding to the element type of the cleaned paragraph.

[0154] In one possible implementation, when the element type of the paragraph is a second type of element type, the second determining module 1302 is specifically used for: The preset second indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph; The paragraph layout module 1303 includes: The cleaning unit is used to clean up the original indentation-related information of the paragraph, which includes at least one of paragraph indentation attributes, invisible characters at the beginning of the paragraph, and number indentation attributes. The setting unit is used to set a preset paragraph layout style corresponding to the element type of the cleaned paragraph; The first-line indentation setting unit is used to determine whether to set a first-line indentation for the paragraph based on whether there is body text between the paragraph and the paragraph's parent heading and the alignment of the preset paragraph layout style.

[0155] In one possible implementation, the first-line indentation setting unit is specifically used for: If there is body text between the paragraph and the parent heading of the paragraph, and the alignment of the preset paragraph layout style is the default alignment, set a specified first-line indent for the paragraph. If there is no body text between the paragraph and its parent heading, or if there is no body text between the paragraph and its parent heading and the alignment of the preset paragraph layout style is not the default alignment, then it is determined that no first-line indentation will be set for the paragraph.

[0156] In one possible implementation, when the element type of the paragraph is a third element type, the second determining module is specifically used for: Based on the element type and the original indentation representation, determine the target paragraph layout strategy corresponding to each paragraph.

[0157] In one possible implementation, the second determining module 1302 is specifically used for: In a case where the original indentation characteristic quantity indicates that the first-line indentation quantity of the paragraph is the same as the rest-line indentation quantity of the paragraph, a preset fourth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph layout module 1303 is specifically configured to: In a case where the first-line indentation quantity and the rest-line indentation quantity are both the first value, a specified first-line indentation quantity is set for the paragraph. In a case where the first-line indentation quantity and the rest-line indentation quantity are both greater than the first value, a first nearest adsorption strategy is adopted to adjust the first-line indentation quantity of the paragraph. The rest-line indentation quantity of the paragraph is adjusted to be consistent with the current first-line indentation quantity.

[0158] In a possible implementation, the second determination module 1302 is specifically configured to: In a case where the original indentation characteristic quantity indicates that the first-line indentation quantity of the paragraph is greater than the rest-line indentation quantity of the paragraph, a preset fifth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph layout module 1303 comprises: A first adjustment unit is configured to adopt a second nearest adsorption strategy to adjust the rest-line indentation quantity of the paragraph. A second adjustment unit is configured to, in a case where the adjusted rest-line indentation quantity is the first value, set a specified first-line indentation quantity for the paragraph, or in a case where the adjusted rest-line indentation quantity is greater than the first value, adjust the first-line indentation quantity of the paragraph to be consistent with the current rest-line indentation quantity.

[0159] In a possible implementation, the second determination module 1302 comprises: A difference calculation unit is configured to, in a case where the original indentation characteristic quantity indicates that the first-line indentation quantity of the paragraph is less than the rest-line indentation quantity of the paragraph, determine a difference value between the rest-line indentation quantity and the first-line indentation quantity. A strategy determination unit is configured to determine, according to the difference value, the target paragraph layout strategy corresponding to the paragraph.

[0160] In a possible implementation, the strategy determination unit is specifically configured to: In a case where the difference value is less than a second value, a preset sixth indentation strategy is determined as the target paragraph layout strategy corresponding to the paragraph. The paragraph layout module 1303 comprises: A third adjustment unit is configured to adopt a first nearest adsorption strategy to adjust the first-line indentation quantity of the paragraph. A fourth adjustment unit is configured to adjust the rest-line indentation quantity of the paragraph to be consistent with the current first-line indentation quantity.

[0161] In a possible implementation, the policy determining unit is specifically configured to: determine a preset seventh indentation policy as the target paragraph layout policy corresponding to the paragraph in a case where the difference is greater than or equal to a second value; The paragraph layout module 1303 comprises: a third adjusting unit configured to adjust the first-line indentation amount of the paragraph by using a first nearest adsorption policy; a fifth adjusting unit configured to set a specified remaining-line indentation amount for the paragraph, the specified remaining-line indentation amount being a sum of the current first-line indentation amount of the paragraph and a preset indentation amount.

[0162] In a possible implementation, the third adjusting unit is specifically configured to: compare the first-line indentation amount of the paragraph with a group of preset target first-line adsorption values; adjust the first-line indentation amount of the paragraph to a target first-line adsorption value that is nearest to the first-line indentation amount according to a preset nearest neighbor rule.

[0163] In a possible implementation, the first adjusting unit is specifically configured to: compare the remaining-line indentation amount of the paragraph with a group of preset target remaining-line adsorption values; adjust the remaining-line indentation amount of the paragraph to a target remaining-line adsorption value that is nearest to the remaining-line indentation amount according to a preset nearest neighbor rule.

[0164] In a possible implementation, the apparatus further comprises: a first reprocessing module configured to perform indentation amount alignment processing on text paragraphs belonging to the same numbering interval after performing paragraph layout processing on each of the paragraphs based on the target paragraph layout policy.

[0165] In a possible implementation, the apparatus further comprises: a second reprocessing module configured to adjust the hanging indentation setting of the paragraph according to the difference between the first-line indentation amount and the remaining-line indentation amount of the paragraph after the paragraph layout processing based on the target paragraph layout policy.

[0166] In a possible implementation, the second reprocessing module is specifically configured to: maintain the current paragraph layout attribute of the paragraph in a case where one of the following conditions is met: the first-line indentation amount of the paragraph after the paragraph layout processing is the same as the remaining-line indentation amount, the first-line indentation amount of the paragraph after the paragraph layout processing is different from the remaining-line indentation amount, and the first line of the paragraph does not have a section title. In a case that the first line of the paragraph after the paragraph layout processing has a different indentation amount from the rest of the lines and the first line of the paragraph has a section title, a hanging indentation is set for the paragraph according to a length of the section title.

[0167] As Figure 14 shown in the figure, an embodiment of the present application provides an electronic device, comprising 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 complete mutual communication through the communication bus 114, the memory 113 is used for storing a computer program; In an embodiment of the present application, the processor 111 is used for executing the program stored in the memory 113, and a document processing method provided by any one of the preceding method embodiments is implemented. determining element types and original indentation representation amounts of paragraphs in a to-be-processed document; determining a target paragraph layout strategy corresponding to each of the paragraphs according to the element types and / or the original indentation representation amounts; performing paragraph layout processing on each of the paragraphs based on the target paragraph layout strategy, to obtain a processed document.

[0168] An embodiment of the present application further provides a computer readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to implement steps of a document processing method provided by any one of the preceding method embodiments.

[0169] The device embodiments described above are only schematic, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place or distributed on a plurality of network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0170] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Based on such understanding, the above technical solutions essentially or in other words the part that contributes to the related art can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.

[0171] It is to be understood that the terminology used herein is for the purpose of describing particular example embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order

[0172] The above description is that of current embodiments of the application. Various modifications and changes can be made thereto without departing from the spirit and scope of the application as set forth. The scope of the application is not to be limited to the exact details shown above.

Claims

1. A document processing method characterized by, The method comprises: determining the element type and original indentation representation of each paragraph in the document to be processed; determining the target paragraph layout strategy corresponding to each paragraph according to the element type and / or the original indentation representation; performing paragraph layout processing on each paragraph based on the target paragraph layout strategy to obtain a processed document.

2. The method of claim 1, wherein, The method comprises: identifying original indentation related information of each paragraph in the document to be processed, wherein the original indentation related information comprises at least one of paragraph indentation attribute, invisible character at the beginning of a paragraph, and numbered indentation attribute; converting the identified original indentation related information into the original indentation representation according to a preset standard unit.

3. The method of claim 1, wherein, In the case where the element type of the paragraph is a first type of element type, the method comprises: determining a preset first indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing paragraph layout processing on the paragraph based on the first indentation strategy, which comprises: cleaning up the original indentation related information of the paragraph, wherein the original indentation related information comprises at least one of paragraph indentation attribute, invisible character at the beginning of a paragraph, and numbered indentation attribute; setting a preset paragraph layout style corresponding to the element type of the paragraph on the cleaned-up paragraph.

4. The method of claim 1, wherein, In the case where the element type of the paragraph is a second type of element type, the method comprises: determining a preset second indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing paragraph layout processing on the paragraph based on the second indentation strategy, which comprises: cleaning up the original indentation related information of the paragraph, wherein the original indentation related information comprises at least one of paragraph indentation attribute, invisible character at the beginning of a paragraph, and numbered indentation attribute; setting a preset paragraph layout style corresponding to the element type of the paragraph on the cleaned-up paragraph. determining whether to set a first-line indentation for the paragraph according to whether there is body text between the paragraph and the upper-level title of the paragraph and the alignment mode of the preset paragraph layout style.

5. The method of claim 4, wherein, The method comprises: in the case where there is body text between the paragraph and the upper-level title of the paragraph and the alignment mode of the preset paragraph layout style is a default alignment mode, setting a specified first-line indentation amount for the paragraph; in the case where there is no body text between the paragraph and the upper-level title of the paragraph, or there is no body text between the paragraph and the upper-level title of the paragraph and the alignment mode of the preset paragraph layout style is not the default alignment mode, determining not to set a first-line indentation for the paragraph.

6. The method of claim 1, wherein, In a case where the element type of the paragraph is a third type of element type, the determining, according to the element type and / or the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: determining, according to the element type and the original indentation representation, a target paragraph layout strategy corresponding to each of the paragraphs.

7. The method of claim 6, wherein, The determining, according to the element type and the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is the same as the rest-line indentation amount, determining a preset fourth indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing, based on the fourth indentation strategy, paragraph layout processing on the paragraph, comprising: in a case where the first-line indentation amount and the rest-line indentation amount are both a first value, setting a specified first-line indentation amount for the paragraph; in a case where the first-line indentation amount and the rest-line indentation amount are both greater than the first value, adjusting the first-line indentation amount of the paragraph by using a first nearest adsorption strategy; adjusting the rest-line indentation amount of the paragraph to be consistent with the current first-line indentation amount.

8. The method of claim 6, wherein, The determining, according to the element type and the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is greater than the rest-line indentation amount, determining a preset fifth indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing, based on the fifth indentation strategy, paragraph layout processing on the paragraph, comprising: adjusting the rest-line indentation amount of the paragraph by using a second nearest adsorption strategy; in a case where the adjusted rest-line indentation amount is a first value, setting a specified first-line indentation amount for the paragraph; or in a case where the adjusted rest-line indentation amount is greater than the first value, adjusting the first-line indentation amount of the paragraph to be consistent with the current rest-line indentation amount.

9. The method of claim 6, wherein, The determining, according to the element type and the original indentation representation, of a target paragraph layout strategy corresponding to each of the paragraphs comprises: in a case where the original indentation representation indicates that the first-line indentation amount of the paragraph is less than the rest-line indentation amount, determining a difference value between the rest-line indentation amount and the first-line indentation amount; determining, according to the difference value, a target paragraph layout strategy corresponding to the paragraph.

10. The method of claim 9, wherein, The determining, according to the difference value, of a target paragraph layout strategy corresponding to the paragraph comprises: in a case where the difference value is less than a second value, determining a preset sixth indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing, based on the sixth indentation strategy, paragraph layout processing on the paragraph, comprising: adjusting the first-line indentation amount of the paragraph by using a first nearest adsorption strategy; adjusting the rest-line indentation amount of the paragraph to be consistent with the current first-line indentation amount.

11. The method of claim 9, wherein, The determining, according to the difference value, of a target paragraph layout strategy corresponding to the paragraph comprises: in a case where the difference value is greater than or equal to the second value, determining a preset seventh indentation strategy as the target paragraph layout strategy corresponding to the paragraph; performing paragraph layout processing on the paragraph based on the seventh indention strategy, including: adjusting the first line indention of the paragraph by using a first nearest adsorption strategy; setting a specified remaining line indention for the paragraph, the specified remaining line indention being a sum of the current first line indention of the paragraph and a preset indention.

12. The method of any one of claims 7, 10-11, wherein, The adjusting of the first line indention of the paragraph by using the first nearest adsorption strategy includes: comparing the first line indention of the paragraph with a set of preset first line target adsorption values; adjusting the first line indention of the paragraph to a first line target adsorption value nearest to the first line indention according to a preset nearest neighbor rule.

13. The method of claim 8, wherein, The adjusting of the remaining line indention of the paragraph by using the second nearest adsorption strategy includes: comparing the remaining line indention of the paragraph with a set of preset remaining line target adsorption values; adjusting the remaining line indention of the paragraph to a remaining line target adsorption value nearest to the remaining line indention according to a preset nearest neighbor rule.

14. The method of claim 1, wherein, After the performing of the paragraph layout processing on each of the paragraphs based on the target paragraph layout strategy, the method further includes: performing indention alignment processing on the text paragraphs belonging to the same numbering interval.

15. The method of claim 1, wherein, After the performing of the paragraph layout processing on each of the paragraphs based on the target paragraph layout strategy, the method further includes: adjusting the hanging indention setting of the paragraph according to a difference between the first line indention and the remaining line indention of the paragraph after the paragraph layout processing.

16. The method of claim 15, wherein, The adjusting of the hanging indention setting of the paragraph according to the difference between the first line indention and the remaining line indention of the paragraph after the paragraph layout processing includes: maintaining the current paragraph layout attribute of the paragraph in a case where one of the following conditions is met: the first line indention and the remaining line indention of the paragraph after the paragraph layout processing are the same, the first line indention and the remaining line indention of the paragraph after the paragraph layout processing are different and the first line of the paragraph does not have a section title; in a case where the first line indention and the remaining line indention of the paragraph after the paragraph layout processing are different and the first line of the paragraph has a section title, setting a hanging indention for the paragraph according to a length of the section title.

17. A document processing apparatus characterized by comprising: The apparatus includes: a first determining module configured to determine the element type and the original indention representation of each paragraph in a document to be processed; a second determining module configured to determine a target paragraph layout strategy corresponding to each of the paragraphs according to the element type and / or the original indention representation; a paragraph layout module configured to perform paragraph layout processing on each of the paragraphs based on the target paragraph layout strategy to obtain a processed document.

18. An electronic device, comprising: include: a processor and a memory, the processor being configured to execute a document processing program stored in the memory to implement the document processing method in any one of claims 1-16.

19. A storage medium, characterized by The storage medium stores one or more programs, which can be executed by one or more processors to implement the document processing method in any one of claims 1-16.