With the rapid increase in the amount of public code repositories, developers maintain a great desire to retrieve precise code snippets by using natural language. Despite existing deep learning based approaches(e.g., DeepCS and MMAN) have provided the end-to-end solutions (i.e., accepts natural language as queries and shows related code fragments retrieved directly from code corpus), the accuracy of code search in the large-scale repositories is still limited by the code representation (e.g., AST) and modeling (e.g., directly fusing the features in the attention stage). In this paper, we propose a novel learnable deep Graph for Code Search (calleddeGraphCS), to transfer source code into variable-based flow graphs based on the intermediate representation technique, which can model code semantics more precisely compared to process the code as text directly or use the syntactic tree representation. Furthermore, we propose a well-designed graph optimization mechanism to refine the code representation, and apply an improved gated graph neural network to model variable-based flow graphs. To evaluate the effectiveness of deGraphCS, we collect a large-scale dataset from GitHub containing 41,152 code snippets written in C language, and reproduce several typical deep code search methods for comparison. Besides, we design a qualitative user study to verify the practical value of our approach. The experimental results have shown that deGraphCS can achieve state-of-the-art performances, and accurately retrieve code snippets satisfying the needs of the users.
翻译:随着公共代码库数量的迅速增加,开发商仍然非常希望通过使用自然语言检索精确的代码片断。尽管现有的深层次学习基础方法(例如深CS和MMAN)提供了端到端解决方案(即接受自然语言作为查询,并显示直接从代码库中检索的相关代码碎片),但大型存储库的代码搜索准确性仍然受到代码表述(例如AST)和模型(例如直接在关注阶段中显示特征)的限制。在本文中,我们提议了一个新的、可学习的代码搜索深度图(称为GraphCS),以基于中间表述技术将源代码转换为基于变量的流程图(即接受自然语言作为查询,并显示直接从代码库中检索的相关代码片断),大规模存储库的代码搜索准确性仍受到代码代表(例如AST)和模型(例如直接在关注阶段中显示特征)的限制。我们提议了一个设计完善的图表优化机制,在基于模型的代码流图中采用改良的门式直径网络。为了评估degraphCS的准确性搜索(即我们收集了41种典型的精确度数据),我们用来进行大规模搜索的系统搜索的系统,我们收集了40级数据,我们用系统,我们用系统搜索的方法可以复制数据分析。