基于抽象语法树(AST)的异构有向超图神经网络用于代码分类
Heterogeneous Directed Hypergraph Neural Network over abstract syntax tree (AST) for Code Classification
AI总结:
针对现有代码分类方法忽略AST中高阶关联及语义结构信息的问题,提出异构有向超图及其神经网络,在Python和Java数据集上超越现有方法。
摘要:
代码分类是程序理解和自动编码中的一个难题。由于程序中语法的难以捉摸和语义的复杂性,大多数现有研究使用基于抽象语法树(AST)和图神经网络(GNN)的技术来为代码分类创建代码表示。这些技术利用了代码的结构和语义信息,但它们只考虑了成对关联,忽略了AST中同一字段或称为属性的节点之间已经存在的高阶数据相关性,这可能导致代码结构信息的丢失。另一方面,虽然一般超图可以编码高阶数据相关性,但它是同质且无向的,这将在建模AST时导致缺乏语义和结构信息,如节点类型、边类型以及子节点和父节点之间的方向。在本研究中,我们提出了一种异构有向超图(HDHG)来表示AST,以及一种异构有向超图神经网络(HDHGN)来处理该图以进行代码分类。我们的方法提高了代码理解能力,并且可以表示超越成对交互的高阶数据相关性。我们在Python和Java程序的公开数据集上评估了我们的异构有向超图神经网络(HDHGN)。我们的方法优于以前基于AST和基于GNN的方法,这证明了我们模型的能力。
英文摘要:
Code classification is a difficult issue in program understanding and automatic coding. Due to the elusive syntax and complicated semantics in programs, most existing studies use techniques based on abstract syntax tree (AST) and graph neural network (GNN) to create code representations for code classification. These techniques utilize the structure and semantic information of the code, but they only take into account pairwise associations and neglect the high-order data correlations that already exist between nodes of the same field or called attribute in the AST, which may result in the loss of code structural information. On the other hand, while a general hypergraph can encode high-order data correlations, it is homogeneous and undirected which will result in a lack of semantic and structural information such as node types, edge types, and directions between child nodes and parent nodes when modeling AST. In this study, we propose a heterogeneous directed hypergraph (HDHG) to represent AST and a heterogeneous directed hypergraph neural network (HDHGN) to process the graph for code classification. Our method improves code understanding and can represent high-order data correlations beyond paired interactions. We assess our heterogeneous directed hypergraph neural network (HDHGN) on public datasets of Python and Java programs. Our method outperforms previous AST-based and GNN-based methods, which demonstrates the capability of our model.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。