如何有效地帮助程序员从目前的各种代码库中搜索与特定编程任务相关的代码,已成为软件工程重要的研究领域之一.提出一种基于增强描述的代码搜索方法 DERECS,该方法首先基于开源项目、问答系统等构建一个代码-描述语料库,并分析代码及自然语言描述,提取方法调用和代码结构相关特征值;然后,基于代码片段中的方法调用及代码片段的结构特征对代码进行描述增强,以减小被搜索的代码与自然语言查询语句之间的差异,扩大搜索的范围.使用真实自然语言查询语句作为测试基准,对DERECS进行验证.验证结果表明,DERECS的效果显著优于典型方法 SNIFF和Krugle的查询结果.
Effectively searching code for specific programming task from code base has become an important research field of software engineering. This paper presents a description reinforcement based code search (DERECS) approach. DERECS first builds a code- description pair corpus, analyzes both code and its natural language description, and extracts features about method calls and code structure. DERECS reinforces the description of code based on the method calls and code structure features, reduces the gaps between code snippet and natural language query, and expands the search scope. Evaluation is conducted against real-world queries, and the results show DERECS is significantly better than SNIFF and Krugle.