Source Forager:一个相似Source Code的搜索引擎
Source Forager: A Search Engine for Similar Source Code
摘要:
开发人员花费大量时间搜索代码:例如,了解如何完成、纠正或调整自己的代码以适应新的环境。不幸的是,代码搜索的最新技术还没有超越文本搜索而不是标记化源代码。代码具有比普通文本更丰富的结构和语义,并且可以利用此属性来专门化代码搜索过程,以便更好地查询、搜索和对代码搜索结果进行排名。我们提出了一个新的代码-搜索引擎命名为源搜寻器。给定一个C/C++函数形式的查询,Source Forager会在预填充的代码数据库中搜索类似的C/C++函数。Source Forager对数据库进行预处理,以提取各种简单的代码功能,这些功能可以捕获代码的不同方面。搜索基于各种提取的代码特征返回数据库中与查询最相似的$k$函数。我们使用来自两个领域的各种代码搜索查询来测试Source Forager的有用性。我们的实验表明,排序结果返回的源搜寻器是准确的,查询相关的功能可以可靠地检索,即使在搜索一个大型的代码数据库,包含很少的查询相关的功能。我们相信Source Forager是迈向提供更好的代码搜索体验的第一步。
英文摘要:
Developers spend a significant amount of time searching for code: e.g., to understand how to complete, correct, or adapt their own code for a new context. Unfortunately, the state of the art in code search has not evolved much beyond text search over tokenized source. Code has much richer structure and semantics than normal text, and this property can be exploited to specialize the code-search process for better querying, searching, and ranking of code-search results. We present a new code-search engine named Source Forager. Given a query in the form of a C/C++ function, Source Forager searches a pre-populated code database for similar C/C++ functions. Source Forager preprocesses the database to extract a variety of simple code features that capture different aspects of code. A search returns the $k$ functions in the database that are most similar to the query, based on the various extracted code features. We tested the usefulness of Source Forager using a variety of code-search queries from two domains. Our experiments show that the ranked results returned by Source Forager are accurate, and that query-relevant functions can be reliably retrieved even when searching through a large code database that contains very few query-relevant functions. We believe that Source Forager is a first step towards much-needed tools that provide a better code-search experience.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。