The invention discloses a
code clone detection method based on a GAT graph neural
network model, and the method comprises the following steps: extracting and generating clone code data of a corresponding definition from a
programming competition website and an existing
code clone data set according to the definition of a clone code; analyzing the code text to generate an AST
abstract syntax tree; adding an artificially defined additional edge on the basis of the AST
abstract syntax tree to generate a representation graph; inputting the code representation graph into a GAT
network model for training to obtain a graph representation vector; splicing representation vectors of the
cloning code pairs and inputting the representation vectors into a
binary classification network; and judging an output code
cloning prediction result. According to the method, the problem that the code semantic clone detection capability is insufficient in the
code clone detection field is solved, the code text is converted into the graph structure representation, clone code information is represented from the semantic and
structural level, the internal relation of learning clone codes can be accurately obtained, clone code judgment and prediction are carried out, and the code clone detection accuracy is improved.