An AI-based word document intelligent analysis and structured storage method

By performing non-destructive logical text segment reorganization and dual-component semantic fingerprint construction on Word documents, the problems of long template generation time and poor adaptability in existing technologies are solved, and the automatic identification and accurate storage of dynamic fields are realized, thereby improving the level of intelligence in document processing.

CN122366447APending Publication Date: 2026-07-10星汇智云科技(江苏)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
星汇智云科技(江苏)有限公司
Filing Date
2026-04-07
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing Word document template generation technology relies on manual configuration, which is time-consuming and has low accuracy. It cannot recognize dynamic fields, and existing difference tools cannot locate differences within table cells and lack semantic naming, resulting in poor template generation adaptability and low performance.

Method used

By non-destructively reorganizing logical text segments of Word document logical container nodes, constructing and running merge mappings, generating field boundary records, extracting dual-component semantic fingerprints, realizing format-preserving bookmark injection, and supporting cross-template semantic retrieval.

Benefits of technology

It improves the accuracy and stability of document parsing, realizes automatic recognition and precise boundary division of dynamic fields, enhances the intelligence level of document structured storage, and supports consistent recognition and retrieval of cross-template fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122366447A_ABST
    Figure CN122366447A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of document semantic analysis, in particular to a Word document intelligent analysis and structured storage method based on AI. The application performs format attribute consistency analysis on a Word document running node, executes non-destructive logical text segment recombination and constructs a running merging mapping, and establishes a character offset mapping. Then, minimum difference substring detection is performed on different documents through double-layer alignment of a container path intersection and a text segment serial number, and field boundary records are generated. A double-component semantic fingerprint is constructed by extracting a field forward fixed label text hash and combining a field content mode, and a consistent bookmark name is generated through a fingerprint registration table. A target node is positioned according to a running node operation range, format reservation bookmark injection is executed, semantic fingerprints and injection results are written into a database, and field structured storage is realized. On the premise of maintaining the integrity of the original document structure and format, the accuracy and automation degree of document field recognition and structured processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of document semantic parsing technology, specifically to an AI-based intelligent parsing and structured storage method for Word documents. Background Technology

[0002] In the field of document information processing technology, template generation and structured storage based on Word format documents are important means to improve document processing efficiency and are widely used in scenarios such as test reports and technical documents that require frequent generation of documents in the same format.

[0003] Existing template generation technologies suffer from the following main problems: First, traditional methods rely on manual text-by-text document analysis and manual configuration of bookmarks and placeholders, which is time-consuming and has low accuracy in identifying dynamic fields. They also lack objective basis for judging accidental fixed content versus inevitable dynamic fields. Second, while existing document difference comparison tools (such as general comparison software based on the Myers difference algorithm) can identify text-level differences, they only output visual results at the paragraph level, failing to locate specific differences within table cells or generate machine-readable structured location markers, making them unsuitable for direct template generation. Third, existing document template technologies based on rule bases or XML template matching rely on manually predefined rules, resulting in poor adaptability and difficulty in handling personalized changes in client document formats. Fourth, existing technologies fail to synchronously combine and store difference identification results with precise coordinate information within the document (paragraph index, table row and column coordinates), requiring a second full-document matching during the bookmark backfilling stage, introducing errors and inefficient performance. Fifth, for identified difference fields, existing technologies lack an automatic recommendation mechanism for semantic naming; bookmark naming relies on manual judgment, resulting in poor standardization and consistency.

[0004] Therefore, existing technologies have significant shortcomings in intelligent parsing of Word documents, automatic recognition of dynamic fields, structured location storage, and efficient template generation. An intelligent method that can integrate multi-document comparison, AI semantic analysis, and structured storage is needed to solve these problems.

[0005] To address this, an AI-based intelligent parsing and structured storage method for Word documents is proposed. Summary of the Invention

[0006] The purpose of this invention is to provide an AI-based intelligent parsing and structured storage method for Word documents. This method involves non-destructive logical text segment reorganization of running nodes and the construction of a running merge mapping, performing cross-document difference detection to generate field boundary records, constructing a dual-component semantic fingerprint and generating a bookmark name, and injecting format-preserving bookmarks based on the operation range of the running nodes, thereby achieving structured storage of fields and cross-template semantic retrieval.

[0007] To achieve the above objectives, the present invention provides the following technical solution: An AI-based intelligent parsing and structured storage method for Word documents includes: For adjacent running nodes in the logical container node of a Word document, non-destructive logical text segment reorganization is performed based on the consistency of format attributes, and a running merge mapping that records the character offset relationship of each original running node is constructed. Using the logical text segment and the run merge mapping as input, cross-document minimum difference substring detection is performed through double-layer alignment of container path intersection and text segment sequence number to generate field boundary records carrying the operation range of the run node; Using the field boundary record as input, extract the forward fixed label text hash and field content pattern enumeration to construct a two-component semantic fingerprint, query the fingerprint registry to obtain or generate a consistent book signature name, and form a labeled field boundary record; Using the boundary records of the labeled fields as input, the target node is directly located and the format-preserving bookmark injection is performed based on the operation range of the running node it carries. The injection result and the two-component semantic fingerprint are written into the database, and the semantic fingerprint is used as an index to support cross-template semantic retrieval and consistency auditing.

[0008] The preferred non-destructive logical text segment reorganization process is as follows: The document undergoes revision acceptance preprocessing to eliminate interference from revision insertion and deletion nodes on format attribute determination, resulting in a document structure containing only formal content; for each logical container node in the document, the current logical text segment state is initialized; all direct child running nodes of the container node are traversed, and all tag names and attribute values ​​of the format attribute child nodes are extracted for each running node, concatenated into a standardized format signature in lexicographical order of tag names; the current running node's format signature is compared with the recorded format signature using string equality: if they match, the current node text is appended to the merged text, and the node reference is appended to the list; if they do not match, the current logical text segment is encapsulated and written to an ordered list, and a new logical text segment is initialized with the current node; after all traversals are completed, the last logical text segment is encapsulated; the original running nodes are not modified throughout the process, and the reorganization result exists in parallel with the original document structure as an independent data structure.

[0009] Preferably, the construction process of the run-merge mapping is as follows: a two-dimensional key is formed by the container node structure path and the sequence number of the logical text segment within the container; during the appending of a run node to each logical text segment, the node reference of the run node, the string length of the merged text before appending as the character starting offset, and the current node text length as the character occupied length are recorded synchronously, and the three constitute an offset entry appended to the ordered list of run nodes corresponding to the logical text segment; when the logical text segment is encapsulated, its corresponding ordered list of run nodes and the offset information of each entry are synchronously written into the run-merge mapping, forming a complete mapping relationship from any character offset range in the merged text of the logical text segment to the corresponding original run node and the local offset range within the node; the run-merge mapping is constructed independently for the two documents.

[0010] Preferably, the generation process of the field boundary record is as follows: Construct container index tables with container node structure paths as keys and ordered lists of logical text segments within the container as values, using ordered lists of logical text segments from both documents respectively; take the intersection of the key sets of the container index tables of the two documents, and perform a comparison on container nodes whose structural positions are completely corresponding; for each container path in the intersection, extract the list of logical text segments from both documents within that container, align them one by one with the same sequence number, and compare whether the two merged text segments are equal; for segments with unequal text, scan character by character from the beginning of the merged text to determine the position of the first different character as the difference start offset, and scan character by character from the end of each text to determine the difference end offset; query the merge mapping based on the offset interval, traverse the list of running nodes corresponding to the logical text segments, find all running nodes where the character offset interval overlaps with the difference interval, and calculate the affected local start offset and local end offset within each node; encapsulate the container structure path, logical text segment sequence number, difference start offset, difference end offset on both sides, difference substring text on both sides of the two documents, and the list of operation ranges of the running nodes into a field boundary record.

[0011] Preferably, the construction process of the dual-component semantic fingerprint is as follows: First component construction: using the container path to which the field boundary record belongs as the key, scan backwards from the corresponding segment number of the current field boundary record in the list of logical text segments of the container; skip logical text segments with empty merged text; for each non-empty text segment, determine whether its merged text appears in the original text set of all current field boundary records: those that do not appear are fixed label texts, which are normalized and their hash values ​​are calculated as the first component; those that appear are dynamic field texts, and the scanning continues forward; if no fixed label is found at the beginning of the container, the hash value of the last three-level path string of the container structure path is calculated and used as the first component to replace it; The second component is constructed by sequentially performing pattern checks on the original text of the field. The check order is as follows: whether it conforms to the date format of year-month-day separation; whether it consists of uppercase letters, numbers, and hyphens and its length does not exceed the preset limit; whether it contains entries from the enterprise nature keyword dictionary; whether it consists of pure Chinese characters and its length does not exceed the preset limit; whether it consists of pure numbers and decimal points; the first matching format type is used as the enumeration value of the second component; if none of them match, the enumeration value is a general text type. The hash value of the first component and the enumeration value of the second component are concatenated with a separator to form a semantic fingerprint string.

[0012] Preferably, the method for obtaining the labeled field boundary record is as follows: using the semantic fingerprint string as the key, query the persistent fingerprint registry; if a record is found, directly retrieve the corresponding bookmark name; if not found, query the predefined naming rule table according to the second component enumeration value, and generate the bookmark name according to the naming rule corresponding to the enumeration value; after generation, write the semantic fingerprint and bookmark name into a new record and perform a persistence operation, so that it can be reused for querying any document; write the bookmark name and semantic fingerprint string into the corresponding field boundary record to form the labeled field boundary record; the labeled field boundary record adds a bookmark name field and a semantic fingerprint field to the original field boundary record, while the remaining fields, including the container structure path, logical text segment number, and running node operation range list, remain unchanged.

[0013] Preferably, the specific positioning process for directly locating the target node based on the operation range of the running node is as follows: Read the list of operation ranges of the running nodes from the boundary record of the annotation field, arranged according to the structural order of the nodes in the document; jump directly to the target running node based on the node reference, without performing any full-text string traversal on the document text; obtain the text length of the target running node, and determine whether the local start offset is zero and whether the local end offset is equal to the text length minus one: if the condition is true, the entire text of the node is different content, and the node text value is directly modified to the bookmark name, without any modification to the node format attributes; if the condition is not true, the text of the node is only partially different content, and the node is split in place into three adjacent nodes: a prefix node, a bookmark placeholder node, and a suffix node; each of the three nodes holds a deep copy of the original node format attributes, and each node is assigned a unique node identifier to prevent the document application from automatically merging adjacent nodes; process all running node operation entries of the current annotation field boundary record sequentially according to the positioning and injection logic.

[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention achieves non-destructive logical text segment reorganization by determining the consistency of format attributes between adjacent running nodes in the logical container nodes of a Word document. During the reorganization process, a running merge mapping is simultaneously constructed, establishing a precise character offset mapping relationship between the logical text segments and the original running nodes. This method avoids directly modifying or destroying the original document structure, achieving structured analysis of text content while ensuring the complete preservation of document format, node hierarchy, and layout information. This invention can establish reversible mapping relationships at the character level, enabling subsequent field location and processing to accurately trace back to the original running node, thereby significantly improving the accuracy, stability, and structural consistency of document parsing.

[0015] 2. This invention employs a two-layer alignment mechanism combining container path intersection and text segment sequence numbers to perform cross-document minimum difference substring detection on logical text segments between different Word documents. Combined with run-merge mapping, it precisely traces the difference character range back to the corresponding running node and its local offset range, thereby forming a field boundary record containing the operation range of the running node. This method can automatically identify and accurately delineate the boundaries of dynamic field content while maintaining the semantic consistency of the document structure. This invention maintains stable recognition capabilities even with complex layouts, node splits, or format differences, effectively improving the accuracy and automation of field extraction.

[0016] 3. This invention constructs the first component of a semantic fingerprint by extracting the preceding fixed tag text of a field and calculating its hash value. Simultaneously, it generates a second component by combining field content pattern enumeration, forming a stable dual-component semantic fingerprint. A unified bookmark naming and reuse system is achieved through a fingerprint registry. Subsequently, the target node is directly located based on the operation range of the running node in the field boundary record, and format-preserving bookmark injection is performed, ensuring that structured fields form stable identifiers within the document. This mechanism not only achieves semantically consistent field identification across different templates or versions of documents but also supports cross-template field retrieval, version consistency auditing, and data tracking management through semantic fingerprints as a database index, thereby significantly improving the intelligence level of document structured storage and management. Attached Figure Description

[0017] Figure 1 A schematic diagram of the process for an AI-based intelligent parsing and structured storage method for Word documents provided by this invention; Figure 2 This is a schematic diagram of the two-component semantic fingerprint construction process provided by the present invention; Figure 3 A schematic diagram of the precise injection process with format preservation provided by the present invention. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.

[0019] Example 1: In enterprise document management scenarios, Word documents of the same business type (such as inspection reports and contract texts) often contain a fixed document structure framework and dynamic fields that change with the business instance (such as customer name, inspection date, and product model). The Word documents involved in this embodiment follow the Office Open XML standard. Here, "run node" corresponds to the run element in the document structure, which is the smallest unit for storing continuous, consistently formatted text; logical container nodes refer to paragraph nodes and table cell nodes. Because the Word application may forcibly insert run node splitting points into semantically continuous text during user editing due to character-level format changes, spell check annotations, or revision history generation, a visually complete piece of text is distributed across multiple adjacent run nodes in the underlying structure.

[0020] This fragmentation phenomenon brings two types of problems: First, when comparing across documents, the same semantic content may produce a large number of false differences with inconsistent node boundaries due to different fragmentation methods, which interferes with the recognition of real dynamic fields. Second, when filling bookmarks, if string search and replacement is performed on the difference text across multiple running nodes, the nodes must be merged. However, the merging operation inevitably loses the original independent character format attributes of each running node, which destroys the visual consistency of the document.

[0021] This embodiment uses two Word documents of the same business type (hereinafter referred to as Document A and Document B, respectively) as input to fully realize the entire process from fragmentation processing at the runtime node, cross-document difference identification, semantic field naming, and format-preserving bookmark injection into the database for hierarchical storage.

[0022] Please see Figure 1This invention provides an AI-based intelligent parsing and structured storage method for Word documents. The technical solution is as follows: For adjacent running nodes in the logical container nodes of a Word document, non-destructive logical text segment reorganization is performed based on format attribute consistency to construct a running merge mapping that records the character offset relationship of each original running node; using the logical text segment and running merge mapping as input, cross-document minimum difference substring detection is performed through container path intersection and text segment sequence number double-layer alignment to generate field boundary records carrying the operation range of running nodes; using the field boundary records as input, forward fixed label text hash and field content pattern enumeration are extracted to construct a dual-component semantic fingerprint, and a fingerprint registry is queried to obtain or generate a consistent bookmark name to form an annotated field boundary record; using the annotated field boundary record as input, the target node is directly located based on the running node operation range it carries and format-preserving bookmark injection is performed. The injection result and dual-component semantic fingerprint are written to the database, and the semantic fingerprint is used as an index to support cross-template semantic retrieval and consistency auditing. This solution solves the recognition error problem caused by the fragmentation of Word's underlying nodes by establishing a dual-track mapping between the logical layer and the structural layer.

[0023] Furthermore, the specific process of the non-destructive logical text segment reorganization is as follows: Perform revision acceptance preprocessing on the document to eliminate the interference of revision insertion nodes and revision deletion nodes on the determination of format attributes, and obtain a document structure containing only formal content; For each logical container node in the document, initialize the current logical text segment state, including the current merged text, the current format signature, and the current running node reference list, all of which are set to empty; Iterate through all direct child running nodes of the container node, extract all tag names and attribute values ​​of the format attribute child nodes of each running node, and concatenate them into a standardized format signature in lexicographical order of tag names; The current running node's format signature is compared with the recorded format signature execution string: if they match, the current node's text is appended to the merged text and the node reference is appended to the list; if they do not match, the current logical text segment is encapsulated and written to an ordered list, and a new logical text segment is initialized with the current node. After all traversals are completed, the final logical text segment is encapsulated. The original running node is not modified in any way during the entire process. The reorganization result exists in parallel with the original document structure as an independent data structure. The independent data structure includes: merged text, format signature, path of the container structure, and segment number.

[0024] Furthermore, the process of constructing the merged mapping is executed synchronously with the process of reorganizing the logical text segments, specifically as follows: A two-dimensional key is formed by the container node structure path and the sequence number of the logical text segment within the container; During the process of appending a running node to each logical text segment, the node reference of the running node, the string length of the merged text before appending as the character starting offset, and the current node text length as the character occupied length are recorded synchronously. These three are combined to form an offset entry to be appended to the ordered list of running nodes corresponding to the logical text segment. When a logical text segment is encapsulated, its corresponding ordered list of running nodes and the offset information of each entry are synchronously written into the running merge mapping, forming a complete mapping relationship from any character offset range in the merged text of the logical text segment to the corresponding original running node and the local offset range within the node. The run merge mapping constructs two documents independently and outputs them to the field boundary record generation step.

[0025] The run-merge mapping is implemented using a two-layer nested data structure: the outer layer uses the container node structure path string as the key, and the path is formed by concatenating the node types and indices of each level from the document root node to the target container node, with nodes separated by forward slashes; the inner layer uses the indices of logical text segments within the container as the key, and the values ​​are arrays of run node offset entries.

[0026] Each offset entry contains three fields: node reference object, character start offset, and character length. The node reference object is a direct memory reference to the running node object in the underlying document object model. The system arranges the entries according to the order in which the running nodes appear in the document, ensuring that the offsets are consistent in ascending order. Given a target character range, the system iterates through the array and determines the overlap between the target range and the node range (i.e., the target start is less than or equal to the node end and the target end is greater than or equal to the node start) to achieve precise backtracking of the original node.

[0027] Specifically, before performing any comparison operations, the document processing library is first invoked to perform revision acceptance preprocessing on both documents. This step removes the wrapping layers of all revision insertion nodes and revision deletion nodes in the underlying document structure, leaving only the final confirmed official text content in the document structure.

[0028] For each logical container node in the document (including paragraph nodes and table cell nodes), traverse all its direct child execution nodes. For each execution node, extract all format sub-elements from its format attribute child nodes. The extracted format attributes include, but are not limited to: font name, font size (points), bold, italic, color value, underline type, and strikethrough. Concatenate the tag names and corresponding attribute values ​​of all the above format sub-elements in lexicographical order (i.e., alphabetical order of tag names) to form a standardized format signature string, ensuring that the format signature is unique for the same set of format attributes.

[0029] For each logical container node, initialize the current logical text segment state, including the current merged text (initially an empty string), the current format signature (initially empty), the current running node reference list (initially an empty list), and the current logical text segment's sequence number within the container (initially zero).

[0030] Traverse all direct child nodes of the container node one by one. For each node, calculate its format signature and then perform a string equality comparison with the format signature already recorded in the current logical text segment: If the two signatures are completely identical, the text content of the current running node is appended to the end of the current merged text, and a running offset record is appended to the running merge mapping entry corresponding to the current logical text segment. If the two signatures differ by even a single character, the currently accumulated logical text segment is encapsulated into an independent logical text segment object and written to the container's ordered list of logical text segments. Simultaneously, the entry for that logical text segment in the run-merge mapping is updated, the sequence number is incremented, and then a new logical text segment state is initialized with the current running node's format signature, text content, and node reference. After all running nodes have been traversed, the last logical text segment object is encapsulated and written to the ordered list.

[0031] Each logical text segment object contains the following fields: merged text (the complete string of text from all running nodes in this segment), format signature (inherited from the format signature of the first running node in this segment), the structure path of the container (a path string of hierarchical type and sequence number from the document root node to the current container node, such as "document root → second row of table → third cell"), and the sequence number of this segment within the container.

[0032] The non-destructive principle is specifically manifested in the following: throughout the entire process, the original execution nodes are not modified, moved, or deleted in the underlying document structure. Logical text segment objects and execution merge mappings are represented by independent memory data structures, existing in parallel with the original document's underlying structure, forming a dual-track parallel structure of logical content and original structure.

[0033] The run-merge mapping uses a two-dimensional key consisting of "container node structure path and logical text segment number" as an index. Each two-dimensional key records an ordered list of the original run nodes contained in the logical text segment. Each run offset record in the list contains the following three items: the node reference of the run node (a direct reference to the specific run node object in the underlying structure), the starting character position of the run node text in the merged text string of the logical text segment (i.e., the number of existing characters in the merged text before appending the run node text), and the character length of the run node text.

[0034] Together, they form a complete mapping from any character position in the merged text to the original running node: given a character offset range in the merged text, by traversing the list of running offset records and judging the interval overlap relationship, we can accurately find all the original running nodes that carry the content of the character range and the local character offset range within each node.

[0035] Perform the above process on document A to generate an ordered list of logical text segments A and a merge mapping A; perform the same process on document B to generate an ordered list of logical text segments B and a merge mapping B.

[0036] Furthermore, the process for generating the field boundary record is as follows: Construct container index tables with the container node structure path as the key and the ordered list of logical text segments within the container as the value, using ordered lists of logical text segments from the two documents respectively; Take the intersection of the key sets of the two document container index tables, and perform the comparison only on container nodes whose structural positions are completely corresponding. The container path intersection data is used as the input for subsequent alignment operations. For each container path within the intersection, extract the list of logical text segments of the two documents within that container, align them one by one with the same sequence number, and compare whether the two merged text segments are equal; for segment pairs with unequal text, scan character by character from the beginning of the merged text to determine the position of the first different character as the starting offset of the difference, and scan character by character from the end of each text to determine the ending offset of the difference respectively. Based on the offset range query, run the merge mapping, traverse the list of running nodes corresponding to the logical text segment, find all running nodes where the character offset range and the difference range overlap, and calculate the affected local start offset and local end offset within each node. The container structure path, logical text segment sequence number, difference start offset, difference end offset on both sides, difference substring text on both document sides, and list of operation ranges of running nodes are encapsulated as field boundary records. Each entry in the list of operation ranges of running nodes includes a node reference, local start offset and local end offset within the node.

[0037] Specifically, taking the ordered lists of logical text segments of the two documents as input, we traverse the logical text segment objects of each document, and append the logical text segment objects belonging to the container node structure path to the ordered list of the corresponding key, thereby constructing container index table A and container index table B respectively.

[0038] The intersection of the two container index table key sets is used to form a common container path set. Subsequent comparison operations are performed only on container paths within this set. Container paths that exist only in a single document (i.e., parts where the number of paragraphs or table structures are not completely consistent between the two documents) are recorded as structural difference containers, skipped from subsequent processing, and written to the difference log to ensure that the comparison operation only targets container nodes that are physically identical.

[0039] For each container path in the common container path set, retrieve the list of logical text segments corresponding to that path from container index table A and container index table B, respectively. Take the shorter of the two lists as the upper limit of traversal, and align logical text segment pairs with the same index one by one starting from zero. Compare whether the merged text of the two pairs is completely equal; if they are equal, skip them; otherwise, perform the minimum difference substring detection.

[0040] For pairs of text with unequal values, the first distinct character is determined by scanning character by character from the beginning. If either side is an empty string, the starting offset of the difference is set to 0, and the ending offset of the difference on the non-empty side is set to the total length of the text on that side minus 1. The scanning process uses Unicode code points for equality comparison, distinguishing between uppercase and lowercase letters. To prevent scanning out of bounds, the lower boundary of the scan from the end forward is locked as the starting offset of the difference, ensuring that the starting offset is always less than or equal to the ending offset.

[0041] The specific process of minimum difference substring detection: Let the merged text from Party A and the merged text from Party B be two strings to be compared. Starting from the beginning of each string, compare them character by character sequentially until the first different character is found. This position is the starting offset of the difference, denoted as the common prefix length. If no different characters are found after scanning to the end of a certain string, the starting offset of the difference is equal to the total number of characters in the shorter string.

[0042] After determining the starting offset of the difference, compare each character sequentially forward from the end of the merged text of Party A and Party B, finding the position where the first character in the direction of their respective ends is different. Add one to this position to obtain the ending offset of the difference for each (referred to as ending offset A for Party A and ending offset B for Party B). During forward scanning, use the starting offset of the difference as the lower boundary to ensure that the suffix scan does not exceed the determined prefix boundary.

[0043] Therefore, the substring between the starting offset of the difference and the ending offset of the difference in the merged text of Party A is the original text of the field that has changed in document A in this logical text segment; the corresponding substring of Party B is the field comparison text; the prefix (before the starting offset of the difference) and the suffix (after the ending offset of the difference) of both are completely the same in the two documents, which are fixed text and are not treated as fields.

[0044] For each pair of differing logical text segments, query the run-merge mapping A using the container structure path and the logical text segment sequence number as a two-dimensional key, and retrieve the run offset record list corresponding to that logical text segment. For each run offset record in the list, determine whether its character interval (from the start position to the start position plus length minus one) overlaps with the differing character interval (from the start offset of the differing character interval to the end offset of the differing character interval A). The specific method for determining overlap is: if the two intervals have a common part in character position (i.e., at least one character in the character interval of a certain run record is located in the differing character interval), then it is considered that there is an overlap.

[0045] For each overlapping running offset record, calculate the local character range affected within the current running node: the local starting offset is the larger of the difference between the starting offset of the difference and the starting position of the current running, and zero; the local ending offset is the smaller of the difference between the ending offset of the difference and the starting position of the current running, and the character length of the current running minus one.

[0046] The node references, local start offsets, and local end offsets of all running offset records that meet the overlap condition are summarized into a running node operation range list, arranged in the order in which the running nodes appear in the document.

[0047] Encapsulate the following information into a single field boundary record: container structure path, logical text segment number, difference start offset, difference end offset of Party A, difference end offset of Party B, original text of Party A's field, comparison text of Party B's field, and list of operation ranges for running nodes.

[0048] In cases where two documents within the same container path have unequal numbers of logical text segments, for the redundant logical text segment of the document with a larger number that exceeds the length of the shorter list, first attempt to merge the text with the adjacent logical text segments that have the same format signature, and then re-perform the comparison; if the merged text still cannot match the logical text segment at the corresponding position in the other party's list, then mark the container path as a structurally abnormal container, record it in the difference log, and skip subsequent processing.

[0049] After all container paths have been processed, all field boundary records are sorted in ascending order by container structure path lexicographical order and logical text segment number to form an ordered list of field boundary records.

[0050] Furthermore, the construction process of the dual-component semantic fingerprint refers to Figure 2 The steps are as follows: First component construction: Using the container path to which the field boundary record belongs as the key, scan backwards from the segment number corresponding to the current field boundary record in the list of logical text segments of that container; skip logical text segments with empty merged text; for each non-empty text segment, determine whether its merged text appears in the original text set of all current field boundary records: those that do not appear are fixed label text, which are normalized (removing leading and trailing whitespace characters, removing trailing colon-type separators, and unifying full-width characters to half-width characters) and their hash value is calculated as the first component; those that appear are dynamic field text, and continue scanning forward; if no fixed label is found at the beginning of the container, the hash value of the last three-level path string of the container structure path is calculated and used as the first component to replace it; The second component is constructed as follows: Pattern checks are performed sequentially on the original text of the field, in the following order: whether it conforms to a date format with year, month, and day separated; whether it consists of uppercase letters, numbers, and hyphens and its length does not exceed a preset limit (model format); whether it contains entries from a dictionary of enterprise-related keywords (enterprise name format); whether it consists of only Chinese characters and its length does not exceed a preset limit (person's name format); and whether it consists of only numbers and decimal points (numeric format). The first matching format type is used as the enumeration value for the second component; if none of them match, the enumeration value is a general text type. The hash value of the first component and the enumeration value of the second component are concatenated with a separator to form a semantic fingerprint string.

[0051] Furthermore, the method for obtaining the boundary records of the labeled field is as follows: Using the semantic fingerprint string as the key, query the persistent fingerprint registry; If a record already exists, the corresponding bookmark name is retrieved directly. The bookmark name is a consistent name that has been established for the semantic fingerprint in the historical document processing. If no match is found, the predefined naming rule table is queried based on the second component enumeration value, and a book name is generated according to the naming rule corresponding to the enumeration value. After generation, the semantic fingerprint and the book name are combined into a new record and written into the fingerprint registry and a persistence operation is performed for reuse in subsequent document processing queries. The persistence operation ensures that the same semantic fingerprint returns the same book name in any document processing sequence. Write the book name and semantic fingerprint string into the corresponding field boundary record to form the labeled field boundary record; the labeled field boundary record adds the book name field and semantic fingerprint field to the original field boundary record, while the remaining fields, including the container structure path, logical text segment number, and running node operation range list, remain unchanged.

[0052] Specifically, for each field boundary record in the ordered list of field boundary records, the original text of the Party A field of all field boundary records is first summarized into a fixed set, which serves as the query basis for dynamic field text determination.

[0053] Using the container structure path of the current field boundary record as the key, retrieve the list of logical text segments for that container from container index table A. Starting with the logical text segment index of the current field boundary record minus one, scan the logical text segments one by one in reverse order (i.e., in the direction of decreasing index): If the merged text of the currently scanned logical text segment is an empty string, skip it and continue forward; If the merged text is not empty, determine whether it exists in the above dynamic field text set: if it exists (i.e. the text has changed in both documents and is itself a dynamic field), skip it and continue forward; if it does not exist (i.e. the text is exactly the same in both documents and belongs to fixed tag text), perform normalization processing on the text and calculate the hash value as the first component.

[0054] The specific steps of standardization processing are as follows: The first step is to remove leading and trailing full-width and half-width spaces from the string; The second step is to remove full-width colons, half-width colons, full-width separators, and other common delimiter suffixes from the end of the string. The third step is to replace full-width Arabic numerals (i.e., double-byte numeric characters) in the string with the corresponding half-width Arabic numerals, and replace full-width Latin letters with the corresponding half-width Latin letters.

[0055] The purpose of normalization is to eliminate hash value inconsistencies caused by differences in typesetting habits (such as mixing full-width and half-width colons, and the presence or absence of leading and trailing spaces) of the same tag text, ensuring that tag text with the same semantics produces the same first component. The SHA-256 algorithm is used to calculate the digest of the forward fixed tag text. The number of truncated bytes is dynamically set according to the size of the fingerprint registry: 8 bytes are truncated when the number of records is less than 10,000; 10 bytes are truncated when the number of records is between 10,000 and 100,000; and 12 bytes are truncated when the number of records is greater than 100,000. The data is then converted to a hexadecimal string to reduce the probability of hash collisions.

[0056] Calculate a deterministic hash value for the normalized string (using a fixed algorithm, the same input will inevitably produce the same output). Take the first few bytes of the hash result as the hexadecimal string representation as the first component value. The principle for selecting the byte truncation length is: within the scale of the fingerprint registry maintained by the current document processing system, ensure that the probability of hash collisions caused by truncation is lower than an acceptable level.

[0057] If no fixed tag text that meets the conditions is found after scanning forward from the sequence number of the current field boundary record to the starting position of the container list, the last three-level path in the container structure path string (i.e., the path segment after the last three level separators) is taken as the replacement string, and the same hash calculation is performed on it, and the hash result is used as the first component replacement value. The selection of the last three-level path is based on the fact that the end level of the structure path can best reflect the local position characteristics of the current field in the physical structure of the document, and has reproducible distinguishability for fields at the same structural position in the same type of document.

[0058] For the original text of the Party A field recorded at the current field boundary, perform pattern determination in the following fixed priority order, and take the first hit pattern type as the second component enumeration value. Perform pattern matching on the original text of the field. Date determination uses a regular expression that includes the year, month, date, and their corresponding separators, and performs numerical range verification; model determination requires that the beginning and end are letters or numbers, hyphens are allowed in the middle, and the length is defaulted to within 20 characters; enterprise name determination is achieved by querying the preset keyword dictionary substring; person name determination is limited to 2 to 4 Chinese characters or interpuncts; numerical determination only matches combinations of numbers and decimal points.

[0059] Specifically: The first priority is date format determination: check whether the text is composed of four-digit year numbers, separators (one of the hyphen, Chinese character "year", or slash), one to two-digit month numbers, the same type of separator, and one to two-digit date numbers in sequence. If it meets the requirements, the enumeration value is the date type.

[0060] The second priority is model format determination: check whether the text is composed of uppercase Latin letters, Arabic numerals, and hyphens, and the total number of characters does not exceed the preset upper limit. The determination method of this upper limit is: according to the number of characters in the longest model code in the enterprise's existing product model database, it is configured and written into the system parameter file by the system administrator during the initialization phase, and this parameter value is read and used during the processing flow; if the enterprise has no historical model data, the number of characters corresponding to the industry common specification (such as the regulations on the length of product numbers in national standards) is used as the initial configuration value, and it can be adjusted according to the actual data later. If it meets the requirements, the enumeration value is the model type.

[0061] The third priority is enterprise name format determination: query whether the text contains any of the entries in the preset enterprise nature keyword dictionary. The preset content of the dictionary includes but is not limited to: company, group, limited liability, limited company, stock, research institute, research center. If a hit is found, the enumeration value is the enterprise name type. The content of the dictionary is sorted and entered by professionals according to the common enterprise naming norms in the target business area during system initialization, and subsequent entries can be added or deleted through the system management interface.

[0062] The fourth priority is name format determination: checking whether the text consists entirely of Chinese characters and whether the total number of characters does not exceed the preset upper limit. This upper limit is determined by configuring it based on the reasonable character range for names in the target business scenario (referencing the national standard for the length of Chinese names), with a typical value of no more than five Chinese characters. The configuration method is the same as the model format upper limit. If it meets the requirements, the enumerated value is the name type.

[0063] The fifth priority is numeric format determination: check if the text consists only of Arabic numerals and decimal points. If it does, the enumerated value is a numeric type.

[0064] If none of the above five conditions are met, the enumeration value is of the general text type.

[0065] The reason for using a fixed order among the priorities is that: the date format has the most stringent characteristics and does not overlap with other formats; the combination of uppercase letters and numbers in the model format does not overlap with the Chinese character characteristics of company names and personal names; the determination of company names relies on a dictionary rather than a character set, and there is a possibility of overlap with the constraints of full Chinese characters in personal names (in very rare cases, some short company names may conform to the personal name format), so company names take precedence over personal names.

[0066] The first component value and the second component enumeration value are concatenated with an underscore as the separator to form a semantic fingerprint string.

[0067] The system queries the persistent fingerprint registry using the semantic fingerprint string as the key. The fingerprint registry is a persistent key-value store, and its storage medium can be an independent table in a relational database or a disk-serialized hash file, depending on the deployment environment. The system queries the persistent registry based on the fingerprint; if no match is found, a bookmark name containing double curly braces (e.g., "{{test date}}") is generated according to a predefined naming table. For numeric or general types, the bookmark name is automatically appended with the first 6 hexadecimal characters of the first component as a suffix to ensure naming uniqueness within the same enumeration type.

[0068] If a corresponding record exists in the fingerprint registry, the registered bookmark name is retrieved directly. If it does not exist, a bookmark name is generated from the following naming rules table based on the second component enumeration value: date type corresponds to "Test Date" (enclosed in a predefined format character), model type corresponds to "Product Model", company name type corresponds to "Customer Name", person name type corresponds to "Engineer Name", numeric type corresponds to "Test Data", and the first few digits of the semantic fingerprint hash are appended as a distinguishing suffix (the selection principle for the number of suffix digits is the same as the first component hash truncation principle), and general text type corresponds to "Field" with the same hash suffix appended. After generating the bookmark name, the semantic fingerprint string and the bookmark name are written as a new record to the fingerprint registry and a persistent write operation (such as database insertion or update) is performed to ensure that subsequent batch queries of the same fingerprint in any document processing return the exact same bookmark name.

[0069] The fingerprint registry persistence consistency guarantee mechanism: The fingerprint registry write operation is executed in a transaction. If the same semantic fingerprint is triggered to write at the same time in a concurrent processing scenario, the unique key constraint of the database ensures that only one record is successfully written. Subsequent queries will return the same bookmark name, thereby ensuring the consistency of bookmark naming across documents and processing batches at the system level.

[0070] Write the bookmark name and semantic fingerprint string to the current field boundary record to form the labeled field boundary record. The labeled field boundary record adds the bookmark name field and semantic fingerprint field to all fields of the original field boundary record, while the other fields (container structure path, logical text segment number, list of operation scope of running nodes, original text of Party A field, and comparison text of Party B field) remain unchanged.

[0071] Furthermore, the specific positioning process for directly locating the target node based on the operating range of the running node is described in reference to... Figure 3 The steps are as follows: Read the list of operation ranges of running nodes from the boundary records of the annotation fields. Each entry in the list contains a node reference, a local start character offset and a local end character offset within the node, and is arranged in the structural order of the nodes in the document. It jumps directly to the target running node based on the node reference, without performing any full-text string traversal on the document text; Take the text length of the target running node, and determine whether the local start offset is zero and whether the local end offset is equal to the text length minus one: if the conditions are met, then all the text of the node is different content, and the node text value is directly modified to the bookmark name, without making any changes to the node format attributes. If the condition is not met, the text of the node is only partially different, and the node is split in place into three adjacent nodes: a prefix node (the text is the original content before the local starting offset), a bookmark placeholder node (the text is the bookmark name), and a suffix node (the text is the original content after the local ending offset); the prefix node or suffix node is not created when the corresponding content is empty; each of the three nodes holds a deep copy of the original node's format attributes, and each node is assigned a unique node identifier to prevent the document application from automatically merging adjacent nodes; Process all running node operation entries of the current labeled field boundary record sequentially according to the above positioning and injection logic.

[0072] The process of writing the injection result and the two-component semantic fingerprint into the database also includes: After the bookmark injection is completed, the document structure is serialized into a byte stream, the digest value of the byte stream is calculated as the skeleton file identifier, the byte stream is stored in the file system and the storage path is recorded; All marked field boundary records are written into the database field record table. The field record table uses the combination of skeleton file identifier, container structure path and logical text segment number as the composite primary key, semantic fingerprint as the independent index column, and a composite index is built using the combination of skeleton file identifier and semantic fingerprint. Each record also includes book name, field original text and field comparison text. It supports directly retrieving abnormal records with multiple different bookmark names corresponding to the same semantic fingerprint by counting the number of different values ​​of the bookmark name in the semantic fingerprint group, thus achieving cross-template field naming consistency auditing without reading any document files; When the template is instantiated, the field record table is queried based on the skeleton file identifier to obtain all field records. After sorting by container structure path and logical text segment number, the corresponding skeleton file is read to restore the document structure. The bookmark placeholder node is located directly by the container path and number in the field record. The bookmark name is replaced to the actual fill value to generate the final document.

[0073] Specifically, the original underlying structure of document A is a memory-based document object model. For each record in the ordered list of records with marked field boundaries, its list of operation ranges for running nodes is read, and each operation entry is processed sequentially according to the order in which the running nodes appear in the document (i.e., the sorted order in the list).

[0074] The specific implementation of direct location: Each operation entry contains a node reference, which points to the specific operation node object in the underlying document object model during the merge mapping construction. Accessing the target operation node directly through the node reference eliminates the need for any string search or text traversal of the entire document, thus eliminating the search time overhead that increases linearly with document size.

[0075] Branch handling for format-preserving injection: Take the total length of the text characters in the target running node, and determine whether the local start offset of the current operation entry is zero and whether the local end offset is equal to the total length of the text characters minus one. If both conditions are met, then the entire text of the running node is within the difference range, and the text content of the running node is directly modified to the bookmark name string. All original format attribute child nodes of the running node are not modified in any way, and the original character format is completely preserved. If none of the above conditions are met simultaneously, then the text of the running node is only partially located within the difference interval. The running node is then split in place into three consecutive new running nodes: Prefix node: The text content is the substring before the local starting offset in the original text; if the substring is an empty string, no prefix node is created; Bookmark placeholder node: The text content is the bookmark name string; Suffix node: The text content is the substring after the local end offset in the original text; if the substring is an empty string, no suffix node is created. Each of the three nodes holds a deep copy of the original running node's format attribute child nodes. Deep copy means that a new independent format attribute child node object is created, and the tag names and attribute values ​​of all child elements of the original node's format attribute are completely copied to the new object. The new object and the original node's format attribute child nodes are independent of each other in memory, and modifications to one do not affect the other.

[0076] To prevent automatic merging by document applications: A unique run identifier attribute is generated for each newly created run node. Specifically, a random string is generated using a universal unique identifier generation algorithm, and the first eight hexadecimal characters are used as the attribute value. This ensures that the run identifier attribute values ​​of the three new run nodes generated by the same split operation are different, preventing the Word application from automatically merging adjacent run nodes with the same identifier the next time the document is opened, thus disrupting the bookmark placeholder structure.

[0077] The three new nodes are replaced in the underlying document structure in the order of prefix node, bookmark placeholder node, and suffix node, thus completing the in-place split.

[0078] After processing all the running operation entries of the current annotation field boundary record in sequence, continue processing the next annotation field boundary record until all records have been processed.

[0079] After all boundary records of the labeled fields have been processed, the modified in-memory document object model is serialized into a byte stream of the underlying structure. A digest value is calculated for the byte stream, and the first few bytes of the digest result are taken as a hexadecimal string representation as the skeleton file identifier. The principle for selecting the byte truncation length is the same as the principle for the first component hash truncation, ensuring the uniqueness of the skeleton file identifier in the current file system. The byte stream is written to the file system, recording the correspondence between the storage path and the skeleton file identifier for subsequent template instantiation steps.

[0080] For all records in the ordered list of records with marked field boundaries, a batch write operation is performed, writing the data to the database field record table. The table structure of the field record table is as follows: The composite primary key consists of three columns: skeleton file identifier, container structure path, and logical text segment number, ensuring that there is only one unique record for each field position in the same skeleton file. Semantic fingerprint columns are indexed independently to support fast retrieval using semantic fingerprints as query criteria; The combination of skeleton file identifier and semantic fingerprint creates a composite index, which supports the rapid location of fields with specific semantics within a single skeleton file. Each record also includes a bookmark name, the original text of the Party A field, and the comparison text field of the Party B field.

[0081] After all records have been written, commit the database transaction to complete the entire document processing workflow.

[0082] After the field record table is written, the following audit operations can be performed directly on the data in the table using Structured Query Language, without needing to read any document files: Based on semantic fingerprints, the number of different values ​​for bookmark names in each group is counted. Groups with more than one different value are queried, which can identify abnormal fields with the same semantics but inconsistent bookmark names in different document processing batches. This can be used for the naming standard verification and correction of the template library.

[0083] When it is necessary to generate an actual business document from a stored template skeleton, the field record table is queried using the skeleton file identifier as a condition to retrieve all field records corresponding to that skeleton file, sorted in ascending order by container structure path lexicographical order and logical text segment sequence number. The byte stream corresponding to the skeleton file identifier in the file system is read and restored to an in-memory document object model.

[0084] Based on the container structure path in each field record, the corresponding container node is located in the in-memory document object model. Based on the logical text segment sequence number, the execution node containing the bookmark name text is located in the child execution node sequence of that container node. The text content of that execution node is replaced from the bookmark name string with the actual fill value corresponding to the business instance, while maintaining the format attributes. After all field records have been processed, the document object model is serialized into the final business document byte stream and output to the downstream business system.

[0085] Example 2: This embodiment, based on the entire process described in Embodiment 1, focuses on elaborating the fuzzy sequence alignment mechanism and the semantic fingerprint bookmark name correction propagation mechanism. Embodiment 1 has implemented a complete process for non-destructive logical text segment reconstruction of two documents, running merge mapping construction, cross-document minimum difference substring detection, dual-component semantic fingerprint construction, bookmark injection, and database writing. This embodiment introduces an extension mechanism in the field boundary record generation stage and the database writing stage.

[0086] For structurally abnormal containers with two documents of unequal numbers of logical text segments within the same container path, after a conventional merging attempt fails, fuzzy sequence alignment is performed. The specific process is as follows: A list of logical text segments from both documents within the container path is extracted. Using the character-level Levenshtein edit distance between any two merged text segments as the cost function, a dynamic programming algorithm is used to calculate the globally optimal sequence alignment scheme between the two lists. Alignment operations are categorized into replacement, insertion, and deletion. Only logical text segment pairs corresponding to replacement operations in the alignment scheme are extracted. Minimum difference substring detection is performed on each text segment pair to generate candidate field boundary records. The alignment confidence score is obtained by subtracting the ratio of the alignment cost of each candidate record's corresponding text segment pair to the sum of the number of characters in the text segments on both sides, making the confidence score positively correlated with the alignment similarity. Candidate records with confidence scores higher than a preset threshold are included in an ordered list of field boundary records for subsequent processing, while those with scores lower than the threshold are written to an extended difference log for manual review along with their confidence scores.

[0087] The preset threshold is determined as follows: During the system initialization phase, a sample document set with correctly labeled field boundaries is used as input. For all candidate field boundary records generated by the fuzzy sequence alignment algorithm on this sample set, the labeling results are used as the true values. A grid search is performed within the range of confidence scores. The target function is to maximize the harmonic mean of precision and recall (F1 score). The confidence score value that results in the highest F1 score is determined as the initial threshold and written into the system parameter file. This parameter value is read and used in the actual processing flow. When a new sample set is added, the threshold calibration can be re-executed and the parameter file updated according to the same method to adapt to the distribution differences of document structure changes under different business scenarios.

[0088] Specifically, in the field boundary record generation step described in Embodiment 1, after completing the regular sequence number alignment comparison for each container path, if the number of logical text segment lists of two documents under a certain container path is not equal, and the sequence number alignment cannot be completed even after trying to merge adjacent segments with the same format signature, then this step is triggered.

[0089] Take two lists of logical text segments from the container path, denoted as List A and List B respectively. Use the character-level edit distance between the merged text of segment i in List A and segment j in List B as the alignment cost for this segment pair. The edit distance is calculated using the minimum number of single-character insertion, deletion, and replacement operations required to transform one string into another; the more similar the two strings, the lower the cost. When the number of characters in a merged text exceeds the pre-written character length limit in the system parameter file, only the first few characters of the merged text (with a value equal to the limit) are used to calculate the edit distance. The excess is accumulated as the absolute value of the difference between the lengths of the two texts into the cost, ensuring that the cost calculation is completed within a bounded number of steps.

[0090] Based on the aforementioned costs, a dynamic programming algorithm is used to perform globally optimal sequence alignment of the two lists. A two-dimensional cost matrix is ​​constructed, with the number of rows equal to the length of list A plus one and the number of columns equal to the length of list B plus one. The first row and k-th column of the matrix are initialized with k times the empty segment alignment cost, and the first column and k-th row are also initialized with k times the empty segment alignment cost, representing the cumulative cost of aligning k segments with an empty list. Then, starting from the first row and first column, the minimum total cost of aligning the first i segments of list A with the first j segments of list B is filled cell by cell. Each cell takes the minimum cost from the following three sources: from the top-left diagonal cell plus the alignment cost of the i-th and j-th segments (corresponding to replacement), from the left cell plus the empty segment cost (corresponding to insertion), and from the top cell plus the empty segment cost (corresponding to deletion). After the matrix is ​​filled, backtracking from the bottom right corner to the top left corner, the operation type of each step is determined step by step: if the current cell comes from the top-left diagonal cell, it is recorded as a replacement operation; if it comes from the left cell, it is recorded as an insertion operation; if it comes from the top cell, it is recorded as a deletion operation. The backtracking terminates when the zeroth row and zeroth column are reached, resulting in a complete alignment scheme.

[0091] Only logical text segment pairs belonging to the replacement type in the alignment scheme are extracted. For each pair of replacement text segments, the minimum difference substring detection described in Example 1 is performed to generate candidate field boundary records.

[0092] For each candidate field boundary record, calculate its alignment similarity score: divide the edit distance cost of the text segment pair by the sum of the number of characters in the merged text on both sides, and the quotient is the difference ratio. Subtract this difference ratio from one to obtain the final alignment similarity score. The more similar the two text segments are, the closer the score is to one. Candidate records with alignment similarity scores higher than a preset threshold are added to an ordered list of field boundary records for further processing; candidate records with scores lower than or equal to the preset threshold, along with their scores, are written to an extended difference log for manual review.

[0093] Preset threshold acquisition: During system initialization, professionals select several document pairs from the processed historical document library that have differences in the number of logical text segments under the same container path. For each document pair, correctly labeled field boundaries are manually assigned, forming a labeled sample set. A fuzzy sequence alignment algorithm is run on each document pair in the sample set to obtain all candidate field boundary records and their alignment similarity scores. Candidate thresholds are selected one by one within a range of zero to one, using a step size pre-written in the system parameter file. For each candidate threshold, the precision and recall rates are calculated between the filtered record set and the manually labeled results: precision is the number of filtered records matching the manually labeled records divided by the total number of filtered records; recall is the number of filtered records matching the manually labeled records divided by the total number of manually labeled records. If the sum of precision and recall is zero, the evaluation score corresponding to that candidate threshold is recorded as zero, and it does not participate in the highest score selection; the process continues to the next candidate threshold. Otherwise, twice the product of precision and recall is divided by the sum of the two, and the result is used as the evaluation score for that candidate threshold. The candidate threshold with the highest evaluation score is written to the system parameter file, and this parameter value is read and used in subsequent actual processing. When the business scenario expands or new document types are added, corresponding labeled samples can be added, and the threshold calibration can be re-executed and the parameter file updated using the same method.

[0094] The semantic fingerprint bookmark name correction propagation steps are as follows: When a user manually corrects the bookmark name of a record in the database field record table through the management interface, the semantic fingerprint field value of that record is read. Within a database transaction with a serializable isolation level, the following two update operations are executed synchronously: The corresponding bookmark name field in the fingerprint registry is updated to the corrected value using the semantic fingerprint as the key; the bookmark name field in the field record table is batch-updated to the corrected value for all records sharing the same semantic fingerprint, using the semantic fingerprint as a condition. These two update operations are committed within the same transaction, relying on the database's unique key constraint on the semantic fingerprint column in the fingerprint registry to prevent concurrent corrections from writing inconsistent data. Simultaneously, the timestamp of the correction operation, the bookmark name before correction, the bookmark name after correction, and the corresponding semantic fingerprint are written to the correction log table, forming a traceable naming change record to support the review and auditing of correction history.

[0095] Specifically, after the database write operation described in Example 1 is completed, the system provides a manual signature correction function. The user selects a record in the field record table through the management interface, modifies the signature of that record to a new value, and submits. The system reads the semantic fingerprint field value of that record, initiates a database transaction with a serializable isolation level set, and executes the following sequentially within the transaction: using the semantic fingerprint as the key, updates the signature field of the corresponding record in the fingerprint registry to the new value; using the semantic fingerprint as the condition, batch updates the signature fields of all records in the field record table whose semantic fingerprint fields are equal to that value to the new value. The transaction is then committed after both updates are completed.

[0096] If a conflict is triggered by the unique key constraint of the semantic fingerprint column in the fingerprint registry during transaction commit, it means that the correction operation of the same semantic fingerprint was committed concurrently. The subsequent transaction is rolled back, and the system returns a prompt to the committer, indicating that the bookmark name corresponding to the semantic fingerprint has been corrected to the latest value by the concurrent operation, and displays the latest value, allowing the user to decide whether to commit again to overwrite.

[0097] After a transaction is successfully committed, the timestamp of this correction, the name of the document before the correction, the name of the document after the correction, and the corresponding semantic fingerprint are written into the correction log table to form a traceable naming change record for subsequent name change review and auditing.

[0098] The above-mentioned correction propagation mechanism ensures that in any subsequent document processing batch, any field with the same semantic fingerprint as the corrected fingerprint will directly obtain the corrected signature name from the fingerprint registry without further manual intervention; records with the same fingerprint that have been written into the field record table in historical batches will be synchronously updated to the corrected name, so that the cross-template field naming consistency audit results accurately reflect the latest naming status.

[0099] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An AI-based intelligent parsing and structured storage method for Word documents, characterized in that, include: For adjacent running nodes in the logical container node of a Word document, non-destructive logical text segment reorganization is performed based on the consistency of format attributes, and a running merge mapping that records the character offset relationship of each original running node is constructed. Using the logical text segment and the run merge mapping as input, cross-document minimum difference substring detection is performed through double-layer alignment of container path intersection and text segment sequence number to generate field boundary records carrying the operation range of the run node; Using the field boundary record as input, extract the forward fixed label text hash and field content pattern enumeration to construct a two-component semantic fingerprint, query the fingerprint registry to obtain or generate a consistent book signature name, and form a labeled field boundary record; Using the boundary records of the labeled fields as input, the target node is directly located and the format-preserving bookmark injection is performed based on the operation range of the running node it carries. The injection result and the two-component semantic fingerprint are written into the database, and the semantic fingerprint is used as an index to support cross-template semantic retrieval and consistency auditing.

2. The AI-based intelligent parsing and structured storage method for Word documents according to claim 1, characterized in that: The specific process of non-destructive logical text segment reorganization is as follows: perform revision acceptance preprocessing on the document, eliminate the interference of revision insertion nodes and revision deletion nodes on the determination of format attributes, and obtain a document structure containing only formal content; For each logical container node in the document, initialize the current logical text segment state; traverse all direct child running nodes of the container node, extract all tag names and attribute values ​​of the format attribute child nodes for each running node, and concatenate them into a standardized format signature in lexicographical order of tag names; The current running node's format signature is compared with the recorded format signature using string equality comparison: if they match, the current node's text is appended to the merged text and the node reference is appended to the list; if they do not match, the current logical text segment is encapsulated and written to an ordered list, and a new logical text segment is initialized with the current node; after all traversals are completed, the last logical text segment is encapsulated; the original running node is not modified at all during the process, and the reorganization result exists in parallel with the original document structure as an independent data structure.

3. The AI-based intelligent parsing and structured storage method for Word documents according to claim 2, characterized in that: The specific process of constructing the run-merge mapping is as follows: a two-dimensional key is formed by the container node structure path and the sequence number of the logical text segment within the container; during the appending of a run node to each logical text segment, the node reference of the run node, the string length of the merged text before appending as the character starting offset, and the current node text length as the character occupied length are recorded synchronously. These three elements form an offset entry appended to the ordered list of run nodes corresponding to the logical text segment; when the logical text segment is encapsulated, its corresponding ordered list of run nodes and the offset information of each entry are synchronously written into the run-merge mapping, forming a complete mapping relationship from any character offset range in the merged text of the logical text segment to the corresponding original run node and the local offset range within the node. The run merge mapping is constructed independently for each of the two documents.

4. The AI-based intelligent parsing and structured storage method for Word documents according to claim 1, characterized in that: The generation process of the field boundary record is as follows: Construct container index tables with the container node structure path as the key and the ordered list of logical text segments within the container as the value, using ordered lists of logical text segments from the logical text segments of the two documents respectively; take the intersection of the key sets of the container index tables of the two documents, and perform a comparison on container nodes whose structural positions are completely corresponding; for each container path in the intersection, extract the list of logical text segments from the two documents within that container, align them one by one with the same sequence number, and compare whether the two merged text segments are equal; for segment pairs with unequal text, scan character by character from the beginning of the merged text to determine the position of the first different character as the difference start offset, and scan character by character from the end of each text to determine the difference end offset of each; query the merge mapping based on the offset interval, traverse the list of running nodes corresponding to the logical text segments, find all running nodes where the character offset interval overlaps with the difference interval, and calculate the affected local start offset and local end offset within each node; encapsulate the container structure path, logical text segment sequence number, difference start offset, difference end offset on both sides, difference substring text on both sides of the two documents, and the list of operation ranges of the running nodes into a field boundary record.

5. The AI-based intelligent parsing and structured storage method for Word documents according to claim 1, characterized in that: The construction process of the dual-component semantic fingerprint is as follows: First component construction: using the container path to which the field boundary record belongs as the key, scan backwards from the corresponding segment number of the current field boundary record in the list of logical text segments of the container; skip logical text segments with empty merged text; for each non-empty text segment, determine whether its merged text appears in the original text set of all current field boundary records: those that do not appear are fixed label texts, which are normalized and their hash values ​​are calculated as the first component; If the text appears as a dynamic field, continue scanning forward; if a fixed label is not found at the beginning of the container, the hash value of the last three-level path string of the container structure path is used as the first component to replace it. The second component construction involves performing pattern checks on the original text of the field in the following order: whether it conforms to the date format of year-month-day separation; whether it consists of uppercase letters, numbers, and hyphens and its length does not exceed the preset limit. Does it include entries from the dictionary of keywords related to enterprise nature? Whether it consists entirely of Chinese characters and its length does not exceed the preset limit; Whether it consists of only numbers and a decimal point; the first matching format type is used as the second component enumeration value; If none of the above are found, the enumerated value is of the general text type; The hash value of the first component and the enumeration value of the second component are concatenated with a separator to form a semantic fingerprint string.

6. The AI-based intelligent parsing and structured storage method for Word documents according to claim 5, characterized in that: The method for obtaining the annotation field boundary record is as follows: using the semantic fingerprint string as the key, query the persistent fingerprint registry; if a record is found, directly retrieve the corresponding bookmark name; if not found, query the predefined naming rule table according to the second component enumeration value, and generate the bookmark name according to the naming rule corresponding to the enumeration value; after generation, write the semantic fingerprint and bookmark name into a new record and perform a persistence operation, so that it can be reused for querying any document; write the bookmark name and semantic fingerprint string into the corresponding field boundary record to form the annotation field boundary record; the annotation field boundary record adds the bookmark name field and semantic fingerprint field on the basis of the original field boundary record, and the remaining fields, including the container structure path, logical text segment number, and running node operation range list, remain unchanged.

7. The AI-based intelligent parsing and structured storage method for Word documents according to claim 1, characterized in that: The specific positioning process for directly locating the target node based on the operation range of the running node is as follows: Read the list of operation ranges of the running nodes from the boundary record of the annotation field, arranged according to the structural order of the nodes in the document; jump directly to the target running node based on the node reference, without performing any full-text string traversal on the document text; obtain the text length of the target running node, and determine whether the local start offset is zero and the local end offset is equal to the text length minus one: if the conditions are true, the entire text of the node is different, and the node text value is directly modified to the bookmark name, without modifying the node format attributes; if the conditions are not true, the text of the node is only partially different, and the node is split in place into three adjacent nodes: a prefix node, a bookmark placeholder node, and a suffix node; each of the three nodes holds a deep copy of the original node format attributes, and each node is assigned a unique node identifier to prevent the document application from automatically merging adjacent nodes; process all running node operation entries of the current annotation field boundary record sequentially according to the positioning and injection logic.