arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2205.00424cs.SE
收藏

跨语言程序分类的统一抽象树表示学习

Unified Abstract Syntax Tree Representation Learning for Cross-Language Program Classification

Kesu Wang, Meng Yan, He Zhang, Haibo Hu

摘要:

程序分类可以看作是对代码的一种高层抽象,为与源代码理解相关的各种任务奠定基础,在软件工程领域有着非常广泛的应用,如代码克隆检测、代码气味分类、缺陷分类等。跨语言程序分类可以实现不同程序设计语言的代码迁移,并且还可以促进跨语言代码重用,从而帮助开发人员快速编写代码,减少代码迁移的开发时间。现有的研究大多集中在代码的语义学习,而很少有研究致力于跨语言任务。跨语言程序分类的主要挑战是如何提取不同程序设计语言的语义特征。为了解决这一问题,本文提出了一种统一抽象树(UAST)神经网络。具体而言,UAST的核心思想包括两个统一的机制。首先,UAST通过统一AST遍历序列和图形化AST结构来学习AST表示,以捕获语义代码特征。其次,我们构建了一种称为统一词汇表的机制,它可以减少不同程序设计语言之间的特征差距,从而可以达到跨语言程序分类的作用。此外,我们还收集了一个包含5种程序设计语言的20,000个文件的数据集,可以作为跨语言程序分类任务的基准数据集。我们在两个数据集上进行了实验,结果表明,我们提出的方法在四个评估指标(精度,召回率,F1分数和准确性)方面优于最先进的基线。

英文摘要:

Program classification can be regarded as a high-level abstraction of code, laying a foundation for various tasks related to source code comprehension, and has a very wide range of applications in the field of software engineering, such as code clone detection, code smell classification, defects classification, etc. The cross-language program classification can realize code transfer in different programming languages, and can also promote cross-language code reuse, thereby helping developers to write code quickly and reduce the development time of code transfer. Most of the existing studies focus on the semantic learning of the code, whilst few studies are devoted to cross-language tasks. The main challenge of cross-language program classification is how to extract semantic features of different programming languages. In order to cope with this difficulty, we propose a Unified Abstract Syntax Tree (namely UAST in this paper) neural network. In detail, the core idea of UAST consists of two unified mechanisms. First, UAST learns an AST representation by unifying the AST traversal sequence and graph-like AST structure for capturing semantic code features. Second, we construct a mechanism called unified vocabulary, which can reduce the feature gap between different programming languages, so it can achieve the role of cross-language program classification. Besides, we collect a dataset containing 20,000 files of five programming languages, which can be used as a benchmark dataset for the cross-language program classification task. We have done experiments on two datasets, and the results show that our proposed approach outperforms the state-of-the-art baselines in terms of four evaluation metrics (Precision, Recall, F1-score, and Accuracy).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑