Skip to main content
Article
AutoQuery: Automatic Construction of Dependency Queries for Code Search
Automated Software Engineering
  • Shaowei WANG, Singapore Management University
  • David LO, Singapore Management University
  • Lingxiao JIANG, Singapore Management University
Publication Type
Journal Article
Version
acceptedVersion
Publication Date
9-2016
Abstract

Many code search techniques have been proposed to return relevant code for a user query expressed as textual descriptions. However, source code is not mere text. It contains dependency relations among various program elements. To leverage these dependencies for more accurate code search results, techniques have been proposed to allow user queries to be expressed as control and data dependency relationships among program elements. Although such techniques have been shown to be effective for finding relevant code, it remains a question whether appropriate queries can be generated by average users. In this work, we address this concern by proposing a technique, AutoQuery, that can automatically construct dependency queries from a set of code snippets. We realize AutoQuery by the following major steps: firstly, code snippets (that are not necessarily compilable) are converted into program dependence graphs (PDGs); secondly, a new graph mining solution is built to return common structures in the PDGs; thirdly, the common structures are converted to dependency queries, which are used to retrieve results by using a dependence-based code search technique. We have evaluated AutoQuery on real systems with 47 different code search tasks. The results show that the automatically constructed dependency queries retrieve relevant code with a precision, recall, and F-measure of 68.4, 72.1, and 70.2 %, respectively. We have also performed a user study to compare the effectiveness of AutoQuery with that of human generated queries. The results show that queries constructed by AutoQuery on average help to retrieve code fragments with comparable F-measures to those retrieved by human constructed queries.

Keywords
  • Code search,
  • Dependency query,
  • Query construction,
  • Graph mining
Identifier
10.1007/s10515-014-0170-2
Publisher
Springer Verlag (Germany)
Copyright Owner and License
Authors
Creative Commons License
Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International
Additional URL
https://doi.org/10.1007/s10515-014-0170-2
Citation Information
Shaowei WANG, David LO and Lingxiao JIANG. "AutoQuery: Automatic Construction of Dependency Queries for Code Search" Automated Software Engineering Vol. 23 Iss. 3 (2016) p. 393 - 425 ISSN: 0928-8910
Available at: http://works.bepress.com/david_lo/186/