Code review report construction method
By combining code detection methods with static and dynamic features, and utilizing program dependency graphs and BERT models for high-precision matching of errors and knowledge points, this approach solves the problems of low detection accuracy and insufficient knowledge association in existing technologies, and achieves efficient identification of errors and automated location of knowledge points in complex logical structures.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI UNIV
- Filing Date
- 2026-01-09
- Publication Date
- 2026-05-19
AI Technical Summary
Existing code detection methods mostly rely on static feature extraction, which makes it difficult to capture the dynamic behavior features of code at runtime. They also lack a deep understanding of program intent, contextual dependencies, and cross-statement logical relationships, resulting in low accuracy of detection results in complex control structures or multi-function interaction scenarios, and a lack of adaptability in knowledge association.
By jointly modeling static structural features and dynamic operational features, and combining program dependency graphs and the contextual semantics of the BERT model, a multi-dimensional code semantic representation is constructed. A knowledge triple embedding representation mechanism is introduced to achieve high-precision semantic association between errors and knowledge points. Graph attention networks and cross-attention mechanisms are used for feature fusion and matching.
It improves the accuracy of error identification and the automation of knowledge location, enabling the identification of potential anomalies in complex logical structures, achieving high-precision matching of errors and knowledge points, and possessing technical advantages of strong interpretability and high scalability.
Smart Images

Figure CN122065833A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of program semantic analysis and intelligent code diagnosis technology, and in particular to a method for constructing code review reports. Background Technology
[0002] In scenarios such as programming education, intelligent assessment, and automated review, systems typically need to identify logical errors, pinpoint their causes, and provide targeted knowledge reference feedback based on the source code submitted by developers. To achieve these goals, existing research mainly focuses on two directions: static code analysis and semantic modeling.
[0003] Currently, mainstream code inspection methods primarily rely on static analysis. These methods can capture the syntactic structure and variable dependencies of code, identify potential structural defects at compile time, and support syntactic integrity verification and local logic checks. Meanwhile, semantic modeling methods are typically based on deep learning models, using contextual representation learning to understand and express the meaning of code, providing support for semantic similarity calculation and knowledge reasoning.
[0004] In recent years, some research has begun to explore dynamic analysis and program execution tracing methods. By monitoring information such as execution paths, memory access, and variable state changes, these methods further reveal the true behavior of code during execution. These methods can help detect runtime anomalies, such as array out-of-bounds errors, recursion failures, and resource leaks. Meanwhile, the combination of knowledge graphs and code semantic analysis has also become a research hotspot. By establishing the relationship between "error type—knowledge point—solution," these methods explore automated knowledge delivery mechanisms for teaching and intelligent assessment.
[0005] Overall, the current technology system has initially formed a multi-layer detection framework from static structural analysis to semantic understanding and then to knowledge mapping. However, there is still room for further research in terms of the depth of structure-semantic fusion, the way dynamic features are utilized, and the adaptability of knowledge association. Summary of the Invention
[0006] In view of the aforementioned shortcomings of existing technologies, the technical problem to be solved by this invention is that existing detection methods mostly rely on static feature extraction, analyzing only structural information such as abstract syntax trees, control flow graphs, or program dependency graphs. This makes it difficult to capture the dynamic behavioral characteristics of code during runtime, such as variable state changes, abnormal triggering paths, and implicit logical errors, resulting in low accuracy of detection results in complex control structures or multi-function interaction scenarios. Secondly, in terms of semantic layer modeling, traditional methods often lack a deep understanding of program intent, contextual dependencies, and cross-statement logical relationships, making it difficult to identify potential error types that are semantically equivalent but structurally different. Furthermore, in the knowledge association stage, existing systems generally rely on manually defined rules or static templates to map detection results to teaching knowledge points, lacking adaptive semantic matching and reasoning capabilities, making it difficult to achieve high-precision automated alignment between errors and knowledge points. This invention provides a code review report construction method. This method takes the joint modeling of static structural features and dynamic runtime features as its core. By sequentially executing steps such as structural feature extraction, semantic feature modeling, graph attention fusion, and interactive semantic matching, it constructs a multi-dimensional code semantic representation, jointly modeling static structural features and dynamic runtime features to achieve multi-dimensional expression of code semantics. By combining the structural dependencies of the program dependency graph with the contextual semantics of the BERT model, an error representation with both global dependency and semantic understanding capabilities is formed. This method introduces a knowledge triple embedding mechanism to achieve adaptive semantic alignment between code structural features and semantic features, thereby establishing a high-precision semantic link between errors and knowledge points. This effectively improves the accuracy of error identification and the automation of knowledge localization. In intelligent programming teaching and generative feedback scenarios, it possesses strong interpretability and scalability advantages, providing a new implementation path for the integration of code semantic analysis and teaching knowledge graphs.
[0007] To achieve the above objectives, this invention provides a method for constructing code review reports, based on graph structure and output semantic fusion knowledge graph matching, including the following steps:
[0008] Perform static and dynamic joint analysis on the input source code to generate a program dependency graph (PDG) structure, as well as runtime logs and exception outputs.
[0009] Graph Attention Network (GAT) is used to enhance the embedding of structure extracted from program dependency graphs;
[0010] The pre-trained BERT model was used to embed contextual semantic features into knowledge nodes in dynamic error logs and knowledge graphs.
[0011] Weighted average pooling is performed on graph structure feature embeddings and semantic feature embeddings to compress redundant information and highlight key features;
[0012] A Cross-Attention mechanism is adopted in the cross-semantic interaction layer to align the error semantic space with the knowledge semantic space;
[0013] The fused semantic features are input into a multilayer perceptron (MLP) to calculate the matching score, and the semantic association and ranking of errors and knowledge points are completed and output based on the score results.
[0014] Furthermore, the steps for generating the program dependency graph structure (PDG) include:
[0015] Based on the static syntax parsing results of the source code, extract code blocks, function calls, variable references, and control structures;
[0016] Control edges are generated through control dependency analysis to describe logical control relationships such as "condition-branch" and "loop-body".
[0017] Data edges are generated through data dependency analysis to represent variable passing relationships such as "definition-use" and "assignment-reference".
[0018] Finally, a directed dependency graph structure PDG containing a set of nodes and a set of edges is constructed, providing a foundation for subsequent graph structure embedding.
[0019] Furthermore, the graph attention network GAT is used to enhance the embedding of the program dependency graph extraction structure, including any node in the PDG. Its neighboring nodes Attention weights Based on the joint calculation of node feature similarity and edge type weights, the structure-enhanced embedding is finally obtained through multi-layer GAT propagation. .
[0020] Furthermore, the semantic feature embeddings of the pre-trained BERT model include
[0021] Error logs and knowledge node text are input into the pre-trained BERT model to extract context vectors from multiple Transformers;
[0022] The semantic embedding matrix is obtained through feature concatenation and layer normalization. and The former retains dynamic semantic difference information, while the latter retains the conceptual semantics and triplet structure semantics of knowledge nodes.
[0023] Furthermore, weighted average pooling includes pooling based on node weights. Embedded features A weighted average is performed, with the weights determined by the semantic saliency of the nodes and the attention distribution. The resulting vector represents the compression result of the global semantics and is used for subsequent cross-semantic alignment.
[0024] Furthermore, the Cross-Attention alignment mechanism includes
[0025] The overall semantic vector will be dynamically run. As a query The semantic set of knowledge graph nodes For K, V, structural semantics As a contextual enhancement, the Cross-Attention layer uses this matrix to calculate semantic alignment weights, enabling dynamic matching of erroneous segments with knowledge points.
[0026] Furthermore, the process of calculating the matching score using a multilayer perceptron (MLP) includes: inputting the aligned fused features into a fully connected neural network of two or more layers, and outputting a matching score with a dimension of 1. for The activation function has a higher score, indicating a stronger semantic consistency between the error and the knowledge point.
[0027] Furthermore, knowledge nodes in the knowledge graph are in the form of triples. This means that the structural information of triples is preserved through BERT's context window, ensuring that the relational constraints and conceptual hierarchy of knowledge nodes can be reflected during semantic alignment.
[0028] Furthermore, the output includes an error and knowledge matching score table and corresponding explanatory text, which is generated based on an alignment attention matrix and is used to display error attribution and knowledge point guidance in the intelligent teaching system. Technical effect
[0029] This invention achieves intelligent processing that integrates static and dynamic error detection with knowledge matching by fusing program structure information and deep semantic features, resulting in the following significant technical advantages:
[0030] This invention jointly models code control flow and data flow using program dependency graphs and graph attention networks, enhancing the system's ability to identify complex logical structures and potential anomalies. An extensible dynamic feature enhancement mechanism enables the system to identify runtime errors, capturing hidden errors that static analysis cannot detect. Through semantic embedding and cross-attention mechanisms of the BERT model, it achieves dual-channel synergy of structure and semantics, effectively addressing error types that are semantically similar but have significant differences in syntactic structure. A multilayer perceptron enables nonlinear semantic alignment, improving the accuracy and interpretability of error-to-knowledge matching. This invention requires no manual rules; it can automatically complete the "error pattern → knowledge point" mapping through feature fusion and deep learning, significantly improving the adaptability and teaching value of automated evaluation and intelligent teaching systems.
[0031] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0032] Figure 1 This is a flowchart illustrating a preferred embodiment of a code review report construction method according to the present invention;
[0033] Figure 2 This is a schematic diagram of a multi-source feature fusion extraction process based on static and dynamic semantics for a code review report construction method according to a preferred embodiment of the present invention. Detailed Implementation
[0034] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present 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 merely illustrative of the present invention and are not intended to limit the present invention.
[0035] In the following description, specific details, such as particular internal procedures and techniques, are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the invention. However, those skilled in the art will appreciate that the invention may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of the invention with unnecessary detail.
[0036] This invention provides a method for constructing code review reports, based on graph structure and output semantic fusion knowledge graph matching, including the following steps:
[0037] Step 1 involves performing joint static and dynamic analysis on the input source code to generate a program dependency graph (PDG) structure, runtime logs, and exception outputs. The steps for generating the PDG include:
[0038] Based on the static syntax parsing results of the source code, extract code blocks, function calls, variable references, and control structures;
[0039] Control edges are generated through control dependency analysis to describe logical control relationships such as "condition-branch" and "loop-body".
[0040] Data edges are generated through data dependency analysis to represent variable passing relationships such as "definition-use" and "assignment-reference".
[0041] Finally, a directed dependency graph structure PDG containing a set of nodes and a set of edges is constructed, providing a foundation for subsequent graph structure embedding.
[0042] The implementation process of step one includes step 101, which extracts the static code structure by generating AST and deriving PDG, so that the control dependencies and data dependencies of the code are represented in the form of a graph structure;
[0043] Step 102: The system receives the source code file C and its corresponding compilation or runtime error log E, and locates the code fragments related to the errors through lexical and syntactic preprocessing. At the same time, it extracts line index and token fragment information to provide input for subsequent structural analysis and semantic modeling.
[0044] Step two involves using a graph attention network (GAT) to enhance the embedding of the program dependency graph structure; this includes processing any node in the PDG. Its neighboring nodes Attention weights Based on the joint calculation of node feature similarity and edge type weights, the structure-enhanced embedding is finally obtained through multi-layer GAT propagation. Specifically, step 103, the graph attention propagation GAT structural feature extraction module, further introduces a multi-layer graph attention network GAT on the program dependency graph PDG to perform weighted modeling of the dependencies between nodes, and obtains a structure-enhanced code feature representation.
[0045] Step 3: The pre-trained BERT model is used to embed contextual semantic features into the dynamic error logs and knowledge nodes in the knowledge graph. The error logs and knowledge node texts are input into the pre-trained BERT model to extract context vectors from multiple Transformers. The semantic embedding matrix is obtained through feature concatenation and layer normalization. and The former retains dynamic semantic difference information, while the latter retains the conceptual semantics and triplet structure semantics of knowledge nodes.
[0046] The implementation process of step three includes: step 104, dynamic code analysis and semantic feature extraction, inputting the located code fragment P and the corresponding error log text E into the pre-trained language model BERT to obtain semantic embeddings containing contextual information, which are used to characterize code behavior and error semantic features;
[0047] Step 105: Extract the contextual semantic features of knowledge graph triples, and simultaneously extract the knowledge triples from the knowledge graph. Perform text processing to construct a set of knowledge nodes for semantic matching.
[0048] Step four involves performing weighted average pooling on the graph structure feature embedding and semantic feature embedding to compress redundant information and highlight key features; weighted average pooling includes processing based on node weights. Embedded features A weighted average is performed, with the weights determined by the semantic saliency of the nodes and the attention distribution. The resulting vector represents the compression result of the global semantics and is used for subsequent cross-semantic alignment.
[0049] The implementation process of step four includes step 106, weighted average pooling to compress and highlight key information, weighted average pooling of the structural features and semantic embedding features output by the graph attention network, compressing redundant information and highlighting key semantic and structural features through node weights to form a structure-enhanced code representation.
[0050] Step 5: Employ the Cross-Attention mechanism in the cross-semantic interaction layer to align the error semantic space with the knowledge semantic space; the Cross-Attention alignment mechanism includes:
[0051] The overall semantic vector will be dynamically run. As a query The semantic set of knowledge graph nodes For K, V, structural semantics As a contextual enhancement, the Cross-Attention layer uses this matrix to calculate semantic alignment weights, enabling dynamic matching of erroneous segments with knowledge points. Knowledge nodes in the knowledge graph are in the form of triples. This means that the structural information of triples is preserved through BERT's context window, ensuring that the relational constraints and conceptual hierarchy of knowledge nodes can be reflected during semantic alignment.
[0052] The implementation process of step five includes step 107, aligning the semantic space across the cross-channel interaction layer, introducing a cross-channel attention mechanism, using the error semantic vector as a query, aligning the semantic vectors of knowledge nodes, and realizing dynamic matching between the error semantic space and the knowledge semantic space.
[0053] Step six involves inputting the fused semantic features into a multilayer perceptron (MLP) to calculate the matching score, and then outputting the semantic association and ranking of errors and knowledge points based on the score results. The MLP calculation of the matching score includes: inputting the aligned fused features into a two- or more fully connected neural network, outputting a matching score with a dimension of 1. for The activation function assigns a higher score, indicating a stronger semantic consistency between the error and the knowledge point. The output includes an error-knowledge matching score table and corresponding explanatory text. This explanatory text, generated based on an alignment attention matrix, is used in the intelligent teaching system to demonstrate error attribution and knowledge point guidance.
[0054] The implementation process of step six includes step 108, discriminant vector construction, MLP scoring, and interpretable output.
[0055] The specific implementation methods of the above steps will be described in detail below with reference to specific embodiments.
[0056] like Figure 1 As shown, this invention provides a method for constructing a code review report, specifically including the following steps:
[0057] Steps 101 to 104 are detailed as follows: Figure 2 As shown:
[0058] Step 101 involves extracting the static code structure through AST generation and PDG derivation, representing the control dependencies and data dependencies of the code in a graph structure, specifically including:
[0059] Input code snippet Use a language-specific parser to generate an abstract syntax tree .
[0060] Traverse the AST and identify the set of syntax nodes. This includes functions, conditions, loops, assignments, and calls.
[0061] Determine if control flow or data flow exists. If not, directly use the AST sequence to replace the structural features.
[0062] If control flow or data flow exists, construct the Program Dependency Graph (PDG) structure based on control flow analysis and symbol table to obtain a directed graph:
[0063]
[0064] The set of edges ,
[0065] Controlling dependency edges:
[0066]
[0067] Data dependency edges:
[0068]
[0069] Finally obtained This lays the foundation for subsequent graph-based structural feature learning.
[0070] Step 102: The system receives the source code file C and its corresponding compilation or runtime error log E, and locates the error-related code segments through lexical and syntactic preprocessing. Simultaneously, it extracts line index and token fragment information to provide input for subsequent structural analysis and semantic modeling, specifically including:
[0071] Input source code file Compilation and runtime error logs It includes error type, line number, stack trace, runtime variable snapshot, etc.
[0072] Lexical and grammatical preprocessing: removing comments, blank lines, and redundant spaces; preparing for lexical analysis and grammatical parsing.
[0073] According to the error log The line number or backtracking information in the code snippet is used to locate the code snippet related to the error. If precise location is not available, several candidate segments are selected heuristically based on the top of the exception stack or the exception type.
[0074] from Extract runtime context Generate a runtime context sequence.
[0075] Finally return .
[0076] Step 103, the Graph Attention Propagation (GAT) structural feature extraction module, further introduces a multi-layer graph attention network (GAT) onto the program dependency graph (PDG) to perform weighted modeling of the dependencies between nodes, obtaining a structure-enhanced code feature representation, specifically including:
[0077] Input PDG directed graph (Step 101 output), apply multi-layer graph attention GAT to compute structure embedding: for any node , its first Layer output is
[0078]
[0079] Attention weight
[0080]
[0081]
[0082] in , For learnable parameter matrices / vectors, This represents vector concatenation. This represents the edge type weight scalar applied based on the edge type (control flow, data flow). After... The structural feature matrix is obtained after layer iteration.
[0083]
[0084] Calculate the rate of change of node features between two iterations: If any of the following conditions are met:
[0085] (1) (Embedding change is less than the threshold ε);
[0086] (2) (Maximum number of floors reached);
[0087] If convergence is confirmed, the final output will be a structural feature matrix that corresponds one-to-one with the PDG node indices. Otherwise, continue iteratively updating the... layer.
[0088] Step 104, dynamic code analysis and semantic feature extraction: Input the located code fragment P and the corresponding error log text E into the pre-trained language model BERT to obtain semantic embeddings containing contextual information, which are used to characterize code behavior and error semantic features, specifically including:
[0089] code snippet Error log text Remove meaningless whitespace and retain line number information for mapping; mark comments and strings to preserve the original text semantics.
[0090] Input code snippet Error log text ,Will and The inputs are processed by BERT, which performs word segmentation, position and segment embedding, and multi-layer Transformer encoder to obtain context-sensitive token-level embedding sequences. Each token embeds Pooling yields the dynamic overall semantic vector. .
[0091] Calculate the cosine similarity between code semantics and error semantics. and the average attention entropy of the model output :
[0092]
[0093]
[0094] To determine if the model confidence level is too low, if... The semantic association between code and error is weak or non-linear. High attentional dispersion leads to low confidence, triggering the dynamic fine-tuning module: selecting samples corresponding to the error logs and code, performing mini-batch gradient updates, optimizing BERT parameters, and then re-encoding to generate new samples. Otherwise, the current semantic vector is directly passed to the next stage fusion module.
[0095] Step 105: Extract the contextual semantic features of knowledge graph triples, and simultaneously extract the knowledge triples from the knowledge graph. Textualization is performed to construct a knowledge node set for semantic matching, specifically including:
[0096] Input knowledge triple set Perform text concatenation on each triple:
[0097] ,
[0098] And on The process involves word segmentation, sub-wordization, stop word removal, and normalization to obtain a preprocessed set of knowledge node texts. .
[0099] For each knowledge node Input BERT to get And pooling to obtain the semantic vector of the knowledge node:
[0100]
[0101] Step 106: Weighted average pooling compresses and highlights key information. Weighted average pooling is applied to the structural features and semantic embedding features output by the graph attention network. Redundant information is compressed and key semantic and structural features are highlighted through node weights, forming a structure-enhanced code representation. Specifically, this includes:
[0102] Input static analysis structure embedding Dynamic analysis of semantic embedding Knowledge node semantic vector .
[0103] For each node Perform node-level structural and semantic fusion:
[0104]
[0105] Calculate the scores and normalize them into weights:
[0106] ,in For scoring networks.
[0107] The final structure-enhanced representation is obtained as follows:
[0108]
[0109] Step 107: Align the semantic space across the cross-channel interaction layer by introducing a cross-channel attention mechanism. Using the error semantic vector as a query, align the semantic vectors of knowledge nodes to achieve dynamic matching between the error semantic space and the knowledge semantic space. Specifically, this includes:
[0110] The overall semantic vector will be dynamically run. As a query The semantic set of knowledge graph nodes For Key and Value, structural semantics As a context enhancement, calculate attention:
[0111] ,
[0112]
[0113] Calculate interactive output:
[0114]
[0115] After obtaining the interaction vectors, they are concatenated and transformed to obtain the error fusion representation and the knowledge node fusion representation:
[0116]
[0117]
[0118] in, This provides lightweight structural features for knowledge nodes when necessary. The final result is the error fusion vector. Knowledge Node Fusion Collection and attention distribution .
[0119] Step 108, discriminant vector construction, MLP scoring, and interpretable output, specifically includes:
[0120] Input error fusion vector Knowledge Node Fusion Collection and attention distribution For each knowledge node Construct a discriminant vector and calculate the matching score using a multilayer perceptron. Let the discriminant vector be a concatenated vector:
[0121] ,in This represents element-wise product.
[0122] Will Input a two-layer MLP:
[0123]
[0124]
[0125] in For errors and knowledge nodes The matching confidence score, This is the Sigmoid function. The system presses... Output the Top-K matching nodes in descending order and assign the corresponding attention weights. Map high-weight nodes in the PDG back to the original code to generate an interpretation path.
[0126] The final score sequence is obtained. The system generates a Top-K matching node list and an explanatory evidence path. Through these steps, the system ultimately achieves semantic matching and ranking output between errors and knowledge nodes, and combines attention weights and high-weight nodes in the program dependency graph to generate an explanatory error attribution path.
[0127] This invention provides a multi-layer code error detection method based on structural semantic fusion and knowledge association, constructing a unified detection framework from static structural analysis to dynamic semantic understanding and knowledge point matching. By introducing a multi-layer graph attention network (GAT) onto the program dependency graph structure (PDG), deep modeling of code structural dependencies is achieved, obtaining feature embeddings with local structure sensitivity. Simultaneously, the BERT model is used to extract semantic features from code and error logs, capturing contextual dependency information between code behavior and semantic logic. In the structural semantic fusion stage, a cross-channel attention mechanism aligns and fuses structural embeddings, error semantic vectors, and knowledge node representations to form a unified high-dimensional representation space, achieving multi-modal collaborative expression from the structural layer to the semantic layer. This method overcomes the limitations of traditional code detection that relies solely on static features or shallow semantics, enabling the understanding of runtime semantics and knowledge associations while preserving the program's logical structure, significantly improving the accuracy and interpretability of error detection.
[0128] In educational settings, this method can automatically detect student code errors and align them with knowledge points, assisting teaching systems in providing personalized feedback. In the fields of software engineering and code review, it can be used to locate complex logical errors and recommend error repairs based on knowledge graphs, demonstrating broad practical value and expansion potential.
[0129] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A method for constructing a code review report, characterized in that, Knowledge graph matching based on graph structure and output semantic fusion includes the following steps: Perform static and dynamic joint analysis on the input source code to generate a program dependency graph (PDG) structure, as well as runtime logs and exception outputs. Graph Attention Network (GAT) is used to enhance the embedding of structure extracted from program dependency graphs; The pre-trained BERT model was used to embed contextual semantic features into knowledge nodes in dynamic error logs and knowledge graphs. Weighted average pooling is performed on graph structure feature embeddings and semantic feature embeddings to compress redundant information and highlight key features; A Cross-Attention mechanism is adopted in the cross-semantic interaction layer to align the error semantic space with the knowledge semantic space; The fused semantic features are input into a multilayer perceptron (MLP) to calculate the matching score, and the semantic association and ranking of errors and knowledge points are completed and output based on the score results.
2. The code review report construction method as described in claim 1, characterized in that, The steps for generating a program dependency graph (PDG) include: Based on the static syntax parsing results of the source code, extract code blocks, function calls, variable references, and control structures; Control edges are generated through control dependency analysis to describe logical control relationships such as "condition-branch" and "loop-body". Data edges are generated through data dependency analysis to represent variable passing relationships such as "definition-use" and "assignment-reference". Finally, a directed dependency graph structure PDG containing a set of nodes and a set of edges is constructed, providing a foundation for subsequent graph structure embedding.
3. The code review report construction method as described in claim 1, characterized in that, Enhanced embedding of program dependency graph extraction structure using graph attention network (GAT), including any node in the PDG. Its neighboring nodes Attention weights Based on the joint calculation of node feature similarity and edge type weights, the structure-enhanced embedding is finally obtained through multi-layer GAT propagation. .
4. The code review report construction method as described in claim 1, characterized in that, The semantic feature embeddings of the pre-trained BERT model include Error logs and knowledge node text are input into the pre-trained BERT model to extract context vectors from multiple Transformers; The semantic embedding matrix is obtained through feature concatenation and layer normalization. and The former retains dynamic semantic difference information, while the latter retains the conceptual semantics and triplet structure semantics of knowledge nodes.
5. The code review report construction method as described in claim 1, characterized in that, Weighted average pooling includes pooling based on node weights. Embedded features A weighted average is performed, with the weights determined by the semantic saliency of the nodes and the attention distribution. The resulting vector represents the compression result of the global semantics and is used for subsequent cross-semantic alignment.
6. The code review report construction method as described in claim 1, characterized in that, Cross-Attention alignment mechanisms include: The overall semantic vector will be dynamically run. As a query The semantic set of knowledge graph nodes For K, V, structural semantics As a contextual enhancement, the Cross-Attention layer uses this matrix to calculate semantic alignment weights, enabling dynamic matching of erroneous segments with knowledge points.
7. The code review report construction method as described in claim 1, characterized in that, The process of calculating the matching score using a Multilayer Perceptron (MLP) includes: inputting the aligned fused features into a fully connected neural network of two or more layers, and outputting a matching score with a dimension of 1; whereby... for The activation function has a higher score, indicating a stronger semantic consistency between the error and the knowledge point.
8. The code review report construction method as described in claim 6, characterized in that, Knowledge nodes in a knowledge graph are in the form of triples. This means that the structural information of triples is preserved through BERT's context window, ensuring that the relational constraints and conceptual hierarchy of knowledge nodes can be reflected during semantic alignment.
9. The code review report construction method as described in claim 1, characterized in that, The output includes an error-knowledge matching score table and corresponding explanatory text, which is generated based on an alignment attention matrix and is used to display error attribution and knowledge point guidance in the intelligent teaching system.