Document processing method and device, electronic equipment and storage medium

By identifying the structural features of newly inserted content in a document and determining the format reference range for intelligent format processing, the problem of insufficient format matching in existing technologies is solved, thereby improving the efficiency and quality of document editing.

CN121881979APending Publication Date: 2026-04-17ZHUHAI 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
ZHUHAI KINGSOFT OFFICE SOFTWARE
Filing Date
2025-12-26
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing document editing tools cannot intelligently match formatting when processing pasted content from complex sources, forcing users to spend a lot of time making manual adjustments, which affects editing efficiency and document quality.

Method used

By identifying the structural features of the original content, determining the format reference range, and performing intelligent format processing based on these features, target content that is consistent with the style of the original text is generated.

Benefits of technology

It achieves intelligent format matching, improves the accuracy and efficiency of typesetting, avoids the problem of fragmented typesetting style caused by a single source of format reference, and enhances the professionalism of documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121881979A_ABST
    Figure CN121881979A_ABST
Patent Text Reader

Abstract

The invention relates to a document processing method and device, electronic equipment and a storage medium, and the method comprises the steps: responding to the insertion of original contents in a document, and determining the structural features of the original contents; and performing format processing on the original content according to the structural characteristics of the original content to obtain target content. According to the technical scheme provided by the embodiment of the invention, the spanning from simple format reuse to intelligent understanding and document structure adaptation is realized, and the typesetting accuracy and typesetting efficiency in a complex content pasting scene and the specialty of the whole document are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly to a document processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] In daily document editing, users can add content to documents primarily through two methods: manual input and copy-paste. Copy-paste is widely used due to its efficiency advantage, and its application scenarios are becoming increasingly complex, including but not limited to: in-document copy-paste within the same document, cross-document copy-paste between different documents, cross-format copy-paste between different formats (such as pasting from web pages, PDFs, or note-taking software to a word processor), and cross-process copy-paste between different applications. However, in this process, the source formatting, implicit non-printable characters, inconsistent paragraph divisions, and numbering systems carried by the original content often interfere with or even destroy the existing formatting specifications and visual consistency of the target document, leading to a series of problems that affect editing efficiency and document quality.

[0003] Currently, mainstream office software word processing components (such as Microsoft Word) offer a "Paste Special" function, with "Match Current Formatting" or "Keep Text Only" being commonly used options. This function can strip away the source formatting to some extent and attempt to apply the direct formatting at the cursor's current position. However, this approach has significant limitations: it typically only matches local formatting adjacent to the insertion point, failing to meet users' higher-level needs for "pasted content" to automatically adapt to the document's existing formatting system, maintain structural integrity, and achieve visual consistency. Summary of the Invention

[0004] This application provides a document processing method, apparatus, electronic device, and storage medium to address the technical problem that current document editing tools still have significant shortcomings in intelligent format matching when processing pasted content from complex sources, causing users to spend a lot of time on tedious manual adjustments, which seriously affects document editing efficiency and user experience.

[0005] Firstly, this application provides a document processing method, the method comprising: In response to inserting original content into the document, the structural features of the original content are determined; Based on the structural characteristics of the original content, the original content is formatted to obtain the target content.

[0006] In one possible implementation, determining the structural features of the original content includes: The original content and at least one of the original content and its contextual content in the document are identified using an artificial intelligence model, and the structural features of the original content are obtained based on the model identification results.

[0007] In one possible implementation, the step of formatting the original content according to its structural characteristics to obtain the target content includes: Based on the insertion position of the original content in the document and the structural characteristics of the original content, a format reference range is determined from the document; Based on the format reference range, the original content is formatted to obtain the target content.

[0008] In one possible implementation, determining the format reference range from the document based on the insertion position of the original content in the document and the structural features of the original content includes: When the structural features of the original content indicate that the original content contains only body paragraphs, a reference paragraph is located from the document based on the element type of the adjacent paragraphs at the insertion position, and the located reference paragraph is determined as a format reference range. Alternatively, if the structural features of the original content indicate that the original content contains a heading paragraph, the selection range is extended to the text above and / or below the insertion position to obtain an extended range as the format reference range.

[0009] In one possible implementation, locating the reference paragraph from the document based on the element type of the adjacent paragraphs at the insertion position includes: Based on the element types of the adjacent preceding and / or following paragraphs at the insertion position, the reference paragraph is located from the document according to predefined rules.

[0010] In one possible implementation, the reference paragraph is located from the document according to predefined rules based on the element type of the adjacent paragraph following the insertion position, including: If the adjacent paragraph following the insertion position is a body paragraph, the adjacent paragraph following the insertion position is determined as a reference paragraph; Alternatively, if the adjacent following paragraph at the insertion position is a heading paragraph, the reference paragraph is determined from the following paragraph of the adjacent following paragraph.

[0011] In one possible implementation, determining the reference paragraph from the following paragraph of the adjacent paragraph includes: The first paragraph of the main text following the insertion position is designated as the reference paragraph. Alternatively, the first heading paragraph with the deepest numbering level in the following text of the insertion location can be designated as the reference paragraph.

[0012] In one possible implementation, based on the element type of the adjacent preceding paragraph at the insertion position, the reference paragraph is located from the document according to predefined rules, including: If the adjacent preceding paragraph at the insertion position is a body paragraph, the adjacent preceding paragraph is determined as a reference paragraph; or, in a continuous body paragraph containing the adjacent preceding paragraph, the body paragraph with the smallest initial indentation is determined as a reference paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a heading paragraph, a reference paragraph is determined based on the hierarchical structure of the preceding paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a special area, the nearest text paragraph following the insertion position shall be designated as the reference paragraph.

[0013] In one possible implementation, determining the reference paragraph based on the hierarchical structure of the adjacent preceding paragraphs includes: Locate the next heading paragraph that is at the same level as the adjacent paragraph above the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, locate the next heading paragraph that is at the same level as the adjacent preceding paragraph of the insertion position and is the closest to the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, the nearest paragraph in the text preceding the insertion position can be designated as the reference paragraph. Alternatively, the nearest paragraph in the main text following the insertion position can be designated as the reference paragraph. Alternatively, the heading paragraph with the deepest numbering level that is closest to the insertion position can be identified as the reference paragraph.

[0014] In one possible implementation, extending the selection range above and / or below the insertion position to obtain an extended interval as the format reference interval includes: If there is no content above the insertion position, the selection range is extended to the following position to obtain an extended range as the format reference range; Alternatively, if there is content preceding the insertion position, the selection range can be extended to the preceding text to obtain an extended interval as the format reference interval.

[0015] In one possible implementation, the step of formatting the original content according to the format reference range to obtain the target content includes: Based on the structural characteristics of the original content, the target paragraph is located from the format reference range; The original content is formatted according to the target paragraph to obtain the target content.

[0016] In one possible implementation, locating the target paragraph from the format reference range based on the structural features of the original content includes: For the heading paragraphs in the original content, locate the other heading paragraphs at the same level and closest to the original content from the format reference range, and determine the other heading paragraphs as the target paragraphs; and / or, For the body paragraphs in the original content, locate the other body paragraphs closest to the original content from the format reference range, and determine the other body paragraphs as target paragraphs; or, locate the other heading paragraphs at the same level and closest to the heading paragraph to which the original content belongs from the format reference range, and determine the first body paragraph below the other heading paragraph as target paragraphs.

[0017] In one possible implementation, the step of formatting the original content according to the target paragraph to obtain the target content includes: The original content is formatted using the paragraph format of the target paragraph to obtain the target content; Alternatively, the original content can be formatted using the character format of the target paragraph, and then the original content can be formatted according to a preset paragraph layout strategy to obtain the target content.

[0018] In one possible implementation, prior to determining the structural features of the original content, the method further includes: Identify the source format of the original content; Based on the source format, the original content undergoes format conversion processing.

[0019] In one possible implementation, prior to determining the structural features of the original content, the method further includes: The original content is then subjected to paragraph correction processing.

[0020] In one possible implementation, prior to determining the structural features of the original content, the method further includes: The original content was numbered and organized.

[0021] In one possible implementation, prior to determining the structural features of the original content, the method further includes: The original content is cleaned of formatting interference factors.

[0022] In one possible implementation, determining the structural features of the original content in response to inserting the original content into the document includes: In response to inserting original content into a document, if the original content is determined to be valid inserted content, the structural characteristics of the inserted content are determined.

[0023] Secondly, this application provides a document processing apparatus, the apparatus comprising: A structural feature determination module is used to determine the structural features of the original content in response to inserting the original content into the document; The format processing module is used to process the original content according to its structural characteristics to obtain the target content.

[0024] In one possible implementation, the structural feature determination module is specifically used for: The original content and at least one of the original content and its contextual content in the document are identified using an artificial intelligence model, and the structural features of the original content are obtained based on the model identification results.

[0025] In one possible implementation, the format processing module includes: A reference interval determination unit is used to determine a format reference interval from the document based on the insertion position of the original content in the document and the structural features of the original content; The processing unit is used to perform format processing on the original content according to the format reference range to obtain the target content.

[0026] In one possible implementation, the reference interval determination unit includes: The first determining subunit is used to locate a reference paragraph from the document based on the element type of the adjacent paragraphs of the insertion position when the structural features of the original content indicate that the original content contains only body paragraphs, and to determine the located reference paragraph as a format reference range. The second determining subunit is used to extend the selection range to the text preceding and / or following the insertion position when the structural features of the original content indicate that the original content contains a title paragraph, so as to obtain an extended range as the format reference range.

[0027] In one possible implementation, the first determining subunit is specifically used for: Based on the element types of the adjacent preceding and / or following paragraphs at the insertion position, the reference paragraph is located from the document according to predefined rules.

[0028] In one possible implementation, the first determining subunit is specifically used for: If the adjacent paragraph following the insertion position is a body paragraph, the adjacent paragraph following the insertion position is determined as a reference paragraph; Alternatively, if the adjacent following paragraph at the insertion position is a heading paragraph, the reference paragraph is determined from the following paragraph of the adjacent following paragraph.

[0029] In one possible implementation, the first determining subunit determines the reference paragraph from the following text of the adjacent paragraph, including: The first paragraph of the main text following the insertion position is designated as the reference paragraph. Alternatively, the first heading paragraph with the deepest numbering level in the following text of the insertion location can be designated as the reference paragraph.

[0030] In one possible implementation, the first determining subunit is specifically used for: If the adjacent preceding paragraph at the insertion position is a body paragraph, the adjacent preceding paragraph is determined as a reference paragraph; or, in a continuous body paragraph containing the adjacent preceding paragraph, the body paragraph with the smallest initial indentation is determined as a reference paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a heading paragraph, a reference paragraph is determined based on the hierarchical structure of the preceding paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a special area, the nearest text paragraph following the insertion position shall be designated as the reference paragraph.

[0031] In one possible implementation, the first determining subunit determines the reference paragraph based on the hierarchical structure of the adjacent preceding paragraphs, including: Locate the next heading paragraph that is at the same level as the adjacent paragraph above the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, locate the next heading paragraph that is at the same level as the adjacent preceding paragraph of the insertion position and is the closest to the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, the nearest paragraph in the text preceding the insertion position can be designated as the reference paragraph. Alternatively, the nearest paragraph in the main text following the insertion position can be designated as the reference paragraph. Alternatively, the heading paragraph with the deepest numbering level that is closest to the insertion position can be identified as the reference paragraph.

[0032] In one possible implementation, the second determining subunit is specifically used for: If there is no content above the insertion position, the selection range is extended to the following position to obtain an extended range as the format reference range; Alternatively, if there is content preceding the insertion position, the selection range can be extended to the preceding text to obtain an extended interval as the format reference interval.

[0033] In one possible implementation, the processing unit includes: The target paragraph positioning subunit is used to locate the target paragraph from the format reference range based on the structural characteristics of the original content. The processing subunit is used to perform format processing on the original content according to the target paragraph to obtain the target content.

[0034] In one possible implementation, the target paragraph positioning subunit is specifically used for: For the heading paragraphs in the original content, locate the other heading paragraphs at the same level and closest to the original content from the format reference range, and determine the other heading paragraphs as the target paragraphs; and / or, For the body paragraphs in the original content, locate the other body paragraphs closest to the original content from the format reference range, and determine the other body paragraphs as target paragraphs; or, locate the other heading paragraphs at the same level and closest to the heading paragraph to which the original content belongs from the format reference range, and determine the first body paragraph below the other heading paragraph as target paragraphs.

[0035] In one possible implementation, the processing subunit is specifically used for: The original content is formatted using the paragraph format of the target paragraph to obtain the target content; Alternatively, the original content can be formatted using the character format of the target paragraph, and then the original content can be formatted according to a preset paragraph layout strategy to obtain the target content.

[0036] In one possible implementation, the device further includes: A format conversion module is used to identify the source format of the original content before determining the structural characteristics of the original content; Based on the source format, the original content undergoes format conversion processing.

[0037] In one possible implementation, the device further includes: The paragraph correction module is used to perform paragraph correction processing on the original content before determining the structural features of the original content.

[0038] In one possible implementation, the device further includes: The numbering and organization module is used to number and organize the original content before determining the structural characteristics of the original content.

[0039] In one possible implementation, the device further includes: The cleaning module is used to clean up format interference factors in the original content before determining the structural characteristics of the original content.

[0040] In one possible implementation, the structural feature determination module is specifically used for: In response to inserting original content into a document, if the original content is determined to be valid inserted content, the structural characteristics of the inserted content are determined.

[0041] Thirdly, this application provides an electronic device, including: a processor and a memory, wherein the processor is configured to execute a document processing program stored in the memory to implement the document processing method described in any one of the first aspects.

[0042] Fourthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the document processing method described in any one aspect.

[0043] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application determines the structural features of the original content in response to the document content insertion operation, and performs intelligent format processing based on these structural features to generate target content that is consistent with the style of the original text. Compared with the prior art, which can only perform simple and mechanical reuse based on the format of the nearest preceding text, this solution achieves a fundamental improvement by recognizing and basing its format on the structural features of the newly inserted content itself. Specifically, by recognizing the structural features such as the logical hierarchy and element type of the newly inserted content, the format processing strategy is intelligently derived based on the recognized structural features, so that format matching is no longer mechanically constrained by the "nearest preceding text", but adapts to the internal structure of the inserted content, thereby enhancing the contextual rationality of format application and the consistency of document style as a whole, and solving the problem of fragmented layout style caused by a single or inappropriate format reference source. At the same time, it can understand the differences in format requirements of different paragraphs, thereby achieving accurate and differentiated format matching for multiple paragraphs, significantly improving the accuracy of format processing, and effectively avoiding content hierarchy chaos caused by uniform formatting. In summary, the technical solution provided in this application has achieved a leap from "simple format reuse" to "intelligent understanding and adaptation of document structure", effectively improving the accuracy and efficiency of typesetting in complex content pasting scenarios, as well as the overall professionalism of the document. Attached Figure Description

[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0047] Figure 1 This is a schematic diagram of a system architecture according to an embodiment of this application; Figure 2 A flowchart illustrating an embodiment of a document processing method provided in this application; Figure 3 This is a schematic diagram illustrating an application scenario involved in an embodiment of this application; Figure 4 A flowchart illustrating an embodiment of another document processing method provided in this application; Figure 5 This is a schematic diagram of a document editing scenario involved in an embodiment of this application; Figure 6 A block diagram illustrating an embodiment of a document processing apparatus provided in this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0050] To address the significant shortcomings of current document editing tools in intelligently matching formats when handling pasted content from complex sources, which forces users to spend considerable time on tedious manual adjustments and severely impacts document editing efficiency and user experience, this application provides a document processing method, apparatus, electronic device, and storage medium that can achieve a leap from "simple format reuse" to "intelligent understanding and adaptation of document structure," effectively improving the accuracy and efficiency of layout in complex content pasting scenarios, as well as the overall professionalism of the document.

[0051] Figure 1 This is a schematic diagram of a system architecture involved in an embodiment of this application. For example... Figure 1 As shown, the system architecture 100 may include: client 101, server 102, model 103, and network 104. Network 104 is used to provide a communication link between client 101, server 102, and model 103, and may include a wireless link, a wired link, or a fiber optic cable, etc., which are not limited in this application.

[0052] The client 101 can be a hardware device or software that supports network connectivity to provide document editing services and other network services. When the device is hardware, it can be a variety of electronic devices with a display screen, including but not limited to smartphones, tablets, laptops, desktop computers, servers, etc. When the device is software, it can be installed on the electronic devices listed above.

[0053] Server 102 is the core processing unit of the entire system architecture 100, capable of deploying various algorithms and relatively powerful computing resources. These algorithms may involve multiple fields such as data processing, machine learning, and deep learning, used to process data uploaded or requests sent by client 101, and execute specific computational tasks, such as document content processing and analysis. Computing resources may include high-performance computing clusters and GPU accelerator cards, which support the rapid execution and efficient processing of algorithms.

[0054] Model terminal 103 is a server or device that deploys one or more models, which are used to process specific computational tasks or provide specific services. For example, model terminal 103 may deploy document element recognition models, natural language processing models, etc. The document element recognition model is used to identify the element types (such as abstract, title, body text, etc.) of paragraphs in the input document. When server terminal 102 receives a request from client 101 and needs to invoke a model, it forwards the request to model terminal 103. Model terminal 103 uses the deployed models to perform inference calculations and outputs the corresponding results. Furthermore, as algorithms continuously improve and data accumulates, the models deployed on model terminal 103 can be updated or optimized periodically. For example, model terminal 103 supports automatic model updates and version control to ensure that the models always maintain the latest performance and accuracy. For example, server terminal 102 is responsible for managing the models on model terminal 103, including uploading, updating, deleting, version controlling, and invoking models.

[0055] Understandable Figure 1 The number of networks and devices shown is for illustrative purposes only. Depending on actual needs, system architecture 100 may include any number of networks and devices, and this embodiment does not impose any limitations on this.

[0056] In some examples, at least two of the client 101, server 102, and model 103 can be the same device, and different devices on the same device can also exchange data with each other via wireless or wired connections.

[0057] Figure 2 This is a flowchart illustrating an embodiment of a document processing method provided in this application. In one embodiment, the method is applied to a client, for example... Figure 1 The example shown is client 101. (As shown in the image) Figure 2 As shown, the process includes the following steps: Step 201: In response to inserting the original content into the document, determine the structural characteristics of the original content.

[0058] The aforementioned documents typically refer to editable document formats, such as .doc, .docx, and .ppt documents, or other formats such as documents and notes. These can be offline or online documents. In practical applications, users can insert content into documents in various ways, such as cut and paste, copy and paste, or manual input. This application embodiment does not impose any limitations on these methods.

[0059] In one embodiment, the method described herein primarily processes raw content that exists in text form. Specifically, the raw content is a text paragraph that can be parsed into a continuous sequence of characters, excluding non-text elements such as images, tables, and embedded objects, and does not involve inserting content into existing images, tables, or objects within a document.

[0060] In another implementation, the method described in this paper primarily processes original content existing as predefined document elements. Specifically, predefined document elements include text elements, as well as non-text elements such as images, tables, and embedded objects, and also involve inserting content into existing images, tables, or objects within the document. For non-text elements, the corresponding content and formatting can be preserved. Of course, the formatting of non-text elements can also be determined based on the formatting of similar elements in the context.

[0061] The core task of step 201 is to analyze the original content inserted by the user into the document to identify key attributes related to the document's organizational structure, i.e., structural features. Structural features describe the role and location of the content within the document's logical structure, mainly including element type (e.g., determining whether a paragraph belongs to a heading, body text, figure caption, or specially formatted body text) and content level (e.g., determining whether a heading is a first-level, second-level, or deeper level).

[0062] See Figure 3 The diagram illustrates a document processing application scenario according to an embodiment of this application. In this scenario, a user inserts original content into a document containing multiple numbered entries (as shown in the diagram: "II. AI Helps Me Edit", "III. AI Inspiration Market", "IV. AI Word Highlighting Reading"). By applying the document processing method provided in this embodiment, the structural features of the original content are intelligently identified (e.g., identifying paragraphs as different levels of headings and body text), and based on its context in the document, a series of formatting processes are automatically performed, including format matching, paragraph rearrangement, and numbering. Ultimately, the newly added original content maintains a consistent formatting style with the original text, thereby achieving efficient and accurate intelligent typesetting.

[0063] For example, in response to detecting a user's insertion of original content into the document, a "Smart Formatting" function icon (or context menu option) can be dynamically displayed near the insertion location (e.g., next to the cursor or at the end of a paragraph). The user can trigger the operation by clicking, hovering over, or using a keyboard shortcut to actively enable and execute the technical solution provided in this application's embodiments. This interactive design provides users with a clear and convenient function entry point while also giving them control over formatting, achieving a good balance between automated intelligent processing and controllable user intent.

[0064] In one embodiment, based on Figure 1 The system architecture described above identifies the structural features of newly inserted original content in a document through collaborative efforts between the client, server, and model. Specifically, the client responds to user actions and collects content to be processed, the server coordinates the processing flow and logical scheduling, and the model provides AI (Artificial Intelligence) recognition capabilities. These three components work together to complete the analysis process from content input to feature output. The specific implementation methods and steps of this recognition mechanism will be further explained in the examples below.

[0065] Step 202: Based on the structural characteristics of the original content, perform format processing on the original content to obtain the target content.

[0066] The core task of step 202 is to perform intelligent format processing on the newly inserted original content in the document based on the structural features determined in step 201, so that its format is consistent with the overall style of the original document and generates target content with standardized format and consistent layout.

[0067] For example, see Figure 3 The example will automatically identify the three paragraphs "II. AI Helps Me Edit," "III. AI Inspiration Market," and "IV. AI Word Highlighting Reading" as belonging to the same level of headings as "I. AI Writes Articles," and set their format to match the heading format. Simultaneously, the corresponding body paragraphs below each heading will be uniformly formatted to match the original text paragraphs. This formatting includes text and layout attributes such as font, font size, and paragraph indentation. Through this processing, a seamless visual and structural integration of the new content with the original text can be achieved.

[0068] Furthermore, based on the above format processing, the generated target content can be presented to the user in a variety of flexible interaction methods to adapt to different user habits and application scenarios. This improves automation efficiency while ensuring the user's control and right to know about the final result. Specific presentation methods include, but are not limited to, the following: Direct Replace: Seamlessly replaces the original content in the document with the target content, achieving a smooth "one-click organization" experience; Replace after confirmation: Display the target content in a non-intrusive interface such as a floating window, bubble, or sidebar, and replace it only after the user confirms, thus achieving a balance between automation and user control; Insert comparison: Insert the target content after the original content to create a visual comparison between the old and new content for users to refer to or choose from; Comments and suggestions: Attach formatting adjustments as comments or suggestions next to the original content, which users can review and accept as needed.

[0069] These diverse presentation methods constitute a flexible and user-friendly output layer design, ensuring intelligent typesetting while also taking into account both security and user autonomy.

[0070] As for the specific process of formatting the original content based on its structural characteristics to obtain the target content, it will be explained below. Figure 4 The embodiments shown are explained in detail, but will not be elaborated here.

[0071] The technical solution provided in this application, in response to document content insertion operations, determines the structural features of the original content and performs intelligent formatting based on these structural features, thereby generating target content that is consistent with the style of the original text. Compared to existing technologies that can only perform simple and mechanical reuse based on the format of the nearest preceding text, this solution achieves a fundamental improvement by recognizing and basing its formatting on the structural features of the newly inserted content itself. Specifically, by recognizing the logical hierarchy and element types of the newly inserted content, the solution intelligently derives a formatting strategy based on the identified structural features. This ensures that formatting matching is no longer mechanically constrained by the "nearest preceding text," but rather adapts to the inherent structure of the inserted content. This enhances the contextual rationality of formatting application and the consistency of document style, solving the problem of fragmented layout styles caused by a single or inappropriate formatting reference source. Simultaneously, it understands the differences in formatting requirements of different paragraphs, thereby achieving accurate and differentiated formatting matching for multiple paragraphs, significantly improving the accuracy of formatting processing and effectively avoiding content hierarchy chaos caused by uniform formatting. In summary, the technical solution provided in this application has achieved a leap from "simple format reuse" to "intelligent understanding and adaptation of document structure", effectively improving the accuracy and efficiency of typesetting in complex content pasting scenarios, as well as the overall professionalism of the document.

[0072] Figure 4 A flowchart illustrating an embodiment of another document processing method provided in this application. Figure 4 The process shown is in Figure 2Based on the illustrated process, this paper describes an exemplary implementation of formatting the original content according to the structural characteristics of the newly inserted original content to obtain the target content. For example... Figure 4 As shown, it includes the following steps: Step 401: Based on the insertion position of the original content in the document and the structural characteristics of the original content, determine the format reference range in the document.

[0073] Step 402: Based on the format reference range, process the original content to obtain the target content.

[0074] For ease of understanding, steps 401 and 402 are explained uniformly below: The format reference range refers to the contextual reference range used when formatting the original content. This range can include one or more paragraphs in the document. When determining the format reference range from the document, the selection logic is not mechanically based solely on the insertion position of the original content (e.g., simply selecting adjacent paragraphs), but rather correlated with the structural characteristics of the original content itself. By establishing the relationship between the insertion position and structural characteristics, the most suitable format reference source can be selected for inserted content of different natures.

[0075] After determining the format reference range from the document, guided by the structural characteristics of the original content, the original content is formatted according to the format reference range to obtain the target content. For example, the most suitable format is found and applied to each paragraph of the original content from the format reference range. For instance, for a paragraph identified as a "second-level heading," a second-level heading paragraph can be found within the format reference range, and its font, size, bold, color, indentation, and other formatting attributes can be copied and applied to the current paragraph; for a paragraph identified as "body text," the format of body text at the same level within the format reference range is matched. Further continuity correction and synchronization can be performed on paragraph numbering, list symbols, etc. Finally, by applying the above formatting operations to the entire original content, target content that is consistent, standardized, and uniform with the document context in terms of visual presentation, structural hierarchy, and layout style is generated, thus achieving automated and intelligent processing from "original insertion" to "format fusion."

[0076] The above provides an overall explanation of steps 401 and 402. The following sections will further elaborate on the implementation details of steps 401 and 402, considering different scenarios: In one embodiment, an exemplary implementation of determining the format reference range from the document based on the insertion position of the original content in the document and the structural features of the original content falls into two categories: Scenario 1: If the structural features of the original content indicate that the original content contains only body paragraphs, locate the reference paragraph in the document based on the element type of the adjacent paragraph at the insertion position, and determine the located reference paragraph as the format reference range.

[0077] When the structural characteristics of the original content indicate that it contains only body paragraphs, the focus is on finding matching body format references from the adjacent context of the original content. This adjacent context includes adjacent preceding paragraphs and / or adjacent following paragraphs. Therefore, locating the reference paragraph from the document based on the element types of the adjacent paragraphs at the insertion position includes: locating the reference paragraph from the document based on the element types of the adjacent preceding and / or adjacent following paragraphs at the insertion position, and according to predefined rules.

[0078] Specifically, when there is an adjacent preceding paragraph at the insertion point of the original content, the reference paragraph is located from the document based on the element type of the adjacent preceding paragraph and according to predefined rules. When there is no preceding paragraph at the insertion point, the reference paragraph is located from the document based on the element type of the adjacent following paragraph and according to predefined rules. The reason for this approach is that document editing and reading typically follow a top-down natural order. Existing preceding content logically and visually constitutes the direct context of the current editing position, and its format (such as the style of the chapter, the continuing numbering sequence, and paragraph indentation standards) has a stronger binding force and reference significance on the format of subsequent content. Prioritizing the reference to preceding paragraphs ensures that the format of the newly inserted content remains consistent with the previously established document structure to the greatest extent possible, avoiding format gaps or logical confusion in the overall document caused by referencing the format of the following text, which is not yet determined or belongs to different logical blocks. When the insertion point is at the beginning of a document or in other scenarios where there is no preceding text, the following paragraph becomes the only available source of reference that reflects the formatting intent of the current area. In this case, deriving from the following text is a reasonable and necessary alternative strategy.

[0079] Furthermore, based on the element type of the adjacent preceding paragraph at the insertion position, the specific implementation of locating the reference paragraph from the document according to predefined rules can be divided into three cases: Scenario 1: If the adjacent preceding paragraph at the insertion point is a body text paragraph, the adjacent preceding paragraph will be designated as the reference paragraph. Alternatively, within a continuous body text interval containing the adjacent preceding paragraph, the body text paragraph with the smallest initial indentation will be designated as the reference paragraph. Specifically, when the adjacent preceding paragraph at the insertion point is a body text paragraph, the determination of the reference paragraph will be based on the specific attributes of that body text paragraph: (1) When the adjacent preceding paragraph is a regular text paragraph, the text paragraph with the smallest indentation value in the continuous text interval containing the adjacent preceding paragraph is determined as the reference paragraph.

[0080] Among them, regular body paragraphs refer to paragraphs that can be clearly identified as ordinary body text by artificial intelligence models. These paragraphs have standard body paragraph format characteristics, and therefore can be accurately identified by artificial intelligence models.

[0081] In this scenario, since paragraphs within a continuous text section are typically formatted based on the same standard, the paragraph with the smallest indentation often represents the formatting starting point or baseline style for that area. Therefore, using the paragraph with the smallest initial indentation as a reference helps maintain formatting consistency within the section and provides a reasonable formatting starting point for newly inserted content that conforms to the current text structure. Accordingly, when the adjacent preceding paragraph is a regular text paragraph, the text paragraph with the smallest initial indentation within the continuous text section containing that adjacent preceding paragraph is determined as the reference paragraph.

[0082] Furthermore, when the adjacent preceding paragraphs are regular body text paragraphs, the character format of the original content is processed using the character format of the reference paragraph, and the original content is processed for paragraph layout according to the preset paragraph layout strategy to obtain the target content.

[0083] For example, the preset paragraph layout strategy includes setting the indentation of the first paragraph in the original content to 2 characters. This conforms to common Chinese document typesetting standards and provides a clear and standardized starting point for newly inserted text. Starting with the second paragraph, the indentation value is derived based on the original indentation relationship between the paragraph and its predecessor to intelligently continue or establish a reasonable hierarchical format. For instance, if the original indentation of the current paragraph is the same as that of the previous paragraph, it indicates that they are at the same level in the original content, and this indentation value will remain unchanged to continue the original parallel relationship. If the original indentation of the current paragraph is greater than that of the previous paragraph, it usually means that it has a subordinate or secondary relationship with the preceding content. In this case, its indentation value can be maintained or appropriately increased to reasonably reflect this hierarchical difference in the target content. Conversely, if the original indentation of the current paragraph is significantly smaller than that of the previous paragraph, it may be considered an abnormal or inconsistent format. In this case, the strategy will refer to the indentation of the previous paragraph and derive a new indentation value that conforms to conventional reading logic based on a preset hierarchical increment (e.g., adding 2 characters). Through this dynamic derivation based on the indentation relationship between adjacent paragraphs, the preset paragraph layout strategy can autonomously construct a clear, reasonable, and internally consistent visual hierarchy of paragraphs for newly inserted multi-paragraph content, even in the absence of explicit contextual references.

[0084] (2) When the adjacent preceding paragraph is a special formatted text paragraph (such as addressee, signature, picture title, table title, appendix, footnote, etc.), the adjacent preceding paragraph itself shall be directly identified as the reference paragraph.

[0085] Specially formatted text typically plays an independent and fixed functional role in a document, with its formatting having clear norms and being context-specific. Logically, it does not belong to a continuous text flow with the preceding and following regular text; therefore, the formatting reference strategy should not follow the same selection strategy as for regular text sections (such as looking for the smallest indented paragraph). Using the specially formatted text paragraph itself as a reference best ensures that newly inserted content maintains a consistent and standardized appearance with this specific functional area.

[0086] Furthermore, special formatted body paragraphs have specific formatting functions and fixed style requirements. Their font, font size, and other character attributes have clear normative significance, making them suitable as a reference for character formatting. However, their paragraph layout (such as indentation) often differs from ordinary body text. Directly adopting them may lead to formatting misalignment. Therefore, the paragraph layout needs to be re-derived to ensure the overall structural consistency.

[0087] Therefore, when the adjacent preceding paragraphs are specially formatted body text paragraphs, the character format of the original content is processed using the character format of the reference paragraph, and the original content is then processed for paragraph layout according to the preset paragraph layout strategy to obtain the target content. This method yields target content that is consistent with the character style of the local functional area and also reasonable in the overall paragraph structure.

[0088] (3) If the adjacent preceding paragraph is suspected to be a main text paragraph, the adjacent preceding paragraph shall also be identified as a reference paragraph.

[0089] In this context, "suspected main text paragraphs" refer to paragraphs that the AI ​​model identifies as non-main text, but the client determines based on other rules (such as format features and location information) that they are suspected to be main text with special formatting. In this case, the reason for still using this paragraph as a reference paragraph is that the client's filtering judgment through auxiliary rules is essentially a secondary confirmation of the paragraph's formatting attributes. Although it is not directly classified as regular main text by the model, its character formatting (such as font and font size) has been verified to be reasonable and standardized for the local scenario. Therefore, directly referencing its character formatting can provide a reliable and context-appropriate formatting basis for subsequent content, even when the model's initial identification is uncertain.

[0090] In other words, although the body text of such paragraphs may be somewhat ambiguous, the actual character format they present still reflects the local style characteristics of that area and has certain reference value. At the same time, in order to avoid conveying possible paragraph format deviations, the paragraph layout still follows the preset strategy for derivation, thereby ensuring the stability of the overall typesetting while retaining effective format information.

[0091] Therefore, when an adjacent preceding paragraph is suspected to be body text, the original content is formatted using the reference paragraph's character format, and then the original content is formatted according to a preset paragraph layout strategy to obtain the target content. This process can output target content that conforms to the context's formatting style.

[0092] The above differentiation and processing methods are based on the format nature and functional intent of different text paragraphs, and match the newly inserted original content with appropriate reference strategies, thereby ensuring the accuracy of the format while maintaining the coordination and consistency of the overall document layout.

[0093] Scenario 2: When the adjacent preceding paragraph at the insertion point is a heading paragraph, the reference paragraph is determined based on the hierarchical structure of the adjacent preceding paragraph. Specifically, when the adjacent preceding paragraph at the insertion point is a heading paragraph, the determination of the reference paragraph will be based on the confidence level of the identified heading paragraph and its hierarchical attributes to ensure that the newly inserted content inherits the correct document hierarchical formatting. (1) When the adjacent preceding paragraph is a regular heading paragraph, the reference paragraph is determined based on the hierarchical structure of the adjacent preceding paragraph.

[0094] In this context, a regular heading paragraph refers to a paragraph whose hierarchy (such as first-level heading, second-level heading) can be clearly identified and confirmed through an artificial intelligence model. When the adjacent preceding paragraph is a regular heading paragraph, the reference paragraph is determined according to the following hierarchy derivation strategy: First, locate the nearest other heading paragraph at the same level as the adjacent preceding paragraph in the text above the insertion point, and determine the first body text paragraph following that other heading paragraph as the reference paragraph. If this is not feasible, locate the nearest other heading paragraph at the same level as the adjacent preceding paragraph in the text below the insertion point, and determine the first body text paragraph following that other heading paragraph as the reference paragraph. If this is still not feasible, determine the nearest body text paragraph above the insertion point as the reference paragraph. If this is still not feasible, determine the nearest body text paragraph below the insertion point as the reference paragraph. As a last resort, determine the heading paragraph with the deepest numbering level closest to the insertion point as the reference paragraph.

[0095] The reason for this approach is that heading paragraphs play a core role in organizing the document's structure, and their format strictly corresponds to their hierarchical level. To ensure that newly inserted content continues the structure defined by the current heading, priority is given to finding formatting references within the context of the same-level heading. Therefore, the core strategy is to locate the nearest other heading at the same level as the current heading (whether preceding or following it) and use the first body paragraph under that heading as a reference. This ensures that the new content receives a format that matches the heading level and maintains a consistent style. If a same-level heading cannot be located, the approach is to find the nearest body paragraph as a reference; as a last resort, the deepest-level heading in the context can also be consulted to obtain a relatively reasonable formatting benchmark.

[0096] Furthermore, when the adjacent preceding paragraphs are regular heading paragraphs, after determining the reference paragraph through the above-mentioned hierarchical derivation strategy, the original content is formatted using the character format of the reference paragraph, and the original content is formatted according to the preset paragraph layout strategy to obtain the target content.

[0097] In addition, it should be noted that when the heading paragraph with the deepest numbering level and closest insertion position is identified as the reference paragraph, it is further determined whether the font size of the reference paragraph meets the criteria for being used as a formatting reference. Specifically, the font size of the paragraph is compared with a preset font size threshold: if the font size is smaller than the threshold, the character format of the reference paragraph is used to format the original content; otherwise, the character format of the reference paragraph is discarded, and the preset character format is used instead to format the original content.

[0098] The reason for this approach is that, within the document structure, the font size of the deepest-level headings is usually close to that of the body text. If their font size is small (e.g., less than the set threshold), it indicates that they may visually coordinate with the body text and are suitable as a formatting reference. If their font size is large (reaching or exceeding the threshold), it means that they still retain obvious heading characteristics, and directly applying their formatting to the body text to be inserted may result in abrupt formatting and confusion of hierarchy. By introducing a font size threshold, more refined and reasonable control can be achieved when referencing the formatting of deep-level headings, thereby ensuring that the final layout conforms to the overall visual specifications and hierarchical order of the document while making full use of contextual formatting information.

[0099] (2) When the adjacent preceding paragraph is a suspected title paragraph, the reference paragraph is determined based on the hierarchical structure of the adjacent preceding paragraph.

[0100] Among them, a suspected title paragraph refers to a paragraph whose recognition confidence by the artificial intelligence model is insufficient, but which the client judges to have the potential to function as a title based on auxiliary rules such as format features and location information. In this case, the reference paragraph is determined according to the following hierarchical derivation strategy: First, determine the nearest preceding paragraph in the main text as the reference paragraph. If this is not feasible, then determine the nearest following paragraph in the main text as the reference paragraph. If this is still not feasible, then use a fallback strategy: determine the nearest heading paragraph with the deepest numbering level as the reference paragraph.

[0101] The reason for this approach is that, due to the uncertainty in the model's identification of suspected heading paragraphs, directly using the conventional heading reference strategy might lead to format inheritance errors due to misjudgment of hierarchy. Therefore, a cautious and gradual safety strategy is adopted instead: first, the most recent body text paragraph is tried as a format reference, because the body text format is relatively stable and easy to confirm in context, providing a reliable benchmark for the basic format. If this path is not feasible, the deepest-level heading in the context is further referenced, but with safety constraints imposed. For example, its character format is only adopted if its font size is less than a preset threshold (such as 4 points); otherwise, the preset character format is used to avoid misusing the large font size format that clearly belongs to the heading in the body text.

[0102] Regarding paragraph layout, it is uniformly derived based on a preset benchmark (such as starting with two characters) to avoid inheriting potentially abnormal indentation and other attributes. This series of strategies aims to provide a format reference for newly inserted content that is both consistent with the visual characteristics of the context and does not disrupt the overall consistency of the document, even when the model recognition is ambiguous, through step-by-step verification and constraint rules.

[0103] Furthermore, when an adjacent preceding paragraph is a suspected heading paragraph, after determining the reference paragraph through the above-mentioned hierarchical deduction strategy, the character format of the original content is processed according to whether the safety constraints are met, using either the character format of the reference paragraph or a preset character format. The paragraph format is then uniformly set according to the preset paragraph layout strategy, thereby outputting target content with a stable format and compatibility with the context logic.

[0104] Case 3: If the preceding paragraph adjacent to the insertion point is a special area, the nearest main text paragraph following the insertion point will be designated as the reference paragraph.

[0105] Special areas include sections like the cover, header, and footer. These areas have independent, fixed formatting functions, and their formatting specifications serve specific document structural parts (such as the first page, header, and footer), usually independent of the main body's formatting system. Using them as a formatting reference might cause newly inserted content to deviate from the formatting context of the main text, resulting in a disjointed layout. Therefore, it's better to look for a reference in the immediately following main body of the document, i.e., selecting the "most recent paragraph in the main text below the insertion point." This ensures that the new content inherits the formatting style of the core main text area, guaranteeing visual and structural continuity with subsequent text.

[0106] Furthermore, in this case, the font, font size, and other character attributes of the main text paragraph are referenced to provide the new content with a text appearance consistent with the main body of the document. Layout attributes such as paragraph indentation are not directly copied (as they may be affected by the position of special areas), but are independently derived based on preset rules (such as "starting from two characters"). This ensures that while matching the format, the paragraph structure is clear and the layout is reasonable, so that the final target content can not only blend with the context style but also conform to the layout logic of the main document.

[0107] Therefore, when the adjacent preceding paragraphs are special areas of content, the character format of the original content is processed using the character format of the reference paragraph, and the original content is processed for paragraph layout according to the preset paragraph layout strategy to obtain the target content.

[0108] Furthermore, based on the element type of the adjacent paragraphs at the insertion position, the specific implementation of locating the reference paragraph from the document according to predefined rules can be divided into three cases: Case 1: If the adjacent paragraph following the insertion point is a body paragraph, then the adjacent paragraph following the insertion point will be designated as the reference paragraph.

[0109] The body paragraphs here include three types: regular body paragraphs, specially formatted body paragraphs, and paragraphs that appear to be body paragraphs. Furthermore, different formatting strategies are used for these three types: (1) When the adjacent following paragraph is a regular body text paragraph, the original content is formatted directly using the paragraph format of that adjacent following paragraph to obtain the target content. Here, the paragraph format is the complete paragraph format, including character format (such as font, font size, color, etc.) and paragraph format (such as indentation, alignment, line spacing, etc.). This processing can ensure that the newly inserted content is completely consistent with the subsequent body text in terms of format, maintaining the visual coherence and structural unity of the document.

[0110] (2) When the adjacent following paragraph is a suspected main text paragraph or a main text paragraph with a special format, the character format of the adjacent following paragraph is used to process the original content, and the paragraph layout is processed according to the preset paragraph layout strategy to obtain the target content.

[0111] Since suspected body paragraphs may not have complete or reliable paragraph formatting, or special body paragraphs may have special formatting or functions, this method can ensure that the paragraph structure is clear and conforms to the overall document specifications by pre-setting paragraph layout strategies while inheriting the text style.

[0112] Scenario 2: When the adjacent paragraph following the insertion point is a heading paragraph, determine the reference paragraph from the following paragraph. This determination includes: identifying the first body text paragraph in the following paragraph of the insertion point as the reference paragraph; or, identifying the first heading paragraph with the deepest numbering level in the following paragraph of the insertion point as the reference paragraph.

[0113] The heading paragraphs here include two types: regular heading paragraphs and suspected heading paragraphs. For both cases, the reference paragraph can be determined according to the following derivation strategy: firstly, the first body text paragraph following the insertion point should be identified as the reference paragraph; if this is not feasible, the first heading paragraph with the deepest numbering level following the insertion point should be identified as the reference paragraph.

[0114] The reason for this approach is that heading paragraphs have a clear hierarchical and organizational function in the document structure, and their formatting often reflects the style guidelines of the current chapter. To ensure that newly inserted content is visually and logically consistent with its heading area, the selection of reference paragraphs should follow these principles: 1. Prioritize body text: Prioritize the first body text paragraph below the title as a reference because the body text paragraph usually directly carries the content under the title, and its format (such as font, indentation, line spacing, etc.) best represents the actual text style of the chapter, which can ensure that the inserted content maintains visual consistency with the chapter in terms of format.

[0115] 2. Hierarchical Supplementation: If there is no body paragraph below the title (e.g., a subheading follows the title directly), the first title with the deepest numbered level is selected as the reference. Deep headings often inherit and continue the style system of the current chapter, providing a relatively reliable benchmark for paragraph and character formatting, and avoiding formatting errors caused by cross-level references.

[0116] This strategy ensures structural consistency between the inserted content and the context from two dimensions: content relevance and format inheritance. It follows the natural reading order of the document while also taking into account the format constraints of the heading hierarchy system.

[0117] Furthermore, after determining the reference paragraph, the original content is formatted using the character format of the reference paragraph, and the original content is formatted according to the preset paragraph layout strategy to obtain the target content.

[0118] Case 3: If the adjacent paragraph at the insertion point is a special area, the original content is formatted using the preset character format, and the original content is laid out according to the preset paragraph layout strategy to obtain the target content.

[0119] This concludes the description of Case 1 (where the structural features of the original content indicate that the original content contains only body paragraphs, the reference paragraph is located from the document based on the element type of the adjacent paragraph at the insertion position, and the located reference paragraph is determined as the format reference range).

[0120] Scenario 2: If the structural features of the original content indicate that the original content contains a heading paragraph, extend the selection range to the text above and / or below the insertion point to obtain an extended range as a format reference range.

[0121] When the structural features of the original content indicate that it contains heading paragraphs, it means that the newly inserted content itself has a hierarchical structure. To accurately understand and match the position and format of this structure within the overall document, referring only to adjacent paragraphs is insufficient. Therefore, the selection range is expanded to the text above and / or below the insertion point to obtain an extended range as a format reference range. The specific expansion logic here also follows the priority order of "preceding the text above, then following the text": if there is content above the insertion point, the selection range is expanded to obtain an extended range as a format reference range. If there is no content above the insertion point, the selection range is expanded to obtain an extended range as a format reference range.

[0122] The stopping boundary rules during the expansion process are as follows: 1. When expanding upwards, the expansion will stop if any of the following situations are encountered: Reaching the document's starting boundary; When encountering special layout areas such as the cover, header, and footer; When encountering independent content with fixed format functions, such as signatures, appendices, notes, addressees, and contract information; When encountering the main title of a document or the title of an attachment; When you encounter a chapter title, try to locate the starting point of the previous chapter; if you cannot locate it, stop here.

[0123] 2. When expanding to the following text (when there is no content above), expansion will stop if any of the following situations are encountered: Reached the end of document boundary; When encountering special layout areas such as the cover, header, and footer; When encountering independent content with fixed format functions, such as signatures, appendices, notes, addressees, and contract information; When encountering the main title of a document or the title of an attachment; When you encounter a chapter title, try to locate the starting point of the next chapter; if you cannot locate it, stop here.

[0124] Through the aforementioned extension mechanism and boundary control, a complete and reasonable contextual range can be intelligently drawn as a format reference range for complex inserted content containing titles, laying the foundation for subsequent accurate hierarchical matching and format migration.

[0125] Furthermore, in one embodiment, formatting the original content according to a format reference range to obtain target content includes: locating the target paragraph from the format reference range based on the structural characteristics of the original content; and formatting the original content according to the target paragraph to obtain the target content.

[0126] The technical solution provided in this embodiment does not simply apply the format of the reference range as a whole, but rather performs precise and targeted format positioning and migration within the format reference range based on the structural characteristics of each paragraph in the original content.

[0127] Specifically, based on the structural characteristics of the original content, the target paragraph is located from the format reference range, including: for heading paragraphs in the original content, locating the other heading paragraphs at the same level and closest to the original content from the format reference range, and identifying the other heading paragraphs as the target paragraphs; and / or, for body paragraphs in the original content, locating the other body paragraphs at the same level and closest to the original content from the format reference range, and identifying the other body paragraphs as the target paragraphs; or, locating the other heading paragraphs at the same level and closest to the heading paragraphs to which the original content belongs from the format reference range, and identifying the first body paragraph following the other heading paragraph as the target paragraph.

[0128] Specifically, for heading paragraphs in the original content: from the format reference range, locate the nearest other heading paragraph at the same level as the current heading and designate it as the target paragraph. This ensures that the newly inserted heading inherits the accurate formatting of existing headings at the same level in the document, maintaining the consistency of the heading hierarchy.

[0129] For body paragraphs within the original content, two complementary strategies are employed: First, directly locate the nearest other body paragraph as the target paragraph. This is the most intuitive method of format reference and is suitable for most cases. Second, considering that body text usually belongs to a heading, first locate the nearest other heading paragraph at the same level as that heading, and then select the first body paragraph following that heading paragraph as the target paragraph. This strategy ensures a high degree of consistency in body text formatting within the same heading level, avoiding format jumps between body text under different headings that might result from simply referencing the "nearest body text."

[0130] After accurately locating the target paragraph, the process then proceeds to "format the original content based on the target paragraph." For example, for a heading paragraph, the character format (font, font size, etc.) and paragraph format (indentation, spacing, etc.) of the target paragraph are copied and applied to the corresponding heading paragraph in the original content. For body paragraphs, the character format of the target paragraph is copied and applied to the corresponding body paragraph in the original content, while the paragraph format is derived based on the target paragraph according to a preset paragraph layout strategy.

[0131] Through this feature-guided positioning and one-to-one format migration, the correct, discrete, local formats in the format reference range can be efficiently and accurately "assembled" onto newly inserted, complex original content, ultimately generating target content that is deeply integrated with the overall document style and has a unified format specification.

[0132] This concludes the description of Case Two (where the structural features of the original content indicate that the original content contains a heading paragraph, the selection range is extended to the text above and / or below the insertion point to obtain an extended range as a format reference range).

[0133] In practical applications, when distinguishing between scenario one and scenario two, the character count of each paragraph in the original content can also be used as an auxiliary basis for judgment. Specifically, the character count of each paragraph can be compared with a preset character count threshold: if the character count of all paragraphs in the original content is greater than the threshold, then each paragraph can be determined to be a body text paragraph; conversely, if the character count of any paragraph is less than or equal to the threshold, then the original content can be determined to contain a title paragraph. This judgment method provides a fast and effective auxiliary basis for the aforementioned distinction based on structural features.

[0134] Figure 4 The process illustrated involves determining a format reference range within the document based on the insertion position and structural features of the original content. The original content is then formatted according to this reference range to obtain the target content. This process intelligently determines the format reference range by combining insertion position and content structural features, achieving context-aware automatic formatting. This significantly improves the accuracy of formatting and the overall consistency of the document, while also adapting to complex hierarchies and diverse layout scenarios. It greatly reduces the need for manual intervention and effectively enhances the efficiency of document editing and layout.

[0135] In one embodiment, determining the structural features of newly inserted original content includes: identifying at least one of the original content and the contextual content of the original content in the document using an artificial intelligence model, and obtaining the structural features of the original content based on the model identification results.

[0136] The core of this embodiment lies in determining the structural characteristics of newly inserted original content by not analyzing the original content itself in isolation, but by comprehensively understanding it in conjunction with the context of its insertion position. In a preferred embodiment, an artificial intelligence model (such as a large language model) is invoked, using both the original content and its context (e.g., content within a "format reference range") as input. This model analyzes the content, semantics, and logical relationships between the two, outputting a determination of the "structural characteristics" of each paragraph in the original content. These characteristics can at least cover element type (e.g., determining whether a paragraph belongs to a title, body text, figure caption, or specially formatted body text) and / or content level (e.g., determining whether a title is at a first, second, or deeper level).

[0137] Specifically, the process begins by invoking an artificial intelligence model (such as a large language model) to analyze the contextual content surrounding the insertion point of the original content (which can be text within a defined "format reference range"). This model first parses the contextual content, identifying and outputting its inherent structural features. These features are "absolute concepts" and may include: element type, content level, numbering system, and logical regions (e.g., determining whether the section belongs to the main body of a document, appendix, chart description, or other specific areas).

[0138] Subsequently, the original content and its surrounding context are input into the model for association analysis. Based on the "formatting environment" and semantic cues provided by the context, the model infers the structural features of related concepts within the original content within that environment. For example, even if the original content is simply plain text "Implementation Plan," the model can determine that the "Implementation Plan" paragraph should inherit the element type and content level of a second-level heading by combining its position immediately following a "1.2 Technical Background" heading and the consistent use of second-level heading styles in the context.

[0139] The hierarchical processing flow of "contextual absolute feature recognition → content association analysis → original content feature derivation" provides a reliable structured basis for subsequent accurate format matching.

[0140] In one embodiment, a series of preprocessing operations can be selectively performed on newly inserted original content before analyzing its structural features. The core purpose of these operations is to clean, standardize, and preliminarily structure the original content—which may be diverse in origin, inconsistent in format, and potentially contain interfering information—transforming it into a "standardized text" with a uniform format, clear logic, and suitability for deep intelligent analysis. This preprocessing stage is a crucial foundation for subsequent accurate identification of structural features and intelligent format matching, significantly improving the robustness and accuracy of the entire process. Exemplary examples include, but are not limited to, the following preprocessing operations: (1) Identify the source format of the original content and perform format conversion processing on the original content according to the source format.

[0141] This preprocessing operation aims to address the complexity of content sources. The original content may come from web page copying, pasting from other documents, email body, or plain text input, and its underlying source may carry rich formatting (such as HTML tags, Word-specific styles, Markdown syntax, etc.).

[0142] By detecting or parsing these source formats, the original content is then converted into a uniform, neutral intermediate format (e.g., plain text stream, but retaining core structural information such as paragraphs and basic line breaks) used by the system's internal processing. This removes the dependency on external formats and provides a fair and reasonable basis for all subsequent analyses.

[0143] For example, the identification and processing of HTML content includes: determining whether the content contains typical HTML code features, such as... 、 、 Tags such as `<style>` and `<class>` are identified. After identification, an HTML parser can be invoked to strip away all HTML tags and style attributes, extracting the clean text content and basic logical paragraph structure. This aims to completely eliminate the interference of webpage styles on subsequent analysis, ensuring content neutrality.

[0144] The identification and processing of Markdown content includes: detecting whether the beginning of paragraphs contains Markdown-specific markers, such as heading markers (#, ##), list markers (-, 1.), or code block markers. After identification, these Markdown syntax markers are parsed. For example, "#heading" is converted into a plain text heading representing a level 1 heading and its heading attributes are recorded; "-item" is converted into a plain text item and its list item attributes are recorded. This removes the markers while preserving the structured intent information of the content.

[0145] The identification and processing of PDF source content involves recognizing common features found when copying text from PDFs, such as unnatural hyphenation at the end of lines, extra spaces, or specific line break patterns after paragraphs. After identification, cleanup and restructuring operations are performed, including merging incorrectly broken words, removing extra spaces, and reconstructing correct paragraph boundaries based on line breaks and indentation patterns. The goal is to correct common text flow errors in PDF conversion and restore the coherent paragraph structure of the content.

[0146] In summary, through the targeted feature identification and conversion described above, "original content" from different channels and carrying different underlying formats can be uniformly converted into a standardized text that retains only the core textual information and basic logical structure, and has a neutral format, laying a solid foundation for subsequent accurate analysis of its structural features.

[0147] Furthermore, when performing format conversion, artificial intelligence models can be relied upon, and prompt word engineering can be used to achieve more accurate and robust conversion processing. The core method involves designing specific prompt words highly adapted to the characteristics of different source formats (such as HTML, Markdown, or PDF) that have been initially identified through rules. This guides the AI ​​model to perform conversion tasks that combine semantic understanding and format cleaning. For example, for HTML content, the prompt words can instruct the model to "remove all tags but retain the text and paragraph logic"; for Markdown, it instructs the model to "parse headings, lists, and other syntax tags and retain structural intent"; and for PDF source text, it requires "fixing typos and incorrect line breaks, and reorganizing into coherent paragraphs." This approach not only compensates for the shortcomings of pure rule-based methods in handling irregular formats but also better preserves the logical structure of the content while cleaning it, thus forming an efficient and adaptive format standardization preprocessing pipeline that combines rule classification with intelligent conversion.

[0148] (2) Perform paragraph correction on the original content.

[0149] The core objective of paragraph correction is to correct paragraph divisions in the original content that are physically flawed, transforming them into paragraphs with a structure that conforms to human reading habits and logical expression norms. This process primarily addresses two common issues: ① Paragraph mixing (a logical paragraph is incorrectly merged into a physical paragraph) When a single physical paragraph actually contains multiple independent logical paragraphs, it should be split. The main criteria for this determination include: Identification by common numbering: If multiple consecutive numbered items appear in the same paragraph (such as "1.… 2.… 3.…"), it is identified as a list structure, and the list is split at the corresponding numbering position.

[0150] Identification by punctuation marks: If a paragraph contains multiple complete sentences (usually ending with a period, question mark, exclamation mark, etc.), and the sentences are logically independent, they may be reasonably split at the end of the sentences to ensure that each paragraph carries a relatively complete semantic unit.

[0151] ② Paragraph fragmentation (a logical paragraph is incorrectly split into multiple physical paragraphs) When text that should belong to the same logical paragraph is split into multiple short, incomplete physical paragraphs, the system will merge them. The main criteria for this determination include: Identify by common numbering: If a number (such as "1.") is followed by empty or very short content, and is a separate paragraph, it may be merged with its subsequent paragraphs to form a complete list item.

[0152] Identification by punctuation and word segmentation: If a paragraph does not end with a punctuation mark (such as a period), and the word segmentation or content at the beginning of the next paragraph is grammatically and semantically closely connected to it, then the two paragraphs should be merged.

[0153] Identifying paragraphs by using leading spaces and indentation: If a paragraph begins with a space or has obvious indentation, but its content is not a new list item or title and is semantically consistent with the previous paragraph, it may be determined to be a continuation of the previous paragraph, and thus a merge operation will be performed.

[0154] Through the above corrections, the paragraph structure of the original content is standardized, ensuring that the text units on which subsequent AI model analysis, feature recognition, and format matching are based are logically correct and complete, thereby greatly improving the accuracy and reliability of the entire processing flow.

[0155] (3) Number and organize the original content.

[0156] The original content was numbered and organized to resolve the confusion caused by manual editing, copying and pasting, or format conversion. This ensures the standardization and consistency of numbering in style, hierarchy, and sequence, thus providing clear and reliable logical clues for subsequent hierarchical analysis and structured understanding. Specific corrections are as follows: 1. Corrected the numbering style error. The system standardizes character formatting errors that occur in sequential numbering. It has a built-in numbering style library that automatically identifies and corrects common style deviations. For example, it corrects full-width brackets "1)" to half-width brackets "1)", or converts Chinese commas "1、" to English periods "1.", ensuring that numbering symbols conform to the specifications.

[0157] 2. Eliminate duplicate numbering styles This addresses the issue of using the same numbering style for different levels of content. For example, if both level 1 and level 3 headings use the "1." style, appropriate styles will be assigned to different levels based on the content level and context, ensuring that the numbering style strictly corresponds to the level.

[0158] 3. Correct the disordered numbering hierarchy To prevent mismatches between content hierarchy and numbering style hierarchy, the system can automatically detect and adjust incorrect numbering levels based on preset or learned document specifications (such as official document standards: I. → (I) → 1. → (1)). For example, the "1." style, which is mistakenly used for a second-level heading, can be corrected to the style of the corresponding level, such as "(I)", according to its actual position in the structure.

[0159] 4. Correcting disordered serial numbers This system handles sequence errors and breaks in numbering continuity within the same level. It can detect and repair cases where serial numbers are not consecutive (e.g., 1., 3., 4.).

[0160] At the same time, this not only addresses the issue of discontinuous numbering within the original content, but also determines how the numbering sequence should be connected based on the context of the insertion position.

[0161] In one embodiment, numbering and organizing the original content includes: numbering and organizing the original content based on the original content and its context within the document. This numbering and organizing includes at least one of the following: adjusting the numbering style in the original content based on the numbering style of the corresponding level in the context content; and adjusting the numbering order in the original content based on the numbering order in the context content. For example: detecting the last sequence number of the corresponding level above to determine whether the newly inserted numbering sequence should "continue numbering" or "re-number". Repairing interrupted or discontinuous sequence numbers within the same level, and automatically restoring a correct and continuous sequence number based on the starting point determined by the context, ensuring that the newly inserted numbering is logically seamlessly connected to the context.

[0162] Through the above sorting, the chaotic numbering system in the original content was reconstructed into a standardized, continuous, and hierarchical ordered structure. This not only improved the professionalism and readability of the document, but also provided crucial standardized input for the AI ​​model to accurately identify content levels and establish structural relationships in subsequent steps.

[0163] (4) Clean up format interference factors in the original content.

[0164] This operation aims to systematically remove all unnecessary formatting characters from the original content that have no actual semantic meaning, are purely due to typesetting errors, or are introduced during conversion, ensuring that the text analyzed in subsequent processing is a clean and well-structured semantic carrier. Its core is to eliminate interference at the physical level, focusing on the logic and structure of the content itself. The cleanup is mainly carried out on two levels: 1. Character-level cleanup: Resolving abnormal character spacing This section primarily analyzes and corrects abnormal spacing. The system intelligently detects and removes invisible characters that affect normal text spacing. For example, it removes anomalies caused by formatting errors, such as words being separated by an equal number of spaces (e.g., "text example"), restoring a continuous and natural "text example". This ensures the correctness of word boundaries and the purity of the text flow.

[0165] 2. Paragraph-level cleanup: Resolving anomalies in text structure and spacing. This section primarily analyzes and corrects abnormal distributions of line breaks and blank lines. The system will identify and correct interfering content that affects paragraph structure and visual spacing. For example, it will remove abnormal situations caused by improper operation, such as extra blank lines or equal spacing between paragraphs (e.g., multiple consecutive line breaks between paragraphs), and standardize them to standard paragraph spacing. This ensures clear paragraph divisions and a neat layout.

[0166] Cleaning up formatting interference is a crucial "purification" step in the text preprocessing workflow. By meticulously removing physical noise between characters and paragraphs, it provides high-fidelity, low-noise text input for subsequent AI model analysis, feature recognition, and intelligent format matching, fundamentally improving the accuracy and reliability of the entire system's content understanding and structural processing.

[0167] Finally, in one embodiment, in response to inserting original content into the document, determining the structural features of the original content includes: in response to inserting original content into the document, if the original content is determined to be valid inserted content, determining the structural features of the inserted content. Wherein, determining that the original content is valid inserted content includes: determining that the original content is valid inserted content if it satisfies at least one of the following valid conditions: the original content is not empty and contains valid characters; the insertion position of the original content does not disrupt the integrity of existing paragraphs in the document.

[0168] This embodiment provides a prerequisite for the technical solution provided in this application, namely, intelligent formatting is performed only on valid insertion operations, thereby ensuring the system's response accuracy and operating efficiency.

[0169] Specifically, upon detecting an insertion action, the subsequent complex analysis process is not initiated immediately. Instead, the inserted "original content" and its operation are first validated for validity. Only content that meets at least one of the following conditions is considered valid inserted content: The content itself is valid: the inserted original content is not empty and contains valid characters (not just meaningless characters such as spaces and newlines). For example... Figure 5 As shown, inserting a pure space or an empty character will not trigger the process.

[0170] The insertion position is valid: the insertion position does not disrupt the integrity of existing paragraphs in the document. For example, Figure 5 As shown, inserting content in the middle of a paragraph is considered editing that paragraph, not creating a new paragraph. Insertions between paragraphs or at the beginning / end of a paragraph, however, are considered new content.

[0171] Furthermore, if the inserted content itself is empty or contains meaningless characters, it will be ignored without any formatting. If the insertion point disrupts the integrity of an existing paragraph (such as inserting in the middle of a paragraph), it is considered an editing operation on that paragraph, and its format should directly inherit the existing format of the paragraph in which it is inserted, without needing to initiate a separate reference paragraph lookup and format derivation process.

[0172] By applying this embodiment, unnecessary complex analysis can be avoided for meaningless or non-new paragraph editing operations, and unpredictable formatting behavior triggered by invalid or abnormal input can be prevented. This improves the intelligence of document processing while taking into account both response efficiency and behavior reliability.

[0173] Figure 6 This is a block diagram illustrating an embodiment of a document processing apparatus provided in this application. (See diagram below.) Figure 6 As shown, the device includes: The structural feature determination module 61 is used to determine the structural features of the original content in response to inserting the original content into the document; The format processing module 62 is used to process the original content according to its structural characteristics to obtain the target content.

[0174] In one possible implementation, the structural feature determination module 61 is specifically used for: The original content and at least one of the original content and its contextual content in the document are identified using an artificial intelligence model, and the structural features of the original content are obtained based on the model identification results.

[0175] In one possible implementation, the format processing module 62 includes: A reference interval determination unit is used to determine a format reference interval from the document based on the insertion position of the original content in the document and the structural features of the original content; The processing unit is used to perform format processing on the original content according to the format reference range to obtain the target content.

[0176] In one possible implementation, the reference interval determination unit includes: The first determining subunit is used to locate a reference paragraph from the document based on the element type of the adjacent paragraphs of the insertion position when the structural features of the original content indicate that the original content contains only body paragraphs, and to determine the located reference paragraph as a format reference range. The second determining subunit is used to extend the selection range to the text preceding and / or following the insertion position when the structural features of the original content indicate that the original content contains a title paragraph, so as to obtain an extended range as the format reference range.

[0177] In one possible implementation, the first determining subunit is specifically used for: Based on the element types of the adjacent preceding and / or following paragraphs at the insertion position, the reference paragraph is located from the document according to predefined rules.

[0178] In one possible implementation, the first determining subunit is specifically used for: If the adjacent paragraph following the insertion position is a body paragraph, the adjacent paragraph following the insertion position is determined as a reference paragraph; Alternatively, if the adjacent following paragraph at the insertion position is a heading paragraph, the reference paragraph is determined from the following paragraph of the adjacent following paragraph.

[0179] In one possible implementation, the first determining subunit determines the reference paragraph from the following text of the adjacent paragraph, including: The first paragraph of the main text following the insertion position is designated as the reference paragraph. Alternatively, the first heading paragraph with the deepest numbering level in the following text of the insertion location can be designated as the reference paragraph.

[0180] In one possible implementation, the first determining subunit is specifically used for: If the adjacent preceding paragraph at the insertion position is a body paragraph, the adjacent preceding paragraph is determined as a reference paragraph; or, in a continuous body paragraph containing the adjacent preceding paragraph, the body paragraph with the smallest initial indentation is determined as a reference paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a heading paragraph, a reference paragraph is determined based on the hierarchical structure of the preceding paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a special area, the nearest text paragraph following the insertion position shall be designated as the reference paragraph.

[0181] In one possible implementation, the first determining subunit determines the reference paragraph based on the hierarchical structure of the adjacent preceding paragraphs, including: Locate the next heading paragraph that is at the same level as the adjacent paragraph above the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, locate the next heading paragraph that is at the same level as the adjacent preceding paragraph of the insertion position and is the closest to the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, the nearest paragraph in the text preceding the insertion position can be designated as the reference paragraph. Alternatively, the nearest paragraph in the main text following the insertion position can be designated as the reference paragraph. Alternatively, the heading paragraph with the deepest numbering level that is closest to the insertion position can be identified as the reference paragraph.

[0182] In one possible implementation, the second determining subunit is specifically used for: If there is no content above the insertion position, the selection range is extended to the following position to obtain an extended range as the format reference range; Alternatively, if there is content preceding the insertion position, the selection range can be extended to the preceding text to obtain an extended interval as the format reference interval.

[0183] In one possible implementation, the processing unit includes: The target paragraph positioning subunit is used to locate the target paragraph from the format reference range based on the structural characteristics of the original content. The processing subunit is used to perform format processing on the original content according to the target paragraph to obtain the target content.

[0184] In one possible implementation, the target paragraph positioning subunit is specifically used for: For the heading paragraphs in the original content, locate the other heading paragraphs at the same level and closest to the original content from the format reference range, and determine the other heading paragraphs as the target paragraphs; and / or, For the body paragraphs in the original content, locate the other body paragraphs closest to the original content from the format reference range, and determine the other body paragraphs as target paragraphs; or, locate the other heading paragraphs at the same level and closest to the heading paragraph to which the original content belongs from the format reference range, and determine the first body paragraph below the other heading paragraph as target paragraphs.

[0185] In one possible implementation, the processing subunit is specifically used for: The original content is formatted using the paragraph format of the target paragraph to obtain the target content; Alternatively, the original content can be formatted using the character format of the target paragraph, and then the original content can be formatted according to a preset paragraph layout strategy to obtain the target content.

[0186] In one possible implementation, the device further includes: A format conversion module is used to identify the source format of the original content before determining the structural characteristics of the original content; Based on the source format, the original content undergoes format conversion processing.

[0187] In one possible implementation, the device further includes: The paragraph correction module is used to perform paragraph correction processing on the original content before determining the structural features of the original content.

[0188] In one possible implementation, the device further includes: The numbering and organization module is used to number and organize the original content before determining the structural characteristics of the original content.

[0189] In one possible implementation, the device further includes: The cleaning module is used to clean up format interference factors in the original content before determining the structural characteristics of the original content.

[0190] In one possible implementation, the structural feature determination module is specifically used for: In response to inserting original content into a document, if the original content is determined to be valid inserted content, the structural characteristics of the inserted content are determined.

[0191] like Figure 7 As shown in the figure, this application provides an electronic device, including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, when the processor 111 executes a program stored in the memory 113, it implements the document processing method provided in any of the foregoing method embodiments, including: In response to inserting original content into the document, the structural features of the original content are determined; Based on the structural characteristics of the original content, the original content is formatted to obtain the target content.

[0192] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the document processing method provided in any of the foregoing method embodiments.

[0193] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0194] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0195] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a," "an," and "described" as used herein may also mean including the plural forms. The terms "comprising," "including," "containing," and "having" are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a specific order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0196] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A document processing method, characterized in that, The method includes: In response to inserting original content into the document, the structural features of the original content are determined; Based on the structural characteristics of the original content, the original content is formatted to obtain the target content.

2. The method according to claim 1, characterized in that, The determination of the structural features of the original content includes: The original content and at least one of the original content and its contextual content in the document are identified using an artificial intelligence model, and the structural features of the original content are obtained based on the model identification results.

3. The method according to claim 1, characterized in that, The step of processing the original content according to its structural characteristics to obtain the target content includes: Based on the insertion position of the original content in the document and the structural characteristics of the original content, a format reference range is determined from the document; Based on the format reference range, the original content is formatted to obtain the target content.

4. The method according to claim 3, characterized in that, The step of determining a format reference range from the document based on the insertion position of the original content in the document and the structural characteristics of the original content includes: When the structural features of the original content indicate that the original content contains only body paragraphs, a reference paragraph is located from the document based on the element type of the adjacent paragraphs at the insertion position, and the located reference paragraph is determined as a format reference range. Alternatively, if the structural features of the original content indicate that the original content contains a heading paragraph, the selection range is extended to the text above and / or below the insertion position to obtain an extended range as the format reference range.

5. The method according to claim 4, characterized in that, The step of locating the reference paragraph from the document based on the element type of the adjacent paragraphs at the insertion position includes: Based on the element types of the adjacent preceding and / or following paragraphs at the insertion position, the reference paragraph is located from the document according to predefined rules.

6. The method according to claim 5, characterized in that, Based on the element type of the adjacent paragraphs at the insertion position, the reference paragraph is located from the document according to predefined rules, including: If the adjacent paragraph following the insertion position is a body paragraph, the adjacent paragraph following the insertion position is determined as a reference paragraph; Alternatively, if the adjacent following paragraph at the insertion position is a heading paragraph, the reference paragraph is determined from the following paragraph of the adjacent following paragraph.

7. The method according to claim 6, characterized in that, Determining the reference paragraph from the following paragraph of the adjacent paragraph includes: The first paragraph of the main text following the insertion position is designated as the reference paragraph. Alternatively, the first heading paragraph with the deepest numbering level in the following text of the insertion location can be designated as the reference paragraph.

8. The method according to claim 5, characterized in that, Based on the element type of the adjacent preceding paragraph at the insertion position, the reference paragraph is located from the document according to predefined rules, including: If the adjacent preceding paragraph at the insertion position is a body paragraph, the adjacent preceding paragraph is determined as a reference paragraph; or, in a continuous body paragraph containing the adjacent preceding paragraph, the body paragraph with the smallest initial indentation is determined as a reference paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a heading paragraph, a reference paragraph is determined based on the hierarchical structure of the preceding paragraph. Alternatively, if the preceding paragraph adjacent to the insertion position is a special area, the nearest text paragraph following the insertion position shall be designated as the reference paragraph.

9. The method according to claim 8, characterized in that, The process of determining the reference paragraph based on the hierarchical structure of the adjacent preceding paragraphs includes: Locate the next heading paragraph that is at the same level as the adjacent paragraph above the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, locate the next heading paragraph that is at the same level as the adjacent preceding paragraph of the insertion position and is the closest to the insertion position, and determine the first body paragraph below the next heading paragraph as the reference paragraph; Alternatively, the nearest paragraph in the text preceding the insertion position can be designated as the reference paragraph. Alternatively, the nearest paragraph in the main text following the insertion position can be designated as the reference paragraph. Alternatively, the heading paragraph with the deepest numbering level that is closest to the insertion position can be identified as the reference paragraph.

10. The method according to claim 4, characterized in that, The step of extending the selection range to the text preceding and / or following the insertion position to obtain an extended interval as the format reference interval includes: If there is no content above the insertion position, the selection range is extended to the following position to obtain an extended range as the format reference range; Alternatively, if there is content preceding the insertion position, the selection range can be extended to the preceding text to obtain an extended interval as the format reference interval.

11. The method according to claim 3, characterized in that, The step of processing the original content according to the format reference range to obtain the target content includes: Based on the structural characteristics of the original content, the target paragraph is located from the format reference range; The original content is formatted according to the target paragraph to obtain the target content.

12. The method according to claim 10, characterized in that, The step of locating the target paragraph from the format reference range based on the structural characteristics of the original content includes: For the heading paragraphs in the original content, locate the other heading paragraphs at the same level and closest to the original content from the format reference range, and determine the other heading paragraphs as the target paragraphs; and / or, For the body paragraphs in the original content, locate the other body paragraphs closest to the original content from the format reference range, and determine the other body paragraphs as target paragraphs; or, locate the other heading paragraphs at the same level and closest to the heading paragraph to which the original content belongs from the format reference range, and determine the first body paragraph below the other heading paragraph as target paragraphs.

13. The method according to claim 11, characterized in that, The step of formatting the original content according to the target paragraph to obtain the target content includes: The original content is formatted using the paragraph format of the target paragraph to obtain the target content; Alternatively, the original content can be formatted using the character format of the target paragraph, and then the original content can be formatted according to a preset paragraph layout strategy to obtain the target content.

14. The method according to claim 1, characterized in that, Before determining the structural features of the original content, the method further includes: Identify the source format of the original content; Based on the source format, the original content undergoes format conversion processing.

15. The method according to claim 1, characterized in that, Before determining the structural features of the original content, the method further includes: The original content is then subjected to paragraph correction processing.

16. The method according to claim 1, characterized in that, Before determining the structural features of the original content, the method further includes: The original content was numbered and organized.

17. The method according to claim 1, characterized in that, Before determining the structural features of the original content, the method further includes: The original content is cleaned of formatting interference factors.

18. The method according to claim 1, characterized in that, The response to inserting original content into the document, determining the structural features of the original content, includes: In response to inserting original content into a document, if the original content is determined to be valid inserted content, the structural characteristics of the inserted content are determined.

19. A document processing apparatus, characterized in that, The device includes: A structural feature determination module is used to determine the structural features of the original content in response to inserting the original content into the document; The format processing module is used to process the original content according to its structural characteristics to obtain the target content.

20. An electronic device, characterized in that, 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 according to any one of claims 1-18.

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