A template rapid application method based on intelligent creation
By automatically identifying and filling the creation area of the docx template using intelligent creation methods, the problem of user personalization needs and format preservation in traditional template application methods is solved, achieving fast and accurate content filling and improving document creation efficiency and quality.
Patent Information
- Application Number
- CN202510672339.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2026-11-24
AI Technical Summary
Traditional template application methods limit users' personalized needs, making it impossible to quickly and accurately fill in content without modifying the local template file format, and intelligent creation cannot accurately identify specific creative areas in the template.
The intelligent creation method parses the docx file, assigns a unique identifier, performs data cleaning and similarity matching, automatically identifies the creation area and fills in the content, ensuring that the template file format remains unchanged.
It increases user freedom and creation efficiency, maintains the consistency and integrity of template files, and ensures the accuracy of content filling and the preservation of formatting.
Smart Images

Figure CN123159293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method for quickly applying templates based on intelligent creation. Background Technology
[0002] In today's era of rapid digital and information technology development, document processing plays a vital role in various fields. Whether it is business office work, education and teaching, or scientific research and creation, a large number of documents need to be edited and generated.
[0003] However, the traditional method of using templates has many limitations. On the one hand, in terms of the flexibility of template use, many existing document processing systems require users to use their specified templates for creation, which greatly restricts users' personalized needs and freedom. Users may already have their own carefully designed template files, which may conform to their specific work style, industry standards, or brand image, but they cannot be used directly in these systems, forcing users to readjust to new templates, wasting a lot of time and energy.
[0004] On the other hand, formatting preservation during template application remains a pressing issue. Some systems modify the format of the user's local template file when filling in content, causing the loss of original styles, layouts, and formatting information. For example, fonts, font sizes, paragraph spacing, page setups, and other formatting elements may be altered. This imposes additional editing and formatting work on the user, impacting work efficiency and potentially damaging the overall aesthetics and professionalism of the document.
[0005] With the rapid development of artificial intelligence technology, intelligent content creation has gradually become a research hotspot in the field of document processing. Intelligent content creation utilizes advanced technologies such as natural language processing and machine learning to automatically understand user needs and generate text content that meets requirements. However, existing intelligent content creation systems, when combined with template application, still suffer from the problem of failing to accurately identify specific creative areas within the user's template, leading to incorrect content placement.
[0006] In conclusion, traditional template application methods and existing intelligent authoring systems, when combined with templates, fail to meet users' needs for quickly and accurately filling in content without modifying the local template file format. Therefore, it is necessary to propose a new method for rapid template application based on intelligent authoring to address these issues and improve the efficiency and quality of document creation.
[0007] Therefore, this invention proposes a method for quickly applying templates based on intelligent creation, which aims to automatically identify the areas in the file that need to be created and replaced without modifying the user's local template file format, and complete the text content filling. Summary of the Invention
[0008] The purpose of this invention is to solve the above-mentioned problems by proposing a method for quickly applying templates based on intelligent creation.
[0009] To achieve the above objectives, the present invention adopts the following technical solution:
[0010] A method for quickly applying templates based on intelligent creation, characterized by comprising:
[0011] S1: Obtain the docx template file, decompress it into a folder, and iterate through and identify it. Assign a unique identifier to each identified text or image content and record it.
[0012] S2: Extract the text content and clean the data, organizing it into a JSON-like key:value collection;
[0013] S3: Obtain user requirements and send them to the large model; obtain the text paragraphs returned by the large model; match them with the key-value pairs and filter out the values with the highest similarity.
[0014] S4: Perform text replacement and reconstruct the replaced compressed file into a docx file. Automatically start a docx reader or editor to open the generated docx file for verification.
[0015] Preferably, the folder in S1 contains multiple XML files and other resource files (such as images), and the step of assigning and recording a unique identifier includes:
[0016] Use a UUID (Universally Unique Identifier) generator to generate a unique identifier (ID) for each identified text or image content;
[0017] Based on the existing XML file, new nodes are added. For each identified content, a corresponding node is added to the XML file. The node includes a unique ID, a tag, location information, and other relevant information.
[0018] The unique ID serves as the unique identifier of the node, the tag serves as the attribute of the node or a child node, the location information includes the starting position of the content (such as page number, paragraph number, line number) and size (such as width, height), and the other relevant information includes content type (text, image), font information, and color.
[0019] Preferably, the data cleaning in S2 includes removing irrelevant characters (such as spaces, line breaks, and special symbols) from the text and performing standardization processing (such as case conversion and punctuation unification). The key-value pair refers to organizing the text content into the form of the key-value pair set according to the context of the text content or specific markers (such as placeholders), such as in a regular contract template: Party A's name: xxx (content to be filled in).
[0020] Preferably, the matching in S3 includes similarity matching, which uses cosine similarity to calculate the similarity between each candidate text returned by the large model and the value corresponding to each key in the set organized in step S2. The calculation formula is as follows: The value corresponding to the highest similarity is taken as the matching result.
[0021] Preferably, the text replacement is performed based on the text position in the XML file located by the node, and the replacement is to replace the value corresponding to the highest similarity with the corresponding position in the XML file.
[0022] Preferably, the server is configured with a module or program for performing the method of any one of claims 1 to 5, and the user terminal includes an interface for uploading template files, inputting data, and viewing output files.
[0023] Compared with the prior art, the advantages of the present invention are as follows:
[0024] This invention can parse user-uploaded documents, allowing users to create using their own templates without relying on specific template formats. This increases user freedom and personalization. Without modifying the user's local template file format, it uses natural language processing technology and machine learning algorithms to automatically identify the creation area and intelligently fill in the content, ensuring the consistency and integrity of the template file while improving the user's creation efficiency. Attached Figure Description
[0025] Figure 1 This is a flowchart of a method for quickly applying templates based on intelligent creation, as proposed in this invention.
[0026] Figure 2 This is a diagram illustrating the node structure for adding new nodes to an existing XML file. Detailed Implementation
[0027] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0028] A method for quickly applying templates based on intelligent creation, characterized by comprising:
[0029] S1: Obtain the docx template file, decompress it into a folder, and iterate through and identify it. Assign a unique identifier to each identified text or image content and record it.
[0030] S2: Extract the text content and clean the data, organizing it into a JSON-like key:value collection;
[0031] S3: Obtain user requirements and send them to the large model. Obtain the text paragraphs returned by the large model and match them with key-value pairs to filter out the values with the highest similarity.
[0032] S4: Perform text replacement and reconstruct the replaced compressed file into a docx file. Automatically start a docx reader or editor to open the generated docx file for verification.
[0033] The file decompression process involves calling python-docx or zipfile to extract docx files into folders. Traversal and identification are performed by the server's template parsing module, which iterates through the decompressed folders to identify XML files and resource files such as images. For XML files, an XML parser (such as a DOM parser or SAX parser) is used to parse the file content and identify the text. For image files, file type recognition techniques (such as checking file header information) are used to determine their format and related attributes.
[0034] Furthermore, the folder in S1 contains multiple XML files and other resource files (with a focus on XML files containing text content, such as document.xml, footerX.xml, headerX.xml, etc., and XML files that may contain image references or other resources). The steps for assigning unique identifiers and recording them include:
[0035] Use a UUID (Universally Unique Identifier) generator to generate a unique identifier (ID) for each identified text or image content;
[0036] Based on the existing XML file, new nodes are added. For each identified content, a corresponding node is added to the XML file. The node includes a unique ID, tag, location information, and other relevant information. The node structure is shown in the attached manual. Figure 2 As shown;
[0037] Among them, the unique ID serves as the unique identifier of the node, the tag serves as the attribute of the node or a child node, the position information includes the starting position of the content (such as page number, paragraph number, line number) and size (such as width, height), and other relevant information includes content type (text, image), font information, and color.
[0038] Data cleaning in S2 includes removing irrelevant characters from the text (such as spaces, newlines, and special symbols) and performing standardization processing (such as case conversion and punctuation unification). For example, regular expressions are used to remove redundant spaces and special symbols, and string processing functions are used to achieve case conversion and punctuation unification. Key-value pairs refer to organizing text content into a set of key-value pairs based on the context or specific markers (such as placeholders). For example, in a typical contract template: Party A's Name: xxx (content to be filled in), "Party A's Name" is used as the key, and "xxx (content to be filled in)" is used as the value.
[0039] Matching in S3 includes similarity matching. Similarity matching uses cosine similarity to calculate the similarity between each candidate text returned by the large model and the value corresponding to each key in the set compiled in step S2. The calculation formula is as follows: Here, A and B represent two text vectors, A⋅B represents the vector dot product, and ∥A∥ and ∥B∥ represent the vector moduli. After calculating the similarity between each candidate text and the corresponding value, the similarity scores are sorted by size, and the value with the highest similarity score is taken as the matching result.
[0040] The text replacement function locates the text position in the XML file based on the node information recorded in step S1, and replaces the value with the highest similarity value in the corresponding position in the XML file. For example, it finds the corresponding text node by its unique ID, and then uses a replacement function to replace the original text with the matching value.
[0041] Furthermore, the replaced XML file and other resource files are recompressed into a docx file. The server completes the file reconstruction by calling a docx file generation tool or library (such as the python-docx library in Python). After the file reconstruction is complete, the server automatically launches a docx reader or editor (such as Microsoft Word, WPS, etc.) to open the generated docx file for verification, checking whether the text replacement is correct and whether the document format meets the requirements.
[0042] A template-fast application system based on intelligent creation includes a server and a user terminal. The server is configured with a module or program for executing a template-fast application method based on intelligent creation, including:
[0043] Template parsing module: Responsible for decompressing, traversing, and identifying docx template files, as well as assigning unique identifiers to text and image content and recording relevant information. This module is implemented using file operations and XML parsing capabilities of programming languages (such as Java and Python).
[0044] The data cleaning module performs data cleaning and standardization on the extracted text content, using regular expressions and string processing functions to remove irrelevant characters, convert case, and unify punctuation.
[0045] Large Model Interaction Module: This module communicates with the large model, sending user requests and receiving returned text paragraphs. It achieves interaction with the large model by calling its API.
[0046] Text replacement module: Replaces text in an XML file based on the matching results, achieving accurate text replacement through node positioning and text replacement functions;
[0047] The file reconstruction module recompresses the replaced XML and resource files into docx files by calling relevant file compression and docx file generation tools or libraries to complete the file reconstruction.
[0048] User terminals include:
[0049] Upload Interface: Provides users with the function of uploading docx template files, and enables file upload operations through the file selection box or drag-and-drop area;
[0050] Input interface: Users can input specific information on this interface, such as text boxes, drop-down menus and other input controls for users to input or select relevant information;
[0051] Viewing interface: This interface displays the generated docx file. Users can view and download the generated document, and further edit and modify it.
[0052] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for quickly applying templates based on intelligent creation, characterized in that, include: S1: Obtain the docx template file, decompress it into a folder, and iterate through and identify it. Assign a unique identifier to each identified text or image content and record it. S2: Extract the text content and clean the data, organizing it into a JSON-like key:value collection; S3: Obtain user requirements and send them to the large model; obtain the text paragraphs returned by the large model; match them with the key-value pairs and filter out the values with the highest similarity. S4: Perform text replacement and reconstruct the replaced compressed file into a docx file. Automatically start a docx reader or editor to open the generated docx file for verification.
2. The method according to claim 1, characterized in that, The folder in S1 contains multiple XML files and other resource files (such as images), and the step of assigning and recording a unique identifier includes: Use a UUID (Universally Unique Identifier) generator to generate a unique identifier (ID) for each identified text or image content; Based on the existing XML file, new nodes are added. For each identified content, a corresponding node is added to the XML file. The node includes a unique ID, a tag, location information, and other relevant information. The unique ID serves as the unique identifier of the node, the tag serves as the attribute of the node or a child node, the location information includes the starting position of the content (such as page number, paragraph number, line number) and size (such as width, height), and the other relevant information includes content type (text, image), font information, and color.
3. The method according to claim 1, characterized in that, The data cleaning in S2 includes removing irrelevant characters (such as spaces, newlines, and special symbols) from the text and performing standardization processing (such as case conversion and punctuation unification). The key-value pair refers to organizing the text content into the form of a key-value pair set based on the context of the text content or specific markers (such as placeholders), such as in a regular contract template: Party A's name: xxx (content to be filled in).
4. The method according to claim 1, characterized in that, The matching in step S3 includes similarity matching, which uses cosine similarity to calculate the similarity between each candidate text returned by the large model and the value corresponding to each key in the set organized in step S2. The calculation formula is as follows: The value corresponding to the highest similarity is taken as the matching result.
5. The method according to any one of claims 1-4, characterized in that, The text replacement is performed based on the text position in the XML file located by the node. The replacement is to replace the value corresponding to the highest similarity with the corresponding position in the XML file.
6. A template-based rapid application system based on intelligent creation, comprising a server and a user terminal, characterized in that, The server is configured with a module or program for performing the method of any one of claims 1 to 5, and the user terminal includes an interface for uploading template files, inputting data, and viewing output files.
