引用本文:周光有,谢琦,余啸.基于关系图卷积网络的代码搜索方法.软件学报,2024,35(6):2863-2879
【打印本页】   【下载PDF全文】   查看/发表评论  【EndNote】   【RefMan】   【BibTex】
←前一篇|后一篇→ 过刊浏览    高级检索
本文已被:浏览 1290次   下载 3916 本文二维码信息
码上扫一扫!
分享到: 微信 更多
基于关系图卷积网络的代码搜索方法
周光有1, 谢琦1, 余啸2
1.华中师范大学 计算机学院, 湖北 武汉 430079;2.武汉理工大学 计算机与人工智能学院, 湖北 武汉 430070
摘要:
代码搜索是当下自然语言处理和软件工程交叉领域的一个重要分支. 开发高效的代码搜索算法能够显著提高代码重用的能力, 从而有效提高软件开发人员的工作效率. 代码搜索任务是以描述代码片段功能的自然语言作为输入, 在海量代码库中搜索得到相关代码片段的过程. 基于序列模型的代码搜索方法DeepCS虽然取得了很好的效果, 但这种方法不能捕捉代码的深层语义. 基于图嵌入的代码搜索方法GraphSearchNet能缓解这个问题, 但没有对代码与文本进行细粒度匹配, 也忽视了代码图和文本图的全局关系. 为了解决以上局限性, 提出基于关系图卷积网络的代码搜索方法, 对构建的文本图和代码图编码, 从节点层面对文本查询和代码片段进行细粒度匹配, 并应用神经张量网络捕捉它们的全局关系. 在两个公开数据集上的实验结果表明, 所提方法比先进的基线模型DeepCS和GraphSearchNet搜索精度更高.
关键词:  代码搜索  关系图卷积网络  细粒度匹配
DOI:10.13328/j.cnki.jos.006910
分类号:TP311
基金项目:国家自然科学基金(61972173); 中央高校自主科研经费(CCNU22QN015); 武汉市知识创新专项基础研究项目(2022010801010278)
Code Search Method Based on Relational Graph Convolutional Network
ZHOU Guang-You1, XIE Qi1, YU Xiao2
1.School of Computer Science, Central China Normal University, Wuhan 430079, China;2.School of Computer Science and Artificial Intelligence, Wuhan University of Technology, Wuhan 430070, China
Abstract:
Code search is an important research topic in natural language processing and software engineering. Developing efficient code search algorithms can significantly improve the code reuse and the working efficiency of software developers. The task of code search is to retrieve code fragments that meet the requirements from the massive code repository by taking the natural language describing the function of the code fragments as input. Although the sequence model-based code search method, namely DeepCS has achieved promising results, it cannot capture the deep semantics of the code. GraphSearchNet, a code search method based on graph embedding, can alleviate this problem, but it does not perform fine-grained matching on codes and texts and ignores the global relationship between code graphs and text graphs. To address the above limitations, this study proposes a code search method based on a relational graph convolutional network, which encodes the constructed text graphs and code graphs, performs fine-grained matching on text query and code fragments at the node level, and applies neural tensor networks to capture their global relationship. Experimental results on two public datasets show that the proposed method achieves higher search accuracy than state-of-the-art baseline models, namely DeepCS and GraphSearchNet.
Key words:  code search  relational graph convolutional network  fine-grained matching