Code Search based on Context-aware Code Translation

被引:24
|
作者
Sun, Weisong [1 ]
Fang, Chunrong [1 ]
Chen, Yuchen [1 ]
Tao, Guanhong [2 ]
Han, Tingxu [3 ]
Zhang, Quanjun [1 ]
机构
[1] Nanjing Univ, State Key Lab Novel Software Technol, Nanjing, Peoples R China
[2] Purdue Univ, W Lafayette, IN 47907 USA
[3] Nanjing Univ, Sch Informat Management, Nanjing, Peoples R China
来源
2022 ACM/IEEE 44TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE 2022) | 2022年
基金
中国国家自然科学基金;
关键词
code search; deep learning; code translation;
D O I
10.1145/3510003.3510140
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Code search is a widely used technique by developers during software development. It provides semantically similar implementations from a large code corpus to developers based on their queries. Existing techniques leverage deep learning models to construct embedding representations for code snippets and queries, respectively. Features such as abstract syntactic trees, control flow graphs, etc., are commonly employed for representing the semantics of code snippets. However, the same structure of these features does not necessarily denote the same semantics of code snippets, and vice versa. In addition, these techniques utilize multiple different word mapping functions that map query words/code tokens to embedding representations. This causes diverged embeddings of the same word/token in queries and code snippets. We propose a novel context-aware code translation technique that translates code snippets into natural language descriptions (called translations). The code translation is conducted on machine instructions, where the context information is collected by simulating the execution of instructions. We further design a shared word mapping function using one single vocabulary for generating embeddings for both translations and queries. We evaluate the effectiveness of our technique, called TranCS, on the CodeSearchNet corpus with 1,000 queries. Experimental results show that TranCS significantly outperforms state-of-the-art techniques by 49.31% to 66.50% in terms of MRR (mean reciprocal rank).
引用
收藏
页码:388 / 400
页数:13
相关论文
共 50 条
  • [1] Context-aware code certification
    Eusterbrock, J
    19TH INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING, PROCEEDINGS, 2004, : 358 - 361
  • [2] Context-aware Code Optimization
    Bolat, Murat
    Li, Xiaoming
    2009 IEEE 28TH INTERNATIONAL PERFORMANCE COMPUTING AND COMMUNICATIONS CONFERENCE (IPCC 2009), 2009, : 256 - 263
  • [3] Context-Aware Change Pattern for Code Transformation
    LIU Zhiping
    Wuhan University Journal of Natural Sciences, 2018, 23 (04) : 355 - 361
  • [4] MLSmellHound: A Context-Aware Code Analysis Tool
    Kannan, Jai
    Barnett, Scott
    Cruz, Luis
    Simmons, Anj
    Agarwal, Akash
    2022 ACM/IEEE 44TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING: NEW IDEAS AND EMERGING RESULTS (ICSE-NIER 2022), 2022, : 66 - 70
  • [5] Context-Aware Code Recommendation in Intellij IDEA
    Abid, Shamsa
    Basit, Hamid Abdul
    Shamail, Shafay
    PROCEEDINGS OF THE 30TH ACM JOINT MEETING EUROPEAN SOFTWARE ENGINEERING CONFERENCE AND SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING, ESEC/FSE 2022, 2022, : 1647 - 1651
  • [6] Towards Context-Aware Code Comment Generation
    Yu, Xiaohan
    Huang, Quzhe
    Wang, Zheng
    Feng, Yansong
    Zhao, Dongyan
    FINDINGS OF THE ASSOCIATION FOR COMPUTATIONAL LINGUISTICS, EMNLP 2020, 2020, : 3938 - 3947
  • [7] Supporting Code Search with Context-Aware, Analytics-Driven, Effective Query Reformulation
    Rahman, Mohammad Masudur
    2019 IEEE/ACM 41ST INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING: COMPANION PROCEEDINGS (ICSE-COMPANION 2019), 2019, : 226 - 229
  • [8] Context-aware code generation with synchronous bidirectional decoder
    Zhang, Xiangyu
    Zhou, Yu
    Yang, Guang
    Han, Tingting
    Chen, Taolue
    JOURNAL OF SYSTEMS AND SOFTWARE, 2024, 214
  • [9] On Source Code Completion Assistants and the Need of a Context-Aware Approach
    Arrebola, Fabio Villamarin
    Aquino Junior, Plinio Thomaz
    HUMAN INTERFACE AND THE MANAGEMENT OF INFORMATION: SUPPORTING LEARNING, DECISION-MAKING AND COLLABORATION, HCI INTERNATIONAL 2017, PT II, 2017, 10274 : 191 - 201
  • [10] Context-Aware Code Change Embedding for Better Patch Correctness Assessment
    Lin, Bo
    Wang, Shangwen
    Wen, Ming
    Mao, Xiaoguang
    ACM TRANSACTIONS ON SOFTWARE ENGINEERING AND METHODOLOGY, 2022, 31 (03)