arrow
返回

Code semantic enrichment for deep code search

delete2024-01-01
delete3
PRE
AI
Z
Zhongyang Deng
徐玲 封面图
徐玲 (Ling Xu) *
C
Chao Liu
L
Luwen Huangfu
鄢
鄢萌 (Meng Yan)
DOI:10.1016/j.jss.2023.111856delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
Code search aims to retrieve code snippets from a large-scale codebase, where the semantics of the searched code match developers' query intent. Code is a low-level implementation of programming intents, but query is always expressed as clear and high-level semantics, which makes it difficult for DL-based approaches to learn the semantic relationship between them. Through a large-scale empirical analysis on more than 2.2 million pairs of Java code and description, we found that the semantics of code and query can be aligned by enriching code with the descriptions of other code in terms of similar implementation. Based on the finding, we propose a code semantic enrichment approach for deep code search, named SemEnr. Specifically, we first enrich semantics for all code snippets in the training and testing data. We estimated the syntactic similarity of each code snippet from the training data and retrieved the most similar one for each. Thereafter, the semantics of one code snippet is represented by its code tokens and the description of the retrieved most similar code. During the model training, we used the attention mechanism to embed pairs of enriched code and query into the shared high-dimensional vector space. To enhance the quality of our learned representations, we integrated a multi-perspective co-attention mechanism, employing Convolutional Neural Networks (CNNs) to capture local correlations between code and query. Finally, we evaluated the effectiveness of our approach by performing experiments on two extensively used Java datasets. Our experimental results reveal that SemEnr achieves an MRR of 0.698 and 0.631, outperforming the best baseline CAT (a state-of-the-art DL-based model) by 19.93% and 18.83%, respectively. In addition, we conducted a user study involving 50 real-world queries to assess SemEnr's performance, and the findings suggest that SemEnr outperformed baseline models by returning more relevant code snippets.
Keyword:
Code search
Deep learning
Semantic enrichment
Co-attention mechanism

期刊

Journal of Systems and Software 封面图
Journal of Systems and Software
IF:
4.1
论文数:
5.5K
被引数:
8.4K

机构

California State University System 封面图
California State University System
学者数:
2.8W
论文数: 2.4W
被引数: 457
C
Chongqing University
学者数:
5.1W
论文数: 4.1W
被引数: 6.0W
引用论文

引用论文

CD300c is an Activating Receptor Expressed on Human Monocytes
err2013-04-06
err0
errOAAI
errVenkateswara R. Simhadri; John L. Mariano; Aleksandra Gil-Krzewska; Qing Zhou; Francisco Borrego
err分享
err收藏
Opportunities and Challenges in Code Search Tools
err2021-10-08
err37
errOAAI
errLiu, Chao; Xia, Xin; Lo, David; Gao, Cuiyun; Yang, Xiaohu; Grundy, John
err分享
err收藏
CRaDLe: Deep code retrieval based on semantic Dependency LearningCRaDLe: 基于语义依赖学习的深度代码检索
err2021-09-01
err34
errOAAI
errGu, Wenchao; Li, Zongjie; Gao, Cuiyun; Wang, Chaozheng; Zhang, Hongyu; Xu, Zenglin; Lyu, Michael R.
err分享
err收藏
没有更多内容