Word document placeholder intelligent filling method and device, medium and product
By combining multi-strategy placeholder detection with artificial intelligence models, the problem of a single placeholder recognition strategy in Word documents is solved, enabling accurate filling and effectiveness evaluation of diverse placeholders, thus improving the accuracy and efficiency of document filling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- THE FIRST AFFILIATED HOSPITAL OF XIAMEN UNIV
- Filing Date
- 2025-12-25
- Publication Date
- 2026-04-24
AI Technical Summary
Existing Word document placeholder recognition strategies are simplistic, incompatible with diverse placeholder representations, and lack effectiveness evaluation, leading to inaccurate entries.
Placeholders for XML tree structure nodes are obtained through a multi-strategy placeholder detection algorithm, multi-dimensional confidence scores are calculated, text content is generated using an artificial intelligence model, and accurate filling is performed using an XPath positioning and replacement algorithm.
It enables accurate identification and effectiveness evaluation of diverse placeholders, improving the accuracy and efficiency of document filling and ensuring that the content matches the intended use of the placeholders.
Smart Images

Figure CN121413577B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of office automation technology, and in particular to a method for intelligently filling in placeholders in Word documents. Background Technology
[0002] In scenarios such as office automation, enterprise digital transformation, and batch document processing, Word documents serve as the core carrier and transmitter of information, and are widely used in various business scenarios such as report generation, contract drafting, and form filling. To improve document production efficiency and ensure content standardization, placeholders, as predefined information filling identifiers, are widely used in templated documents. Users can quickly complete personalized content supplementation based on placeholders, reducing the cost of repetitive editing.
[0003] However, existing Word document placeholder recognition strategies are simplistic, often only detecting single types of placeholders, such as paragraph underlines or fixed-format special characters, failing to accommodate diverse placeholder representations. Furthermore, current technologies lack a mechanism for evaluating placeholder validity. Since placeholders in different scenarios may contain ambiguous, redundant, or invalid identifiers, directly filling in content without validity screening can easily lead to mismatches between the entered content and the intended use of the placeholder, resulting in errors, redundant content, or missing key information. Summary of the Invention
[0004] The embodiments of the present invention provide a method, apparatus, medium and product for intelligently filling placeholders in Word documents, which aims to solve the problem that the existing placeholder recognition strategies are singular and cannot evaluate the effectiveness of placeholders, resulting in inaccurate placeholder filling.
[0005] To achieve the above objectives, in a first aspect, the present invention provides a method for intelligently filling in placeholders in Word documents, comprising the following steps:
[0006] The Word document is obtained through a predefined API, unpacked, and parsed to construct an XML tree structure; the nodes of the XML tree structure include paragraphs, tables, and text run nodes.
[0007] Placeholders for each XML tree structure node are obtained through a predetermined multi-strategy placeholder detection algorithm. The placeholders include paragraph underlines, blank table cells, paragraph semantic prompts, special tags, and / or XML attributes of text running nodes.
[0008] Calculate the multidimensional confidence score of the placeholder to obtain valid placeholders whose confidence scores exceed a preset confidence threshold;
[0009] Based on the contextual semantics of the effective placeholders, a predetermined artificial intelligence model is used to generate text filling content under predetermined constraints.
[0010] The valid placeholders are pre-located using XPath, and the text to be filled in is replaced with the valid placeholders using a predetermined replacement algorithm.
[0011] Furthermore, the multidimensional confidence score is calculated using the following formula:
[0012] ,
[0013] ,
[0014] In the formula, Indicates the first Multidimensional confidence score for each placeholder; Indicates the first The structural score of each placeholder The corresponding structural score weights; Indicates the first The semantic score of each placeholder. The corresponding semantic score weights; Indicates the first The format score for each placeholder. The corresponding format score weights.
[0015] Furthermore, the structural score is determined by XPath accuracy, parent context, and node depth; the semantic score is determined by keyword relevance, contextual coherence, and pattern strength; and the format score is determined by pattern clarity, length reasonableness, and format consistency.
[0016] Furthermore, by default, , , .
[0017] Furthermore, it also includes adjusting the weights of structure score, semantic score, and format score based on document type.
[0018] Furthermore, it also includes: converting placeholders into a unified standard structure that allows for positioning and replacement via pre-defined smart detectors and compatible adapters.
[0019] Furthermore, when XPath fails to locate a valid placeholder, it locates a valid placeholder by matching the text similarity after the run is completed; when text similarity matching fails to locate a valid placeholder, it locates a valid placeholder by matching the structure similarity.
[0020] Furthermore, the predetermined constraints include text length constraints, text style constraints, and text professionalism constraints.
[0021] Secondly, the present invention provides a Word document placeholder intelligent filling device, including a memory and a processor, wherein the memory stores at least one program, and the at least one program is executed by the processor to implement the Word document placeholder intelligent filling method as described above.
[0022] Thirdly, the present invention provides a computer-readable storage medium storing at least one program, which is executed by a processor to implement the intelligent filling method for Word document placeholders as described above.
[0023] Fourthly, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intelligent filling method for Word document placeholders as described above.
[0024] The above technical solution has the following technical effects:
[0025] This invention solves the problems of inaccurate placeholder filling caused by the existing technology's single placeholder recognition strategy and inability to evaluate placeholder validity. The method involves: obtaining placeholders for each XML tree structure node using a predefined API; assembling XML tree structures from paragraph underlines, blank table cells, paragraph semantic prompts, special tags, and / or XML attributes of text execution nodes; calculating multidimensional confidence scores for placeholders to identify valid placeholders with scores exceeding a predefined confidence threshold; generating text content under predefined constraints based on the contextual semantics of the valid placeholders using a predefined artificial intelligence model; locating valid placeholders using XPath; and replacing the text content with valid placeholders using a predefined replacement algorithm. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating a Word document placeholder intelligent filling method according to an embodiment of the present invention;
[0027] Figure 2 This is a diagram showing the XML tree structure and namespace distribution according to an embodiment of the present invention;
[0028] Figure 3 This is a schematic diagram of multi-strategy placeholder detection according to an embodiment of the present invention;
[0029] Figure 4 This is a schematic diagram of the structure of a Word document placeholder intelligent filling device according to an embodiment of the present invention. Detailed Implementation
[0030] To further illustrate the various embodiments, the present invention provides accompanying drawings. These drawings are part of the disclosure of the present invention, primarily used to illustrate the embodiments and to explain the operating principles of the embodiments in conjunction with the relevant descriptions in the specification. With reference to these drawings, those skilled in the art should be able to understand other possible implementations and the advantages of the present invention. Components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components.
[0031] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments.
[0032] Example 1:
[0033] Figure 1 This is a flowchart illustrating a Word document placeholder intelligent filling method according to an embodiment of the present invention, as shown below. Figure 1 As shown, this invention provides a method for intelligently filling placeholders in Word documents. Based on ZIP container-level verification and extraction, it performs Word XML multi-namespace parsing and structural modeling; it detects placeholders using multiple strategies such as underscore patterns, table blanks, semantic paragraphs, special tags, and XML attribute-driven methods, and performs multi-dimensional confidence scoring; it achieves accurate and traceable node positioning based on XPath, and uses text / structural similarity as a fallback in case of failure; it introduces a format preservation engine and a safe updater in the replacement stage to ensure the complete inheritance of format contexts such as w:rPr and w:pPr; it combines transaction management and integrity verification to achieve rollbackable batch safe replacement; finally, it generates Chinese content consistent with the context using a large language model, completing an end-to-end closed loop of recognition—positioning—replacement—verification. This significantly improves the reliability and usability of automatic filling in any Word document, zero-template, format-preserving, and batch-capable scenarios. The method includes the following steps:
[0034] The system retrieves Word documents via a predefined API, unpacks and parses the documents to construct an XML tree structure. The nodes of the XML tree structure include paragraphs, tables, and text run nodes. In one specific implementation, a standardized execution system is built around the .docx file preprocessing workflow, with the main control server and the ZIP container processing module working together to achieve security verification and structured modeling. The main control server receives business requests through API interfaces and is responsible for the entire chain coordination of task distribution, progress monitoring, and result output. It focuses on ZIP container-level verification and unpacking, and sets clear constraints: input file size ≤ 50MB, processing timeout threshold 90s, and memory usage limit 3GB, thus avoiding operational risks from a resource management perspective. In terms of technical operation, it first verifies the PK signature (identifier 0x50 0x4B) of the .docx file OPC package to confirm the container's legality, and then forcibly checks the existence of core files such as [Content_Types].xml, word / document.xml, and word / _rels / document.xml.rels. It adopts fault tolerance processing for optional files such as numbering.xml, balancing the rigor of verification with scenario adaptability, and records ZipMetrics indicators for process traceability.
[0035] In one specific implementation, multiple validation strategies are designed for document input and container validation, allowing users to flexibly choose according to document security level and processing speed requirements:
[0036] Verification strength levels: Fast verification mode only verifies the existence of PK signatures and core files such as [Content_Types].xml and word / document.xml, meeting the fast processing needs of ordinary scenarios; Deep verification mode adds Central Directory deep consistency verification, CRC data integrity verification and malicious file feature scanning on this basis, which is suitable for high-security documents involving sensitive information and eliminates the risk of malicious file injection and data tampering.
[0037] Performance optimization options: Supports enabling ZIP caching / buffer pool mechanism to cache frequently processed document templates or documents with repetitive formats, reducing the time spent on repeated verification and unpacking, and improving efficiency in batch processing scenarios.
[0038] Figure 2 This is an XML tree structure and namespace distribution diagram according to an embodiment of the present invention, such as... Figure 2As shown, Word XML namespace parsing and structural modeling parses key nodes under w:document / w:body, such as paragraphs (w:p), text operations (w:r), tables (w:tbl), cells (w:tc), and relationships (r:rels), constructing a node tree index containing paragraph numbers, table / cell paths, and operation split information. This operation transforms unstructured Word documents into structured data that can be accurately located and efficiently manipulated.
[0039] One specific implementation provides multi-dimensional parsing configurations for XML parsing and structure tree construction, adapting to parsing needs ranging from simple text to complex document formats:
[0040] Minimal parsing covers only core text nodes (w:document / w:p / w:r / w:t), focusing on plain text placeholder processing while balancing speed and lightweight design; standard parsing includes commonly used nodes such as tables (w:tbl), styles (w:styles), and numbering (w:numbering), meeting the needs of most office document processing; enhanced parsing extends to complex elements such as headers and footers, text boxes, and drawing objects, adapting to documents containing placeholders with special formats.
[0041] It supports two parsing methods: DOM (Document Object Model) parsing and SAX (Simple API for XML) streaming parsing. DOM parsing is suitable for small documents and allows random access to any node; SAX streaming parsing is suitable for large documents, as it does not require loading the entire document into memory, reducing memory usage and improving processing speed.
[0042] Figure 3 This is a schematic diagram of a multi-strategy placeholder detection according to an embodiment of the present invention, as shown below. Figure 3 As shown, placeholders for each XML tree structure node are obtained using a predefined multi-strategy placeholder detection algorithm. In one specific implementation, the placeholders include:
[0043] Paragraph underlines, such as “___”, “Name: _”, “Year / Month / Day”, etc., are checked for reasonable length and semantic prompts on the left.
[0044] For blank cells in a table, distinguish between empty blank cells and formatted blank cells by combining the semantics of the header / adjacent cells; handle merged cells;
[0045] Paragraph semantic prompts are identified, such as "fill in / to be filled in / please enter", and matched with subsequent empty paragraphs or placeholder segments;
[0046] Special markers are used to identify [fill in], [pending fill], {placeholder}, etc.; nested cases are handled.
[0047] The XML attributes of the text execution node define specific placeholder styles using w:rPr / w:pPr, style name, and tag class.
[0048] One specific implementation provides a flexible strategy combination mechanism for placeholder detection, enabling accurate detection of placeholders of different types and in different scenarios:
[0049] It supports selecting subsets or supersets from five core detection strategies: underline detection, blank table cell detection, semantic paragraph detection, special marker detection, and attribute-driven detection, to adapt to the presentation of placeholders in different documents. It also supports adding extended detection strategies such as bookmarks, content controls, annotations, and field codes (MERGEFIELD) to cover more personalized placeholder scenarios.
[0050] The system uses fixed weights to calculate confidence scores by default, while also supporting adaptive adjustment of the weight allocation of structure, semantics, and format scores based on document type, such as contracts, application materials, and resumes, to improve the accuracy of placeholder detection in specific scenarios.
[0051] Calculate the multidimensional confidence score of placeholders to obtain valid placeholders whose confidence scores exceed a preset confidence threshold;
[0052] In one specific implementation, based on extensive experience in document processing, the multidimensional confidence score of this technical solution is calculated using the following formula:
[0053]
[0054]
[0055] In the formula, Indicates the first Multidimensional confidence score for each placeholder; Indicates the first The structural score of each placeholder The corresponding structural score weights; Indicates the first The semantic score of each placeholder. The corresponding semantic score weights; Indicates the first The format score for each placeholder. The corresponding format score weights.
[0056] In one specific implementation, based on extensive experience in document processing, the default weight is set to... The weight allocation scheme has been experimentally verified to achieve good placeholder recognition results under different document types.
[0057] In one specific implementation, based on extensive experience in document processing, the factors influencing the structure score in the multidimensional confidence score of this technical solution include: XPath specificity, used to influence the structure score based on the XPath path complexity of placeholders; specifically, normalization calculation based on the number of nodes in the XPath path, the calculation formula is as follows: ,in (XPath Path Complexity) represents the normalized XPath specificity score. The number of nodes in the XPath path, by The function ensures the score does not exceed 1.0, and this factor accounts for 50% of the structure score; the parent context is used to influence the structure score based on the position of the placeholder in the document; specifically, it is calculated by normalizing the character position of the placeholder in the XML document (position.start(position start point)), with higher scores for later positions, and this factor accounts for 30% of the structure score; node depth is used to influence the structure score based on the hierarchical depth of the placeholder type in the XML structure; specifically, it is based on a preset type-score mapping relationship (i.e., different placeholder types correspond to different fixed score values, where table_ The placeholder type scores as follows: cell (table cell) 0.9 points, semantic_label 0.7 points, and other types 0.6 points. Placeholder types with deeper hierarchies and higher levels of structure score higher, accounting for 20% of the structure score. Factors influencing the semantic score include keyword relevance, which affects the semantic score based on the number of form keywords contained in the placeholder content. Specifically, based on a pre-defined list of form keywords (including name, position, title, company, phone number, address, postal code, email, etc.), the number of matching keywords in the placeholder content is counted, and the calculation formula is: Match Count. ,in (Keyword Score) represents the keyword matching score. Each matched keyword adds 0.2 points, with a base score of 0.3 points. This factor accounts for 40% of the semantic score. Contextual coherence is used to determine the reasonableness of a placeholder based on its content length. Specifically, based on a preset length-score mapping, content lengths of 0-2 words receive 0.9 points, 2-10 words receive 0.8 points, 10-30 words receive 0.6 points, and more than 30 words receive 0.4 points. Shorter content is more likely to be a true placeholder rather than main text. This factor accounts for 30% of the semantic score. The strength of the placeholder is used to influence the semantic score based on the detection method and content features of the placeholder. Specifically, based on the preset detection method-score mapping relationship, the smart_table detection method with content containing special tags or less than 3 characters in length gets 0.9 points, other smart_table detection methods get 0.7 points, the semantic_empty detection method gets 0.8 points, and other detection methods get 0.6 points. This factor accounts for 30% of the semantic score. The format score includes: Pattern Clarity, which affects the format score based on the format pattern characteristics of the placeholders; specifically, based on a preset pattern-score mapping relationship, content containing square brackets "[" and "]" receives 0.95 points (explicit marking), content containing parentheses "(" and ")" receives 0.8 points (explanatory text), content conforming to the title numbering pattern receives 0.9 points, content containing colons receives 0.8 points, content less than 3 characters receives 0.9 points, content consisting of only short Chinese words receives 0.7 points, and other cases receive 0.5 points. This factor accounts for 40% of the format score; Length Reasonableness, which determines whether the placeholder length matches the expected content to be filled in, such as empty content receiving 1.0 point, and content not exceeding 2 characters receiving 0.5 points. The format score is calculated as follows: 0.95 points for shorter content (no more than 8 characters), 0.85 points for content no more than 20 characters, 0.7 points for content no more than 20 characters, and 0.5 points for content longer than 20 characters. Shorter content better conforms to placeholder characteristics, and this factor accounts for 30% of the format score. Format consistency affects the format score based on placeholder type and content characteristics. Specifically, based on a preset type-consistency mapping relationship, table_cell type placeholders receive 0.8 points, semantic_label type placeholders containing a colon receive 0.9 points, otherwise 0.7 points, and other types receive 0.6 points. This factor accounts for 30% of the format score. All the above scores are calculated based on pre-defined rules and mapping relationships.
[0058] The following example illustrates the complete calculation process of multi-dimensional confidence scores:
[0059] Suppose a table cell placeholder is detected, with the following basic information: placeholder type is table_cell; placeholder content is "[empty cell]" (5 characters); the previous cell content is "Project Manager's Name"; the placeholder's character position in the XML document. ,in (Starting point of position) indicates the starting point of the character position of the placeholder in the XML document; the XPath path of the placeholder is / / w:tbl[2] / w:tr[3] / w:tc[4], which contains 3 valid nodes (w:tbl, w:tr, w:tc).
[0060] First, calculate the structure score: (1) XPath specificity score: The path contains 3 nodes, calculate Division, of which (XPath Path Complexity) represents the complexity metric of the number of nodes in an XPath path. This factor has a weight of 50% and contributes [value missing]. (2) Parent context score: placeholder position ,in (Position Start Point) represents the starting point of the placeholder character position in the XML document, calculated as follows: Division, of which (Position Score) represents the score calculated based on the placeholder position. (Maximum expected number of characters in the document) is a preset normalization constant with a default value of 100,000. This constant is set based on extensive document processing experience and is used to differentiate between multiple similar placeholders in a document to avoid identical scores. The final score is... The score is calculated as follows: 0.3 is the preset minimum position score threshold to ensure that the position score is not too low. This factor has a weight of 30% and a contribution value of [missing value]. (3) Node depth score: The placeholder type is table_cell, the mapping score is 0.9, the weight of this factor is 20%, and the contribution value is Total score for structure point.
[0061] Next, the semantic score is calculated: (1) Keyword relevance score: The placeholder content "[empty cell]" itself does not contain the keyword, but the content of the previous cell "project leader's name" contains the keyword "name". The number of matches is 1. Division, of which (Keyword Score) represents the keyword matching score. This factor has a weight of 40% and a contribution value of [missing value]. (2) Contextual coherence score: The content length is 5 characters. According to the length-score mapping relationship, 2-10 characters correspond to 0.8 points. The weight of this factor is 30%, and its contribution value is (3) Pattern strength score: The detection method is smart_table (intelligent table detection method) and the content contains square brackets "[", the score is 0.9 points, the weight of this factor is 30%, and the contribution value is Semantic total score point.
[0062] Finally, the format score was calculated: (1) Pattern clarity score: The content contains square brackets "[" and "]", which, according to the pattern-score mapping relationship, gives 0.95 points. The weight of this factor is 40%, and its contribution value is (2) Length Reasonableness Score: The content length is 5 characters. According to the length-score mapping relationship, a length of no more than 8 characters corresponds to 0.85 points. The weight of this factor is 30%, and the contribution value is (3) Format consistency score: The placeholder type is table_cell (table cell), and it gets 0.8 points according to the preset type-consistency mapping relationship. The weight of this factor is 30%, and its contribution value is Total score in format point.
[0063] In summary, the final multidimensional confidence score for this placeholder is calculated as follows:
[0064] ,
[0065] ,
[0066] =0.68×0.40+0.71×0.35+0.875×0.25≈0.74,
[0067] The final confidence score of this placeholder The confidence score is 0.74, which exceeds the commonly used confidence threshold (such as 0.6 or 0.7). Therefore, it is determined to be a valid placeholder and can proceed to the subsequent content generation and filling process.
[0068] In one specific implementation, placeholders are converted into a unified standard structure that allows for location and replacement through a predefined intelligent detector and compatible adapter. In another specific implementation, multi-source detection results are converted into a standard structure that can be directly used by the locator and replacer, ensuring field completeness, type stability, and traceability. For example, the input original field {id, strategy, location, match, context, score} is converted into a unified standardized field {id, xpath, originalText, semantics, confidence, detection_strategy} through explicit field mapping and specification: id is retained as a unique identifier string such as "tbl_3_tc_2_p_1"; strategy is mapped to the enumerated type detection_strategy, which includes five types of placeholders such as underscores and tables; location is converted into an XPath string with a w: prefix that supports the WordprocessingML namespace; match is integrated into the original text originalText after merging across w:r; context is expanded into a semantics object containing information such as category, chapter, and paragraph context; and score is normalized to a confidence value in the 0-1 range with three decimal places. At the same time, strict quality verification rules are established: 6 core fields are required, and the data type and format requirements of each field are clearly defined, such as XPath non-empty with w: prefix. Normalization processing is performed on confidence, xpath, and originalText. It supports filling in missing locations through structure hash and is compatible with filling null in missing context fields. In terms of performance, linear mapping is required to be O(n), single-line processing ≤2ms, and thousand-line processing ≤2s to ensure efficient adaptation.
[0069] Using a pre-defined AI model such as DeepSeekClient, text completion content is generated based on the contextual semantics of valid placeholders, under pre-defined constraints such as length, style, and professionalism. In one specific implementation, the trigger condition is successful location and semantic category determination, or when AI completion is required by a rule. The generation strategy needs to combine semantic category, context, and document type, such as application forms and contracts, while controlling concurrent requests to ≤5, single request timeout to 45s, and two retries on failure (backoff 0.5s / 1.5s). The content is customized according to output parameters such as length and formality. After generation, placeholders and redundant affixes need to be removed, and XML escaping is performed. In terms of quality control, the content length will be verified, non-compliant symbols will be cleaned, and the format will be verified using domain-specific blacklists and whitelists, such as the format of personal names / organization names. For multiple failures, template-based rules such as name = 2-4 Chinese characters, postal code = 6 digits will be used for rollback. When calling the DeepSeek model (deepseek-v3-1-250821), you need to specify the headers, distinguish between failure types such as timeout and 429 and adapt them to the corresponding strategies, and record log information such as taskId and time consumption.
[0070] The system uses XPath to locate valid placeholders and then employs a predefined replacement algorithm to replace the text content with the valid placeholders.
[0071] In one specific implementation, when XPath cannot locate a valid placeholder (e.g., due to changes in node attributes), a valid placeholder is located using text similarity matching based on the merged text obtained from the `run` function. When the above strategies fail (e.g., when the text is modified), a valid placeholder is located using structural similarity matching, such as comparing the path pattern of parent / sibling nodes with their position indices. In another specific implementation, text similarity matching based on the merged text obtained from the `run` function concatenates consecutive `w:r` / `w:t` characters within candidate paragraphs / cells sequentially, preserving basic spaces and punctuation, and removing soft returns (`w:br`). Text similarity is calculated using methods such as Jaro-Winkler or normalized edit distance; a threshold ≥ 0.82 is considered an acceptable match. The final fallback structural similarity matching rule determines XML structural similarity by using node path signatures and multi-dimensional feature weighted scoring: First, a "hierarchical path + location" signature is generated for the target node, such as specifying the hierarchy and sequence number of tables, rows, cells, and paragraphs. Then, features such as parent node type, sibling node position, style ID, table header association, and adjacent keywords are combined to calculate a comprehensive score with a weight of 0.5 for path, 0.2 for style, and 0.3 for adjacent semantics. When the score is ≥0.78, it is considered a successful match, serving as a final guarantee after the previous positioning strategy fails.
[0072] In one specific implementation, a predetermined replacement algorithm is used to replace the text content with valid placeholders. The core is to complete the text writing without destroying the WordprocessingML structure, and to fully preserve w:rPr (run style), w:pPr (paragraph style), and table cell attributes throughout the process. The specific process is as follows: First, three types of key formats are collected using FormatKeeper, including run styles such as font, font size, color, bold, italic, underline, and Chinese font families; paragraph styles such as alignment, paragraph spacing, indentation, numbering / outline level, etc.; and cell attributes such as borders, fill, vertical alignment, and cell merging. The format rules are processed according to the principle of "default inheritance and minimal modification". Then, the XmlSafeUpdater replacement strategy is selected according to the scenario. Prioritize updating only the w:t text content when the original structure is intact. If the original run is broken or contains non-retainable tags or irregular nesting, rebuild the compliant node subtree. If there are no replaceable nodes in blank paragraphs or empty cells, create a new structured fragment and apply the format. The replacement process employs a transaction mechanism. After integrity verification including XML syntax validation, document readability checks, and layout snapshot comparison, it is committed upon success and rolled back in case of verification failure or replacement anomalies. Acceptance requires meeting four criteria: replacement success rate ≥ 95% with no structural damage, visible styles consistent with the original text, 100% correct Chinese encoding, and the document must be able to be opened and edited normally. Chinese encoding is uniformly UTF-8 with special characters handled.
[0073] In one specific implementation, the TransactionManager manages the transaction process according to the sequence of "start → record operation → perform replacement → validate → commit / rollback" to ensure the atomicity of the operation; then, the IntegrityValidator performs comprehensive validation from four dimensions: XML structure validity, format consistency, coding integrity, and document readability to avoid document corruption after replacement.
[0074] ZipRepackage restores the validated XML and other components into a compressed package conforming to the OPC standard, i.e., a valid .docx file. Finally, it outputs a new document, generates a download link and an operation processing report, completing the entire process loop.
[0075] One specific implementation focuses on deployment flexibility and environmental adaptability, offering three deployment modes and service architecture options to cover the IT architecture needs of different users, including: a cloud-based SaaS mode suitable for small and medium-sized enterprises and individual users, which does not require local server setup and can achieve functions through network calls; a local private deployment to meet the needs of large enterprises, government agencies, and other scenarios with extremely high requirements for data privacy and security, where all data storage and processing are completed on the local intranet; and a hybrid cloud deployment that combines the advantages of both, with core data retained locally and non-sensitive business processes deployed to the cloud, balancing security and operational efficiency.
[0076] Flexible service architecture switching: Supports K8s microservice decoupled architecture, which splits the system into multiple independent microservice modules. It can be elastically scaled and deployed on demand according to business needs, improving system stability and maintainability. At the same time, it is compatible with monolithic service mode, which is suitable for small deployment environments with limited resources and simple business scenarios, reducing deployment and operation and maintenance costs.
[0077] Edge node localization support: For scenarios requiring network isolation or low latency, such as hospitals and government intranets, it supports the deployment of local inference modules on edge nodes, without relying on cloud computing power, to achieve a localized closed loop for document processing, ensuring data security and processing efficiency.
[0078] Example 2:
[0079] Figure 4 This is a schematic diagram of the intelligent Word document placeholder filling device according to an embodiment of the present invention, as shown below. Figure 4 As shown, the device includes a processor 401, a memory 402, a bus 403, and a computer program stored in the memory 402 and executable on the processor 401. The processor 401 includes one or more processing cores. The memory 402 is connected to the processor 401 via the bus 403. The memory 402 is used to store program instructions. When the processor executes the computer program, it implements the steps in the above-described method embodiment of Embodiment 1 of the present invention.
[0080] Furthermore, as an executable solution, the Word document placeholder intelligent filling device can be a computer unit, which can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer unit may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above-described computer unit structure is merely an example and does not constitute a limitation on the computer unit. It may include more or fewer components, or combine certain components, or use different components. For example, the computer unit may also include input / output devices, network access devices, buses, etc., and this embodiment of the invention does not limit this.
[0081] Furthermore, as an executable solution, the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The processor is the control center of the computer unit, connecting various parts of the entire computer unit via various interfaces and lines.
[0082] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the computer unit by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital card (SD card), flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0083] Example 3:
[0084] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the methods described in the embodiments of the present invention.
[0085] If the modules / units integrated in the computer unit are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution media, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0086] Example 4:
[0087] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intelligent filling method for Word document placeholders as described above.
[0088] Although the invention has been specifically shown and described in conjunction with preferred embodiments, those skilled in the art should understand that various changes in form and detail may be made to the invention without departing from the spirit and scope of the invention as defined in the appended claims, all of which shall be within the scope of protection of the invention.
Claims
1. A method for intelligently filling in placeholders in a Word document, characterized in that, Includes the following steps: The Word document is retrieved via a predefined API, unpacked, and parsed to construct an XML tree structure; the nodes of the XML tree structure include paragraph, table, and text execution nodes. Placeholders for each XML tree structure node are obtained through a predetermined multi-strategy placeholder detection algorithm. The placeholders include paragraph underlines, blank table cells, paragraph semantic prompts, special tags, and / or XML attributes of text running nodes. Calculate the multidimensional confidence score of the placeholder to obtain valid placeholders whose confidence scores exceed a preset confidence threshold; Based on the contextual semantics of the effective placeholders, a predetermined artificial intelligence model is used to generate text filling content under predetermined constraints. The valid placeholders are pre-located using XPath, and the text to be filled in is replaced with the valid placeholders using a predetermined replacement algorithm; The multidimensional confidence score is calculated using the following formula: , , In the formula, Indicates the first Multidimensional confidence score for each placeholder; Indicates the first The structural score of each placeholder The corresponding structural score weights; Indicates the first The semantic score of each placeholder. The corresponding semantic score weights; Indicates the first The format score for each placeholder. The corresponding format score weights; The structural score is determined by XPath specificity, parent context, and node depth; the semantic score is determined by keyword relevance, contextual coherence, and pattern strength; and the format score is determined by pattern clarity, length reasonableness, and format consistency. The XPath specificity is used to obtain a specificity score based on the XPath path complexity of the placeholder, and is calculated using the following formula: , In the formula, This represents the normalized XPath specificity score; This represents the number of nodes in the Path. This represents a function that takes the minimum value. The parent context is calculated using the character position of the placeholder in the XML document, with higher scores for later positions. The node depth score is obtained based on a preset mapping relationship between placeholder type and node depth score. The keyword relevance is based on a preset list of form keywords, and the keyword relevance score is obtained by counting the number of keywords in the placeholder content that match the list of form keywords. The context coherence score is obtained through a preset mapping relationship between placeholder length and context coherence score. The pattern strength score is obtained through a mapping relationship between a preset detection method and the pattern strength score. The detection method includes an intelligent table detection method and a semantic empty paragraph detection method. The pattern clarity score is obtained through a mapping relationship between a preset placeholder format pattern and the pattern clarity score. The format patterns include square brackets, title numbering patterns, parentheses, colons, and plain Chinese short words. The reasonableness of the length is determined based on the degree of matching between the placeholder length and the expected content to be filled in; The format consistency score is obtained based on a preset mapping relationship between placeholder types and content features and the format consistency score.
2. The intelligent filling method for Word document placeholders according to claim 1, characterized in that, By default, , , .
3. The intelligent filling method for Word document placeholders according to claim 1, characterized in that, Also includes: The placeholders are converted into a uniform standard structure that allows for positioning and replacement through pre-defined smart detectors and compatible adapters; The intelligent detector is used to output placeholder detection results; The compatibility adapter is used to generate unified standardized fields by mapping and converting the placeholder detection results to a standard.
4. The intelligent filling method for Word document placeholders according to claim 1, characterized in that, When XPath fails to locate a valid placeholder, it locates a valid placeholder by performing text similarity matching based on the merged nodes of the text; when text similarity matching fails to locate a valid placeholder, it locates a valid placeholder by performing structural similarity matching.
5. The intelligent filling method for Word document placeholders according to claim 1, characterized in that, The predetermined constraints include text length constraints, text style constraints, and text professionalism constraints.
6. The intelligent filling method for Word document placeholders according to claim 1, characterized in that, Also includes: The weights of structure score, semantic score, and format score are adjusted based on document type.
7. A Word document placeholder intelligent filling device, characterized in that, The method includes a memory and a processor, wherein the memory stores at least one program, which is executed by the processor to implement the Word document placeholder intelligent filling method as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The storage medium stores at least one program segment, which is executed by a processor to implement the Word document placeholder intelligent filling method as described in any one of claims 1-6.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the Word document placeholder intelligent filling method as described in any one of claims 1-6.
Citation Information
Patent Citations
Classroom activity courseware making method and device, storage medium and electronic equipment
CN116069850A
Scientific and technological strategy report generation method and system based on generative artificial intelligence
CN118798150A