Page 287 - 《软件学报》2024年第6期
P. 287
软件学报 ISSN 1000-9825, CODEN RUXUEW E-mail: jos@iscas.ac.cn
Journal of Software,2024,35(6):2863−2879 [doi: 10.13328/j.cnki.jos.006910] http://www.jos.org.cn
©中国科学院软件研究所版权所有. Tel: +86-10-62562563
*
基于关系图卷积网络的代码搜索方法
周光有 1 , 谢 琦 1 , 余 啸 2
1
(华中师范大学 计算机学院, 湖北 武汉 430079)
2
(武汉理工大学 计算机与人工智能学院, 湖北 武汉 430070)
通信作者: 周光有, E-mail: gyzhou@mail.ccnu.edu.cn
摘 要: 代码搜索是当下自然语言处理和软件工程交叉领域的一个重要分支. 开发高效的代码搜索算法能够显著
提高代码重用的能力, 从而有效提高软件开发人员的工作效率. 代码搜索任务是以描述代码片段功能的自然语言
作为输入, 在海量代码库中搜索得到相关代码片段的过程. 基于序列模型的代码搜索方法 DeepCS 虽然取得了很好
的效果, 但这种方法不能捕捉代码的深层语义. 基于图嵌入的代码搜索方法 GraphSearchNet 能缓解这个问题, 但没
有对代码与文本进行细粒度匹配, 也忽视了代码图和文本图的全局关系. 为了解决以上局限性, 提出基于关系图卷
积网络的代码搜索方法, 对构建的文本图和代码图编码, 从节点层面对文本查询和代码片段进行细粒度匹配, 并应
用神经张量网络捕捉它们的全局关系. 在两个公开数据集上的实验结果表明, 所提方法比先进的基线模型 DeepCS
和 GraphSearchNet 搜索精度更高.
关键词: 代码搜索; 关系图卷积网络; 细粒度匹配
中图法分类号: TP311
中文引用格式: 周光有, 谢琦, 余啸. 基于关系图卷积网络的代码搜索方法. 软件学报, 2024, 35(6): 2863–2879. http://www.jos.org.
cn/1000-9825/6910.htm
英文引用格式: Zhou GY, Xie Q, Yu X. Code Search Method Based on Relational Graph Convolutional Network. Ruan Jian Xue
Bao/Journal of Software, 2024, 35(6): 2863–2879 (in Chinese). http://www.jos.org.cn/1000-9825/6910.htm
Code Search Method Based on Relational Graph Convolutional Network
1
1
ZHOU Guang-You , XIE Qi , YU Xiao 2
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
* 基金项目: 国家自然科学基金 (61972173); 中央高校自主科研经费 (CCNU22QN015); 武汉市知识创新专项基础研究项目 (20220108
01010278)
收稿时间: 2022-03-24; 修改时间: 2022-06-14, 2022-11-03; 采用时间: 2023-01-22; jos 在线出版时间: 2023-07-12
CNKI 网络首发时间: 2023-07-13