arrow
Return

Code semantic enrichment for deep code search

delete2024-01-01
delete3
PRE
AI
Z
Zhongyang Deng
徐玲 cover
徐玲 (Ling Xu) *
C
Chao Liu
L
Luwen Huangfu
鄢
鄢萌 (Meng Yan)
DOI:10.1016/j.jss.2023.111856delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

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.
Keywords:
Code search
Deep learning
Semantic enrichment
Co-attention mechanism

Journal

Journal of Systems and Software cover
Journal of Systems and Software
IF:
4.1
Papers:
5.5K
Citations:
8.4K

Organization

California State University System cover
California State University System
Scholars:
2.8W
Papers: 2.4W
Citations: 457
C
Chongqing University
Scholars:
5.1W
Papers: 4.1W
Citations: 6.0W
Cited Papers

Cited Papers

Co-Attention Fusion Network for Multimodal Skin Cancer Diagnosis
err2023-01-01
err17
PREAI
errHe, Xiaoyu; Wang, Yong; Zhao, Shuang; Chen, Xiang
errShare
errSave
errShare
errSave
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
errShare
errSave
Opportunities and Challenges in Code Search Tools
err2021-10-08
err37
errOAAI
errLiu, Chao; Xia, Xin; Lo, David; Gao, Cuiyun; Yang, Xiaohu; Grundy, John
errShare
errSave
CRaDLe: Deep code retrieval based on semantic Dependency Learning
err2021-09-01
err34
errOAAI
errGu, Wenchao; Li, Zongjie; Gao, Cuiyun; Wang, Chaozheng; Zhang, Hongyu; Xu, Zenglin; Lyu, Michael R.
errShare
errSave
Automatic query reformulation for code search using crowdsourced knowledge
err2019-01-21
err36
PREAI
errRahman, Mohammad M.; Roy, Chanchal K.; Lo, David
errShare
errSave
Graph-based code semantics learning for efficient semantic code clone detection
err2023-04-01
err12
PREAI
errYu, Dongjin; Yang, Quanxin; Chen, Xin; Chen, Jie; Xu, Yihang
errShare
errSave
no more