A context expansion method, device and equipment of a document and a storage medium
By performing hierarchical structure parsing and semantic analysis on documents, a logically coherent context is generated, which solves the problems of insufficient accuracy and logical coherence in document expansion in existing technologies, and achieves efficient and accurate document expansion and information fusion.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU WEISHITONG INFORMATION SECURITY TECH CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-06-09
AI Technical Summary
Existing document management systems suffer from semantic parsing bias and insufficient accuracy in related searches when processing fragmented documents with concise semantic descriptions or dense technical terms. Furthermore, they lack dynamic adaptation capabilities, resulting in weak logical coherence of expanded content, information redundancy, and low expansion efficiency.
By parsing the hierarchical structure of the target document and related original documents, a hierarchical structure tree is generated. Keywords and semantic weights are extracted using models such as BERT and TF-IDF. Semantic similarity is calibrated by combining a Siamese network model, related nodes are screened, and logically coherent context is generated using attention mechanisms and named entity recognition. A hierarchical association graph is then constructed and fused.
It improves the accuracy and logical coherence of document expansion, enhances the relevance and adaptability of information, reduces information redundancy, and improves the accuracy of subsequent searches and the downstream service experience.
Smart Images

Figure CN122174807A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing, and in particular to a method, apparatus, device, and storage medium for document context expansion. Background Technology
[0002] In existing document management systems, the parsing of contextual information in imported documents largely relies on the document's own text content. When documents contain fragmented content, concise semantic expressions, or are dense with technical terms, semantic parsing biases and insufficient accuracy in related searches are prone to occur. In particular, when fragmented content such as technical paper abstracts and core paragraphs are imported separately, key contexts such as research background, experimental parameters, and value explanations are missing, making it difficult for downstream services to quickly grasp the core value and technical context of the document.
[0003] Current technologies for document context expansion suffer from several significant drawbacks: First, they are limited in their contextual information mining capabilities, relying solely on the document's own text and failing to effectively supplement missing key information from internal and external sources. This makes them ill-suited for the precise parsing needs of complex document scenarios, such as fragmented documents. Second, they neglect the internal hierarchical structure of documents, often employing cross-document associations and general semantic associations, neglecting the inherent structural features of chapters, paragraphs, and arguments, thus limiting expansion efficiency and accuracy. Third, the logical coherence of the expanded content is weak; general semantic associations easily introduce irrelevant information, leading to redundancy, and directly expanding based on locating sentences loses hierarchical logical relationships, disrupting information coherence. Fourth, they lack dynamic adaptability; existing solutions are mostly static expansions with fixed content, unable to adjust the focus based on different application scenarios such as academic retrieval and enterprise knowledge bases, significantly reducing their practicality. These shortcomings collectively make it difficult for existing solutions to achieve accurate and efficient document context expansion, impacting subsequent retrieval accuracy and downstream service experience.
[0004] Therefore, improving the accuracy and logical coherence of document expansion is a pressing technical problem that needs to be solved. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a method, apparatus, device, and storage medium for document context expansion, which can improve the accuracy and logical coherence of document expansion. The specific solution is as follows: Firstly, this application provides a method for expanding the context of a document, including: Identify the target document to be added to the database in the document management system, and identify the original document that has a preset association with the target document. Perform hierarchical structure parsing on the original document to obtain the hierarchical structure tree. The first node in the hierarchical structure tree is determined based on the target document, and the second node is determined from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node; the node is a node that is associated with the text content, semantic attributes and hierarchical association weight of the original document; the hierarchical association weight is a weight that represents the degree of semantic dependence between the current node and the nodes other than the current node in the hierarchical structure tree. An expanded context is generated based on the first node and the second node, and the context is merged into the target document so that the resulting merged document is included in the database.
[0006] Optionally, the step of parsing the hierarchical structure of the original document to obtain a hierarchical structure tree includes: Parse and extract target nodes from the original document, and determine the text content corresponding to the target nodes; The target words are extracted from the text content corresponding to the target node using a first pre-trained model based on BERT, the word frequency weights of the target words are determined using the TF-IDF statistical method, and the semantic weights of the target words are determined using a pre-set semantic database. The first semantic contribution of the target word is determined based on the word frequency weight and the semantic weight; Determine the first logical connector in the text content corresponding to the target node, and determine the initial weight of the corresponding connector based on the first logical connector; Determine the target position of the first logical connector in the text content corresponding to the target node, and correct the initial weight of the connector based on the target position to obtain the corrected weight; The first semantic similarity between the target nodes is determined by a BERT-based Siamese network model, and the first semantic similarity is calibrated by a penalty factor based on the hierarchical position of the target nodes to obtain a second semantic similarity. The target hierarchical association weight of the target node is determined by a preset weighted fusion formula based on the first semantic contribution, the corrected weight, and the second semantic similarity. The target semantic labels are generated by using the target node through a second pre-trained model based on document topics, and the initial semantic labels are corrected based on the hierarchical position of the target node and a preset classifier to obtain the target semantic labels. The hierarchical structure tree corresponding to the original document is determined based on the target node, the target hierarchical association weight, and the target semantic tag.
[0007] Optionally, determining the first node in the hierarchical structure tree based on the target document includes: The text similarity between the target document and the target node in the hierarchical structure tree is determined by the locality-sensitive hashing algorithm, and the target node whose text similarity is higher than a preset similarity threshold is identified as a candidate node; The syntactic tree similarity between the target document and the candidate nodes is determined by dependency parsing. Based on the hierarchical position of the target node and the syntactic tree similarity, a first node is determined from the candidate nodes.
[0008] Optionally, determining the second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node includes: In the hierarchical structure tree, determine the third node other than the first node; Based on the hierarchical position of the first node, the shortest path length between the first node and the third node in the hierarchical structure tree is determined, and the shortest path length is determined as the hierarchical distance between the first node and the third node; The target words corresponding to the first node are determined based on the hierarchical association weight of the first node, and the coverage of the target words corresponding to the third node is determined based on the target words corresponding to the first node. The semantic distance to the target word corresponding to the third node is determined by the target model used to generate word vectors, and the second semantic contribution of the target word corresponding to the third node is determined based on the coverage and the semantic distance. The third node is filtered based on the hierarchical distance, the preset distance threshold, the second semantic contribution, and the preset contribution threshold to obtain the retained filtered nodes; The corresponding weight coefficients are determined based on the type of the target document, and a screening formula is constructed using the weight coefficients, hierarchical distance, and second semantic contribution. The second node is obtained by filtering the filtered nodes using the filtering formula and based on the hierarchical distance and the second semantic contribution.
[0009] Optionally, generating the context that expands the target document based on the first node and the second node includes: A first semantic role is extracted from the text content corresponding to the first node using an attention-based semantic role labeling model, and a second semantic role is extracted from the text content corresponding to the second node. The target entity is extracted from the text content corresponding to the second node using named entity recognition technology. The first semantic role and the second semantic role are matched to obtain a first matching degree, and the initial semantic unit of the second node is determined based on the second semantic role whose first matching degree is greater than a preset matching degree threshold and the target entity. Based on the initial semantic unit and the preset cosine similarity calculation method, the semantic repetition of the second node is determined, and the initial semantic units with semantic repetition greater than the preset repetition threshold are merged to obtain the first target semantic unit; The information gain of the first target semantic unit is determined based on the mutual information value between the first target semantic unit and the first node, and the first target semantic units with information gains less than a preset gain threshold are filtered to obtain the second target semantic unit. Logical labels are assigned to the second target semantic unit to obtain labeled semantic units, and an initial logical dependency graph is constructed based on the labeled semantic units and the hierarchical structure tree. The initial logical dependency graph is sorted using a topological sorting algorithm, the third semantic similarity between the labeled semantic units, and the second matching degree between the second logical connectors in the labeled semantic units, to obtain a sorted logical dependency graph. Based on an adaptive adjustment mechanism for controlling word count and using the target word count of the target document, the sorted logical dependency graph is adjusted to obtain a target logical dependency graph, and a context for expanding the target document is generated based on the target logical dependency graph.
[0010] Optionally, generating the context that expands the target document further includes: Determine the scene tags of the target document; The context of the generated expanded target document is dynamically adjusted based on the scene labels and the pre-trained language model to complete the context update operation.
[0011] Optionally, the step of fusing the context into the target document to include the resulting fused document in the database includes: The first node and the second node in the hierarchical structure tree are determined as vertices, the hierarchical association weights of the first node and the second node are determined as the target weights between the vertices, and a hierarchical association graph is constructed based on the vertices and the target weights using a force-oriented algorithm. The context and the hierarchical relationship graph are fused into the target document, and the resulting fused document is then included in the database.
[0012] Secondly, this application provides a document context extension device, comprising: The structure tree determination module is used to determine the target document to be added to the database in the document management system, and to determine the original document that has a preset association relationship with the target document. The original document is then parsed to obtain the hierarchical structure tree. The node determination module is used to determine the first node in the hierarchical structure tree based on the target document, and to determine the second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node; the node is a node that is associated with the text content, semantic attributes and hierarchical association weight of the original document; the hierarchical association weight is a weight that characterizes the degree of semantic dependence between the current node and the nodes other than the current node in the hierarchical structure tree. The document collection module is used to generate an expanded context for the target document based on the first node and the second node, and to merge the context into the target document so as to collect the resulting merged document into the database.
[0013] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the aforementioned document context expansion method.
[0014] Fourthly, this application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned document context expansion method.
[0015] In this application, a target document to be added to the database in a document management system is identified, and original documents with a preset association relationship with the target document are identified. The original documents are then parsed hierarchically to obtain a hierarchical structure tree. A first node in the hierarchical structure tree is determined based on the target document, and a second node is determined from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node. A node is a node associated with the text content, semantic attributes, and hierarchical association weight of the original document. The hierarchical association weight is a weight representing the degree of semantic dependency between the current node and other nodes in the hierarchical structure tree. An expanded context is generated based on the first node and the second node, and this context is merged into the target document to include the merged document in the database. As can be seen from the above, in this application, a target document to be added to the database is first selected in the document management system, and original documents that satisfy a preset association relationship with the target document are selected. The hierarchical structure of the original documents is then parsed to generate a corresponding hierarchical structure tree. Subsequently, based on the target document, a first node is located in the hierarchical structure tree. Combining the hierarchical position and hierarchical association weight of this first node, a second node is further determined from the hierarchical structure tree. Here, a node is a carrier of the textual content, semantic attributes, and hierarchical association weights associated with the original document. The hierarchical association weights characterize the degree of semantic dependency between the current node and other nodes within the hierarchical structure tree. Finally, a context for expanding the target document is generated based on the first and second nodes, this context is integrated into the target document, and the integrated document is then included in the database. In this way, this application can improve the accuracy and logical coherence of document expansion. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0017] Figure 1 This is a flowchart of a document context expansion method disclosed in this application; Figure 2 A flowchart illustrating a specific document context expansion method disclosed in this application; Figure 3 This is a module architecture diagram of a specific document context expansion method disclosed in this application; Figure 4 This is a schematic diagram illustrating the generation of contextual content as disclosed in this application; Figure 5This is a schematic diagram illustrating the composition of a structured data entry document disclosed in this application; Figure 6 This is a schematic diagram of node relationships in a hierarchical structure tree disclosed in this application; Figure 7 This is a schematic diagram of the structure of a document context expansion device disclosed in this application; Figure 8 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Current technologies for document context expansion suffer from several significant drawbacks: First, they are limited in their contextual information mining capabilities, relying solely on the document's own text and failing to effectively supplement missing key information from internal and external sources. This makes them ill-suited for the precise parsing needs of complex document scenarios, such as fragmented documents. Second, they neglect the internal hierarchical structure of documents, often employing cross-document associations and general semantic associations, neglecting the inherent structural features of chapters, paragraphs, and arguments, thus limiting expansion efficiency and accuracy. Third, the logical coherence of the expanded content is weak; general semantic associations easily introduce irrelevant information, leading to redundancy, and directly expanding based on locating sentences loses hierarchical logical relationships, disrupting information coherence. Fourth, they lack dynamic adaptability; existing solutions are mostly static expansions with fixed content, unable to adjust the focus based on different application scenarios such as academic retrieval and enterprise knowledge bases, significantly reducing their practicality. These shortcomings collectively make it difficult for existing solutions to achieve accurate and efficient document context expansion, impacting subsequent retrieval accuracy and downstream service experience. To this end, this application provides a method, apparatus, device, and storage medium for expanding the context of a document, which can improve the accuracy and logical coherence of document expansion.
[0020] See Figure 1 As shown in the figure, an embodiment of the present invention discloses a document context expansion method, including: Step S11: Determine the target document to be added to the database in the document management system, and determine the original document that has a preset association relationship with the target document. Perform hierarchical structure parsing on the original document to obtain the hierarchical structure tree.
[0021] In this embodiment, the first step is to select a target document to be added to the document management system. To construct contextual information for this target document, related existing documents need to be found as original documents. The preset association relationships can be established based on various rules, such as the similarity of content themes between documents, the same project or task, the same author, the continuity of creation or modification time series, or through preset knowledge graph linking relationships. The process of determining the original documents can be automated, for example, by comparing the similarity of document metadata tags, keyword vectors, or summary embeddings; it can also be semi-automatic or manual, for example, by the system administrator specifying a set of related documents according to business logic. After determining one or more original documents to provide context, the internal structure of these original documents needs to be analyzed in depth. Most structured or semi-structured documents, such as technical reports, academic papers, and product manuals, have an inherent hierarchical organization, usually reflected through heading levels, chapter numbers, specific styles, or markup languages. The purpose of hierarchical structure analysis is to transform these non-planar, nested document contents into a structured tree representation, i.e., a hierarchical structure tree. This tree structure clearly reflects the subordinate and parallel logical relationships between different parts of the document, laying the foundation for subsequent extraction and quantification of the importance of semantic units within the document.
[0022] Specifically, for constructing the hierarchical structure tree, firstly, target nodes are parsed and extracted from the original document, and the text content corresponding to the target nodes is determined. To quantify the core semantic information of the text content contained in the target nodes, target words are extracted from the text content corresponding to the target nodes using a first pre-trained model based on BERT (Bidirectional Encoder Representations from Transformers). The word frequency weights of the target words are determined using the TF-IDF (Term Frequency-Inverse Document Frequency) statistical method, and the semantic weights of the target words are determined using a pre-set semantic database. Based on the word frequency weights and the semantic weights, the first semantic contribution of the target words is determined. This contribution integrates the local statistical characteristics and global semantic importance of the words, and is a word-level importance indicator.
[0023] The logical fluency and argumentative strength of a document largely depend on the use of logical connectors, which are crucial for understanding contextual relationships. Therefore, this paper identifies the first logical connector in the text content corresponding to the target node, determines its initial weight, and then determines the target position of the first logical connector in the text content corresponding to the target node. Based on this target position, the initial weight of the connector is adjusted to obtain a revised weight, which reflects a quantitative assessment of the logical connector's contribution to the logical structure within the current node's context.
[0024] To measure the semantic correlation between different target nodes, a first semantic similarity is determined by a BERT-based Siamese network model. The first semantic similarity is then calibrated using a penalty factor based on the hierarchical position of the target nodes to obtain a second semantic similarity. This second semantic similarity considers both the semantic content and structural position on the correlation.
[0025] After obtaining the first semantic contribution of the target word, the corrected weight of the logical connector, and the second semantic similarity between nodes, the target hierarchical association weight of the target node is determined by a preset weighted fusion formula based on the first semantic contribution, the corrected weight, and the second semantic similarity. This weight is used to characterize the relative importance of the node in the context network of the entire original document and its association strength with other nodes.
[0026] Meanwhile, in order to perform high-level abstraction and classification of the content topics of the nodes, a second pre-trained model based on document topics is used to generate corresponding initial semantic labels using the target nodes, and the initial semantic labels are corrected based on the hierarchical position of the target nodes and a preset classifier to obtain target semantic labels.
[0027] Finally, the hierarchical structure tree corresponding to the original document is determined based on the target node, the target hierarchical association weight, and the target semantic tag. This hierarchical structure tree provides a solid and rich material foundation for subsequent contextual expansion of the target document.
[0028] Step S12: Determine the first node in the hierarchical structure tree based on the target document, and determine the second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node; the node is a node that is associated with the text content, semantic attributes and hierarchical association weight of the original document; the hierarchical association weight is a weight that characterizes the degree of semantic dependence between the current node and the nodes other than the current node in the hierarchical structure tree.
[0029] In this embodiment, the aim is to locate the most relevant entry point to the target document within a constructed hierarchical structure tree rich in quantitative information, and based on this, intelligently discover more nodes with relevance value. Specifically, the first step is to anchor a node from the vast hierarchical structure tree that is most directly and closely related to the content of the target document as the first node. To efficiently and accurately determine the first node, the text similarity between the target document and the target nodes in the hierarchical structure tree is determined using a locality-sensitive hashing algorithm. Target nodes with text similarity higher than a preset similarity threshold are identified as candidate nodes. The syntactic tree similarity between the target document and the candidate nodes is determined using dependency parsing. Based on the hierarchical position of the target node and the syntactic tree similarity, the first node is determined from the candidate nodes. Nodes with higher hierarchical positions may represent more macro-level topics, and their value as a starting point for context may be greater; while syntactic tree similarity ensures the coherence of logical expression. Through this dual constraint of text content and logical structure, it is ensured that the selection of the first node is not only content-related but also logically connected to the target document.
[0030] After successfully identifying the first node, the next task is to search for and identify other nodes with related value, i.e., second nodes, within the hierarchical structure tree, centered on the first node. Specifically, first, a third node other than the first node is identified in the hierarchical structure tree; based on the hierarchical position of the first node, the shortest path length between the first node and the third node in the hierarchical structure tree is determined, and this shortest path length is defined as the hierarchical distance between the first node and the third node. This distance intuitively reflects the proximity of the two nodes in the document's organizational structure; the closer the distance, the more direct their thematic connection in the original document is likely to be.
[0031] In the semantic association dimension, the target words corresponding to the first node are determined based on the hierarchical association weight of the first node, and the coverage of the target words corresponding to the third node is determined based on the target words corresponding to the first node. The semantic distance of the target words corresponding to the third node is determined through the target model used to generate word vectors, and the second semantic contribution of the target words corresponding to the third node is determined based on the coverage and the semantic distance. The higher the contribution, the greater the value of the third node in semantically supplementing or extending the first node.
[0032] In the initial screening, the third node is filtered based on the hierarchical distance, a preset distance threshold, the second semantic contribution, and a preset contribution threshold, resulting in a retained set of nodes. For a more refined and adaptive final screening, a comprehensive screening formula needs to be constructed. Based on the type of the target document, corresponding weight coefficients are determined, and the screening formula is constructed using these weight coefficients, hierarchical distance, and the second semantic contribution. The selected nodes are then filtered using this formula, based on the hierarchical distance and the second semantic contribution, to obtain the second node. Through this multi-step, multi-indicator layered screening and comprehensive evaluation, it is ensured that the determination of the second node does not rely solely on a single feature, but rather on the optimal balance between structural proximity and semantic relevance under the guidance of a specific document type. This provides a high-quality, highly relevant source of alternative content for subsequent contextual information integration.
[0033] Step S13: Generate an expanded context for the target document based on the first node and the second node, and merge the context into the target document to include the resulting merged document in the database.
[0034] In this embodiment, the semantic information carried by the first and second nodes precisely located in the preceding steps is processed, organized and integrated in depth to form a logically coherent, information-condensed supplementary content that is highly adapted to the target document, namely the context, and ultimately achieves effective expansion of the knowledge content of the target document.
[0035] Specifically, a semantic role labeling model based on an attention mechanism is used to extract a first semantic role from the text content corresponding to the first node, and a second semantic role is extracted from the text content corresponding to the second node; named entity recognition technology is used to extract target entities from the text content corresponding to the second node, and these entities are key elements constituting supplementary factual information.
[0036] In order to determine the connection and continuity between the content of the second node and the core semantics of the first node, the first semantic role and the second semantic role are matched to obtain a first matching degree. Based on the second semantic role whose first matching degree is greater than a preset matching degree threshold and the target entity, the initial semantic unit of the second node is determined. This unit is a relatively complete semantic block that carries specific semantic role relationships and entity information.
[0037] Next, these initial semantic units need to be deredundanted and refined. Based on the initial semantic units and a preset cosine similarity calculation method, the semantic redundancy of the second node is determined. Initial semantic units with a semantic redundancy greater than a preset redundancy threshold are merged to obtain the first target semantic units. Further, the added information value brought to the target document by these first target semantic units needs to be evaluated. Based on the mutual information value between the first target semantic units and the first node, the information gain of the first target semantic units is determined. First target semantic units with an information gain less than a preset gain threshold are filtered to obtain the second target semantic units, thus completing the semantic content refinement.
[0038] In order to organize the second target semantic units into a coherent text, they need to be assigned logical relationship identifiers. Specifically, logical labels are assigned to the second target semantic units to obtain labeled semantic units, and an initial logical dependency graph is constructed based on the labeled semantic units and the hierarchical structure tree. This graph depicts the possible logical flows and dependencies between units.
[0039] To ensure the final generated context paragraphs have a logical and clear order, the nodes in the initial logical dependency graph, i.e., the labeled semantic units, need to be globally sorted. The initial logical dependency graph is sorted using a topological sorting algorithm, the third semantic similarity between the labeled semantic units, and the second matching degree between the second logical connectors within the labeled semantic units, resulting in a sorted logical dependency graph.
[0040] To ensure the practicality of the generated context, its length needs to be adapted to the length of the target document. Based on an adaptive adjustment mechanism for controlling the word count and utilizing the target word count of the target document, the sorted logical dependency graph is adjusted to obtain a target logical dependency graph. Then, a context for expanding the target document is generated based on this target logical dependency graph.
[0041] To enhance the adaptability of the context to different application scenarios and the consistency of expression style, scenario tags for the target document are determined; based on the scenario tags and the pre-trained language model, the generated expanded context of the target document is dynamically adjusted to complete the context update operation.
[0042] After generating and optimizing the context, a visual knowledge structure graph needs to be constructed to preserve and intuitively display the knowledge relationships between the original documents in the fused document. The first and second nodes in the hierarchical structure tree are identified as vertices, and the hierarchical association weights between the first and second nodes are determined as target weights between the vertices. A force-directed algorithm is then used to construct a hierarchical association graph based on the vertices and the target weights. Finally, the context and the hierarchical association graph are fused into the target document to include the fused document in the database, thus completing the intelligent context expansion and database entry process for the target document.
[0043] As can be seen from the above, in this application, the target document to be added to the database is first selected within the document management system, and original documents that satisfy a preset association relationship with the target document are simultaneously filtered out. The hierarchical structure of the original documents is then parsed to generate a corresponding hierarchical structure tree. Subsequently, based on the target document, a first node is located in the hierarchical structure tree, and combined with the hierarchical position and hierarchical association weight of the first node, a second node is further determined from the hierarchical structure tree. Here, a node is the carrier of the text content, semantic attributes, and hierarchical association weights associated with the original document, and the hierarchical association weights are used to characterize the degree of semantic dependency between the current node and other nodes in the hierarchical structure tree. Finally, a context for expanding the target document is generated based on the first and second nodes, this context is integrated into the target document, and then the integrated document is added to the database. In this way, this application can improve the accuracy and logical coherence of document expansion.
[0044] The following is combined Figure 2 and Figure 3 The schematic diagram shown illustrates the technical solution of the embodiments of this application in detail.
[0045] First, the article's hierarchical structure is parsed. The target document to be imported and its associated original complete article are obtained. The original complete article is then parsed to generate a hierarchical structure tree. This hierarchical structure tree uses "chapter-section-paragraph-sentence" as multi-level nodes. Each node is associated with corresponding text content, semantic tags, and hierarchical association weights. The hierarchical association weights represent the semantic dependence of the current node on other nodes and are calculated jointly by keyword overlap, logical connectors, and semantic similarity between nodes.
[0046] Specifically, for the analysis of the article's hierarchical structure, keywords are extracted from the text at each node based on the BERT pre-trained model. Keyword frequency weights are calculated using TF-IDF, and the semantic hierarchy weights of keywords are determined using a WordNet semantic dictionary (an English semantic database). The weights of core words are prioritized over modifiers, which in turn prioritize auxiliary words, ultimately yielding a keyword semantic contribution score. A dictionary of logical connectors is constructed, dividing logical connectors into four categories: causal (cause, due to; effect, therefore), progressive (furthermore), parallel (simultaneously, in addition), and adversative (but, however). Basic weights are assigned to each category of logical connectors. The basic weighting of logical connectors can be: causal > progressive > parallel > contrastive, with weight adjustments based on their position in the sentence. The weighting for different connector positions can be: beginning of sentence > middle of sentence > end of sentence. An improved Siamese-BERT model (a type of twin BERT) is used to calculate semantic similarity between nodes. A hierarchical position penalty factor is introduced, with the penalty factor at the same level < across levels, and the penalty factor at adjacent levels < the penalty factor at the level between levels. This hierarchical position penalty factor is used to calibrate the similarity results, avoiding cross-level semantic confusion. An adaptive weighted fusion formula is employed. ,in, Contribution to keyword semantics Adjusting the weights of logical connectors For calibrated semantic similarity; , The weight coefficients for different items can be dynamically optimized using the particle swarm optimization algorithm based on the subject type of the original article to obtain the final weight values. Simultaneously, during the generation of the hierarchical structure tree, an automatic annotation and dynamic update algorithm for hierarchical node semantic labels is introduced: initial semantic labels are generated based on a document topic pre-trained model such as DocBERT, and label constraints are applied based on hierarchical position features; for example, chapter nodes are labeled with "topic domain," section nodes with "subtopic," paragraph nodes with "core viewpoint," and sentence nodes with "supporting arguments." Then, a lightweight classifier is trained using a small number of manually annotated samples to correct the initial labels. A dynamic label update mechanism is established so that when the original article content is updated, only the semantic labels of the changed nodes and their related nodes are recalculated, eliminating the need for a full update and improving parsing efficiency.
[0047] Secondly, target document location and related node filtering are performed. The target document to be added to the database is matched with the nodes in the hierarchical structure tree to locate the core node corresponding to the target document. Based on the hierarchical position and hierarchical association weight of the core node, a set of related nodes is filtered out. The set of related nodes includes the parent node, child node, and highly related sibling nodes of the core node. The parent node provides background context, the child node provides supplementary detailed context, and the highly related sibling nodes provide parallel logical context.
[0048] Specifically, for target document localization and related node selection, the similarity between the target document and the text of each node is calculated based on text fingerprinting algorithms such as SimHash. A set of candidate nodes with similarity scores higher than an initial threshold is selected to quickly narrow down the matching range. The initial threshold can be 0.6. A "semantic structure consistency" evaluation metric is introduced, employing dependency parsing. By analyzing the syntactic structure of the target document and candidate nodes, the syntactic tree similarity between the two is calculated. Simultaneously, constraints are imposed based on the hierarchical position features of the core nodes. For example, when the target document is at the paragraph level, paragraph nodes in the hierarchical structure tree are prioritized for matching. Finally, the node with the highest weighted score of "text similarity + syntactic structure similarity" is selected as the core node, solving the problem of cross-level mismatches caused by single text similarity matching. Based on the hierarchical association weights of core nodes, a two-dimensional evaluation model of "hierarchical distance-semantic contribution" is used to screen associated nodes and prioritize them. Hierarchical distance is defined as the shortest path length between a core node and other nodes in the hierarchical structure tree. For example, the distance to the core node itself is 0, the distance to its parent / child nodes is 1, the distance to its grandparent / grandchild nodes is 2, and so on. The larger the distance, the lower the screening weight. Based on the core keywords of the core nodes, the coverage and semantic extension of the core keywords in the text of each candidate node are calculated. The semantic association distance of keywords can be calculated using Word2Vec; the higher the coverage and the closer the semantic extension, the higher the semantic contribution. A threshold filtering + priority ranking method is used to first filter out nodes with a hierarchical distance greater than 2 or a semantic contribution lower than a preset threshold (0.3). For the remaining nodes, a formula is used... Where ω is the hierarchical weight coefficient, which is dynamically adjusted according to the document type, for example, academic documents. =0.6, Popular Science Document =0.4 calculate priority, select the top N nodes from high to low priority to form a set of related nodes. N is dynamically adjusted according to the core node level. Chapter nodes N=10, section nodes N=8, paragraph nodes N=5, sentence nodes N=3; to ensure the relevance and conciseness of related nodes.
[0049] Next, contextual content is generated. Semantic extraction and redundancy filtering are performed on the text content in the set of related nodes, retaining content whose semantic relevance to the core nodes is higher than a preset threshold; the retained content is reorganized based on hierarchical logical relationships to generate an extended context that conforms to the logical chain of "background-core content-detail supplement-logical extension", wherein the ratio of the length of the extended context to the length of the target document is controlled between 1:1 and 2:1 to avoid information overload.
[0050] Specifically, refer to Figure 4 As shown, for the generation of contextual content, a semantic role labeling (SRL) model based on an attention mechanism is adopted to extract the core semantic roles in the text of each associated node, such as agent, patient, cause, result, method, and purpose; and match them with the core semantic roles of the core nodes, retaining semantic units with high matching degree; at the same time, named entity recognition (NER) is used to extract key entities in the text, such as person names, place names, organization names, experimental data, terms, etc., as a supplement to semantic extraction; a two-dimensional filtering model of "semantic repetition degree-information gain" is constructed. First, the repetition degree of semantic units of different associated nodes is calculated by cosine similarity, and semantic units with repetition degree higher than 0.8 are merged; then the information gain of each semantic unit is calculated. The mutual information formula can be used to calculate the mutual information value between the semantic unit and the core node, and semantic units with information gain lower than a preset threshold can be filtered out. The preset threshold can be 0.1; finally, the concept of "redundancy level" is introduced. Redundant semantic units at the same level are filtered first, and complementary semantic units across levels are retained to avoid information redundancy within the level. Each semantic unit is labeled with a logical type tag, such as background, core, detail, and extension. A logical dependency graph is constructed based on the hierarchical relationships and logical connectors in the hierarchical structure tree. A topological sorting algorithm is used to sort the logical dependency graph, ensuring the logical coherence of the reorganized context. Simultaneously, a "logical fluency" evaluation metric is introduced, calculating the matching degree of transition words between adjacent semantic units. For example, transitions from background to core units prioritize the use of transition words such as "based on this" and "addressing this issue." Semantic similarity is also calculated to fine-tune the sorting results. Finally, a length adaptive adjustment mechanism dynamically allocates the proportion of each logical section according to the target document length. For example, background sections account for 20%-30%, supplementary details for 30%-40%, and logical extensions for 20%-30%, thus ensuring that the expanded context length meets the 1:1 to 2:1 ratio requirement.
[0051] Furthermore, the context can be dynamically adjusted based on the specific scenario. The system retrieves the target document's entry scenario tags, such as academic research, corporate training, and public science education, and adjusts and expands the content focus of the context based on these tags. For academic research scenarios, it strengthens experimental data, references, and terminology explanations in related nodes; for corporate training scenarios, it highlights case studies, practical steps, and application effects; and for public science education scenarios, it simplifies technical terminology and adds colloquial explanations and relatable analogies.
[0052] Specifically, for scenario-based dynamic adjustments, a scenario feature dictionary is constructed, defining exclusive feature keywords for each scenario tag. For example, academic research scenarios might use keywords like "experiment," "simulation," "references," and "terminology"; corporate training scenarios might use keywords like "case studies," "steps," "processes," and "effects"; and public science popularization scenarios might use keywords like "popular," "analogy," and "real-life examples." Style features can also be defined, such as "rigorous," "objective," and "professional" for academic scenarios; "practical," "easy to understand," and "operable" for training scenarios; and "vivid," "popular," and "interesting" for science popularization scenarios. Based on these scenario feature keywords, a keyword weight enhancement algorithm is used to increase the weight of content in related nodes that matches the scenario characteristics. For example, the weight of experimental data in an academic scenario is increased to 1.5 times the original weight. This data is prioritized and highlighted. Simultaneously, a content deletion and supplementation strategy is employed: deleting scenario-irrelevant content (e.g., deleting formula derivations from academic scenarios in science popularization scenarios) and supplementing scenario-adaptive content (e.g., supplementing practical precautions in training scenarios). Finally, a pre-trained language model, such as GPT-2 (Generative Pre-trained Transformer), is used. 2. A style transfer algorithm for fine-tuning a natural language processing model transfers the style of the expanded context text to the style corresponding to the target scene. By constructing a scene style corpus, which can include academic corpora, training corpora, and popular science corpora, the model can be fine-tuned using the scene style corpus to ensure that the transferred text meets the scene requirements in terms of vocabulary selection, sentence structure, and expression. For example, academic scenes use long sentences and professional terminology, while popular science scenes use short sentences and colloquial expressions. An evaluation index of "scene fit" is introduced, which calculates the matching degree between the adjusted expanded context and the scene feature dictionary, and the similarity between the text style and the scene style to ensure that the adjustment effect meets the requirements. If the fit is lower than 0.8, the adjustment is readjusted.
[0053] Finally, the expanded document is added to the database. The target document is then merged with the adjusted expanded context to generate a document like... Figure 5 The structured documents included in the database consist of "core content - extended context - hierarchical relationship graph". The hierarchical relationship graph visually displays the position and relationship between the target document and the extended content in the hierarchical structure of the original article. The structured documents are stored in the database, and a traceability relationship is established between the extended context and the nodes of the original article, which facilitates subsequent updates and verification.
[0054] Specifically, for the inclusion of expanded documents into the database, a force-directed graph algorithm is used to construct a hierarchical relationship graph. Nodes are treated as vertices, and hierarchical relationship weights are used as edge weights. By iteratively calculating the attraction and repulsion forces between vertices, the graph layout is made reasonable and hierarchical. Different colors and shapes are assigned to different types of nodes, such as core nodes, parent nodes, child nodes, and sibling nodes, and different thicknesses are assigned to edges with different weights, intuitively distinguishing node types and relationship strengths. A three-dimensional tracing mechanism of "unique node identifier - semantic hash - version control" is employed. Each original article node is assigned a unique global identifier (UUID), and the semantic hash value of each node's text is calculated as a semantically unique identifier. Version information of the node, such as creation time, update time, and updated content, is recorded. The tracing relationship between the expanded context and the original article nodes is established through a mapping relationship of "expanded context semantic hash - node semantic hash," simultaneously associating the node's UUID and version information. The accuracy of the tracing relationship is verified to ensure that the expanded content remains consistent with the original article.
[0055] Therefore, this application achieves accuracy, efficiency and scenario adaptability in document context expansion, and solves the problems of hierarchical confusion, inaccurate selection of related nodes, semantic redundancy and poor scenario adaptability in traditional context expansion methods, and has significant innovation and practicality.
[0056] The technical solutions in the embodiments of this application will be described in detail below for specific application scenarios.
[0057] In one specific implementation, the context of an academic paper excerpt is expanded. (See reference...) Figure 6As shown, the system retrieves the target document to be added to the database. For example, it takes an abstract of a paper on "Semantic Retrieval Optimization Based on BGE (Basic Embedding, a General Text Embedding Model)" as the target document and retrieves the associated complete paper. The hierarchical parsing module parses the complete paper and generates a hierarchical structure tree of "Chapter (Full Text) - Section (Introduction, Related Work, Experimental Design, Results Analysis, Conclusion) - Subsection (e.g., "Dataset Selection" and "Model Parameter Settings" in Experimental Design) - Paragraph". The hierarchical association weight of each node is calculated. The association weight between the core node corresponding to the abstract and the parent node of the "Introduction" section is 0.92, the association weight between the core node and the child node of the "Experimental Design" subsection is 0.88, and the association weight between the core node and the BGE model comparison paragraph in "Related Work" is 0.85. After locating the core node corresponding to the abstract, the node matching module filters out the set of associated nodes, including the research background paragraph in the introduction, the model parameter details in the experimental design, the core data in the results analysis, and the BGE model comparison content in related work. The context generation module extracts the core content from the related nodes, filters out content such as experimental equipment descriptions with a correlation coefficient of less than 0.8 with "semantic retrieval optimization," and reorganizes it according to the logical chain of "research background - core abstract content - model parameters - experimental results - technical comparison" to generate expanded context. Because the scene tag is "academic research," the scene adaptation module strengthens the model parameters in the expanded content, such as the hidden layer dimension of 1024, the number of attention heads of 16, the MSMARCODE (a large-scale reading comprehension and question-answering dataset) experimental dataset and comparative data, and supplements the explanation of the professional term "semantic vector recall." The document fusion module merges the abstract and expanded context to generate a structured document containing a hierarchical association graph. The graph marks the chapter positions of the abstract and each expanded content in the original paper, completes the data entry, and provides a manual verification interface to facilitate domain experts in correcting the details of the experimental data descriptions.
[0058] In another specific implementation, the context of the enterprise product description fragment is expanded. The target document to be imported is a description fragment of the "core functions" of a smart device, and the import scenario is "enterprise training". The hierarchical parsing module parses the complete product manual. The core node corresponding to the core function fragment has a correlation weight of 0.78 with the parent node of "product development background", a correlation weight of 0.83 with the child node of "operation steps", and a correlation weight of 0.72 with the sibling node of "common problems". After filtering the associated nodes, the context generation module extracts market demand from the development background, key processes from the operation steps, and troubleshooting points from the common problems. The scenario adaptation module highlights the graphic and textual descriptions of the operation steps and training cases.
[0059] Accordingly, see Figure 7 As shown, this application embodiment provides a document context expansion device, including: The structure tree determination module 11 is used to determine the target document to be added to the database in the document management system, and to determine the original document that has a preset association relationship with the target document. The original document is then parsed to obtain the hierarchical structure tree. The node determination module 12 is used to determine a first node in the hierarchical structure tree based on the target document, and to determine a second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node; the node is a node that is associated with the text content, semantic attributes and hierarchical association weight of the original document; the hierarchical association weight is a weight that characterizes the degree of semantic dependence between the current node and the nodes other than the current node in the hierarchical structure tree. The document collection module 13 is used to generate an expanded context of the target document based on the first node and the second node, and to merge the context into the target document so as to collect the resulting merged document into the database.
[0060] In some specific embodiments, the structure tree determination module 11 specifically includes: Parse and extract target nodes from the original document, and determine the text content corresponding to the target nodes; The target words are extracted from the text content corresponding to the target node using a first pre-trained model based on BERT, the word frequency weights of the target words are determined using the TF-IDF statistical method, and the semantic weights of the target words are determined using a pre-set semantic database. The first semantic contribution of the target word is determined based on the word frequency weight and the semantic weight; Determine the first logical connector in the text content corresponding to the target node, and determine the initial weight of the corresponding connector based on the first logical connector; Determine the target position of the first logical connector in the text content corresponding to the target node, and correct the initial weight of the connector based on the target position to obtain the corrected weight; The first semantic similarity between the target nodes is determined by a BERT-based Siamese network model, and the first semantic similarity is calibrated by a penalty factor based on the hierarchical position of the target nodes to obtain a second semantic similarity. The target hierarchical association weight of the target node is determined by a preset weighted fusion formula based on the first semantic contribution, the corrected weight, and the second semantic similarity. The target semantic labels are generated by using the target node through a second pre-trained model based on document topics, and the initial semantic labels are corrected based on the hierarchical position of the target node and a preset classifier to obtain the target semantic labels. The hierarchical structure tree corresponding to the original document is determined based on the target node, the target hierarchical association weight, and the target semantic tag.
[0061] In some specific embodiments, the node determination module 12 specifically includes: The text similarity between the target document and the target node in the hierarchical structure tree is determined by the locality-sensitive hashing algorithm, and the target node whose text similarity is higher than a preset similarity threshold is identified as a candidate node; The syntactic tree similarity between the target document and the candidate nodes is determined by dependency parsing. Based on the hierarchical position of the target node and the syntactic tree similarity, a first node is determined from the candidate nodes.
[0062] In some specific embodiments, the node determination module 12 specifically includes: In the hierarchical structure tree, determine the third node other than the first node; Based on the hierarchical position of the first node, the shortest path length between the first node and the third node in the hierarchical structure tree is determined, and the shortest path length is determined as the hierarchical distance between the first node and the third node; The target words corresponding to the first node are determined based on the hierarchical association weight of the first node, and the coverage of the target words corresponding to the third node is determined based on the target words corresponding to the first node. The semantic distance to the target word corresponding to the third node is determined by the target model used to generate word vectors, and the second semantic contribution of the target word corresponding to the third node is determined based on the coverage and the semantic distance. The third node is filtered based on the hierarchical distance, the preset distance threshold, the second semantic contribution, and the preset contribution threshold to obtain the retained filtered nodes; The corresponding weight coefficients are determined based on the type of the target document, and a screening formula is constructed using the weight coefficients, hierarchical distance, and second semantic contribution. The second node is obtained by filtering the filtered nodes using the filtering formula and based on the hierarchical distance and the second semantic contribution.
[0063] In some specific embodiments, the document collection module 13 specifically includes: A first semantic role is extracted from the text content corresponding to the first node using an attention-based semantic role labeling model, and a second semantic role is extracted from the text content corresponding to the second node. The target entity is extracted from the text content corresponding to the second node using named entity recognition technology. The first semantic role and the second semantic role are matched to obtain a first matching degree, and the initial semantic unit of the second node is determined based on the second semantic role whose first matching degree is greater than a preset matching degree threshold and the target entity. Based on the initial semantic unit and the preset cosine similarity calculation method, the semantic repetition of the second node is determined, and the initial semantic units with semantic repetition greater than the preset repetition threshold are merged to obtain the first target semantic unit; The information gain of the first target semantic unit is determined based on the mutual information value between the first target semantic unit and the first node, and the first target semantic units with information gains less than a preset gain threshold are filtered to obtain the second target semantic unit. Logical labels are assigned to the second target semantic unit to obtain labeled semantic units, and an initial logical dependency graph is constructed based on the labeled semantic units and the hierarchical structure tree. The initial logical dependency graph is sorted using a topological sorting algorithm, the third semantic similarity between the labeled semantic units, and the second matching degree between the second logical connectors in the labeled semantic units, to obtain a sorted logical dependency graph. Based on an adaptive adjustment mechanism for controlling word count and using the target word count of the target document, the sorted logical dependency graph is adjusted to obtain a target logical dependency graph, and a context for expanding the target document is generated based on the target logical dependency graph.
[0064] In some specific embodiments, the document collection module 13 further includes: Determine the scene tags of the target document; The context of the generated expanded target document is dynamically adjusted based on the scene labels and the pre-trained language model to complete the context update operation.
[0065] In some specific embodiments, the document collection module 13 specifically includes: The first node and the second node in the hierarchical structure tree are determined as vertices, the hierarchical association weights of the first node and the second node are determined as the target weights between the vertices, and a hierarchical association graph is constructed based on the vertices and the target weights using a force-oriented algorithm. The context and the hierarchical relationship graph are fused into the target document, and the resulting fused document is then included in the database.
[0066] Furthermore, embodiments of this application also disclose an electronic device, Figure 8This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the document context expansion method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0067] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0068] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0069] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the document context extension method for execution by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0070] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned document context expansion method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0071] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0072] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0073] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0074] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0075] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for expanding the context of a document, characterized in that, include: Identify the target document to be added to the database in the document management system, and identify the original document that has a preset association with the target document. Perform hierarchical structure parsing on the original document to obtain the hierarchical structure tree. The first node in the hierarchical structure tree is determined based on the target document, and the second node is determined from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node. A node is a node that is associated with the text content, semantic attributes, and hierarchical association weights of the original document; the hierarchical association weights are weights that characterize the degree of semantic dependence between the current node and nodes other than the current node in the hierarchical structure tree. An expanded context is generated based on the first node and the second node, and the context is merged into the target document so that the resulting merged document is included in the database.
2. The document context expansion method according to claim 1, characterized in that, The step of parsing the hierarchical structure of the original document to obtain a hierarchical structure tree includes: Parse and extract target nodes from the original document, and determine the text content corresponding to the target nodes; The target words are extracted from the text content corresponding to the target node using a first pre-trained model based on BERT, the word frequency weights of the target words are determined using the TF-IDF statistical method, and the semantic weights of the target words are determined using a pre-set semantic database. The first semantic contribution of the target word is determined based on the word frequency weight and the semantic weight; Determine the first logical connector in the text content corresponding to the target node, and determine the initial weight of the corresponding connector based on the first logical connector; Determine the target position of the first logical connector in the text content corresponding to the target node, and correct the initial weight of the connector based on the target position to obtain the corrected weight; The first semantic similarity between the target nodes is determined by a BERT-based Siamese network model, and the first semantic similarity is calibrated by a penalty factor based on the hierarchical position of the target nodes to obtain a second semantic similarity. The target hierarchical association weight of the target node is determined by a preset weighted fusion formula based on the first semantic contribution, the corrected weight, and the second semantic similarity. The target semantic labels are generated by using the target node through a second pre-trained model based on document topics, and the initial semantic labels are corrected based on the hierarchical position of the target node and a preset classifier to obtain the target semantic labels. The hierarchical structure tree corresponding to the original document is determined based on the target node, the target hierarchical association weight, and the target semantic tag.
3. The document context expansion method according to claim 2, characterized in that, Determining the first node in the hierarchical structure tree based on the target document includes: The text similarity between the target document and the target node in the hierarchical structure tree is determined by the locality-sensitive hashing algorithm, and the target node whose text similarity is higher than a preset similarity threshold is identified as a candidate node; The syntactic tree similarity between the target document and the candidate nodes is determined by dependency parsing. Based on the hierarchical position of the target node and the syntactic tree similarity, a first node is determined from the candidate nodes.
4. The document context expansion method according to claim 1, characterized in that, The step of determining the second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node includes: In the hierarchical structure tree, determine the third node other than the first node; Based on the hierarchical position of the first node, the shortest path length between the first node and the third node in the hierarchical structure tree is determined, and the shortest path length is determined as the hierarchical distance between the first node and the third node; The target words corresponding to the first node are determined based on the hierarchical association weight of the first node, and the coverage of the target words corresponding to the third node is determined based on the target words corresponding to the first node. The semantic distance to the target word corresponding to the third node is determined by the target model used to generate word vectors, and the second semantic contribution of the target word corresponding to the third node is determined based on the coverage and the semantic distance. The third node is filtered based on the hierarchical distance, the preset distance threshold, the second semantic contribution, and the preset contribution threshold to obtain the retained filtered nodes; The corresponding weight coefficients are determined based on the type of the target document, and a screening formula is constructed using the weight coefficients, hierarchical distance, and second semantic contribution. The second node is obtained by filtering the filtered nodes using the filtering formula and based on the hierarchical distance and the second semantic contribution.
5. The document context expansion method according to claim 1, characterized in that, The process of generating an expanded context for the target document based on the first node and the second node includes: A first semantic role is extracted from the text content corresponding to the first node using an attention-based semantic role labeling model, and a second semantic role is extracted from the text content corresponding to the second node. The target entity is extracted from the text content corresponding to the second node using named entity recognition technology. The first semantic role and the second semantic role are matched to obtain a first matching degree, and the initial semantic unit of the second node is determined based on the second semantic role whose first matching degree is greater than a preset matching degree threshold and the target entity. Based on the initial semantic unit and the preset cosine similarity calculation method, the semantic repetition of the second node is determined, and the initial semantic units with semantic repetition greater than the preset repetition threshold are merged to obtain the first target semantic unit; The information gain of the first target semantic unit is determined based on the mutual information value between the first target semantic unit and the first node, and the first target semantic units with information gains less than a preset gain threshold are filtered to obtain the second target semantic unit. Logical labels are assigned to the second target semantic unit to obtain labeled semantic units, and an initial logical dependency graph is constructed based on the labeled semantic units and the hierarchical structure tree. The initial logical dependency graph is sorted using a topological sorting algorithm, the third semantic similarity between the labeled semantic units, and the second matching degree between the second logical connectors in the labeled semantic units, to obtain a sorted logical dependency graph. Based on an adaptive adjustment mechanism for controlling word count and using the target word count of the target document, the sorted logical dependency graph is adjusted to obtain a target logical dependency graph, and a context for expanding the target document is generated based on the target logical dependency graph.
6. The document context expansion method according to any one of claims 1 to 5, characterized in that, The generation of the context that expands the target document also includes: Determine the scene tags of the target document; The context of the generated expanded target document is dynamically adjusted based on the scene labels and the pre-trained language model to complete the context update operation.
7. The document context expansion method according to claim 1, characterized in that, The step of fusing the context into the target document, and then adding the resulting fused document to the database, includes: The first node and the second node in the hierarchical structure tree are determined as vertices, the hierarchical association weights of the first node and the second node are determined as the target weights between the vertices, and a hierarchical association graph is constructed based on the vertices and the target weights using a force-oriented algorithm. The context and the hierarchical relationship graph are fused into the target document, and the resulting fused document is then included in the database.
8. A document context expansion device, characterized in that, include: The structure tree determination module is used to determine the target document to be added to the database in the document management system, and to determine the original document that has a preset association relationship with the target document. The original document is then parsed to obtain the hierarchical structure tree. A node determination module is used to determine a first node in the hierarchical structure tree based on the target document, and to determine a second node from the hierarchical structure tree based on the hierarchical position and hierarchical association weight of the first node; A node is a node that is associated with the text content, semantic attributes, and hierarchical association weights of the original document; the hierarchical association weights are weights that characterize the degree of semantic dependence between the current node and nodes other than the current node in the hierarchical structure tree. The document collection module is used to generate an expanded context for the target document based on the first node and the second node, and to merge the context into the target document so as to collect the resulting merged document into the database.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the document context expansion method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer program is executed by a processor, it implements the document context expansion method as described in any one of claims 1 to 7.