Are the Code Snippets What We Are Searching for? A Benchmark and an Empirical Study on Code Search with Natural-Language Queries

By Shuhan Yan, Hang Yu, Yuting Chen, Beijun Shen, Lingxiao Jiang. 2020

64 citations recorded by the source corpus.

Code search methods, especially those that allow programmers to raise queries in a natural language, plays an important role in software development. It helps to improve programmers' productivity by returning sample code snippets from the Internet and/or source-code repositories for their natural-language queries. Meanwhile, there are many code search methods in the literature that support natural-language queries. Difficulties exist in recognizing the strengths and weaknesses of each method and choosing the right one for different usage scenarios, because (1) the implementations of those methods and the datasets for evaluating them are usually not publicly available, and (2) some methods leverage different training datasets or auxiliary data sources and thus their effectiveness cannot be fairly measured and may be negatively affected in practical uses. To build a common ground for measuring code search methods, this paper builds CosBench, a dataset that consists of 1000 projects, 52 code-independent natural-language queries with ground truths, and a set of scripts for calculating four metrics on code research results. We have evaluated four IR (Information Retrieval)-based and two DL (Deep Learning)-based code search methods on CosBench. The empirical evaluation results clearly show the usefulness of the CosBench dataset and various strengths of each code search method. We found that DL-based methods are more suitable for queries on reusing code, and IR-based ones for queries on resolving bugs and learning API uses.

Subfields: Artificial Intelligence, Information Systems, Software, Information Retrieval & Search, Code Generation & Program Synthesis

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Nan Duan
  2. Daya Guo
  3. Colin B. Clement
  4. Shujie Liu
  5. Ming Zhou
  6. Neel Sundaresan
  7. Alexey Svyatkovskiy
  8. Duyu Tang

In Information Systems

  1. Nan Duan
  2. Daya Guo
  3. Neel Sundaresan
  4. Alexey Svyatkovskiy
  5. Colin B. Clement
  6. Shuai Lu
  7. Shao Kun Deng
  8. Dawn Drain

In Software

  1. Neel Sundaresan
  2. Alexey Svyatkovskiy
  3. Daya Guo
  4. Nan Duan
  5. Colin B. Clement
  6. Shao Kun Deng
  7. Dawn Drain
  8. Michele Tufano

In Information Retrieval & Search

  1. Ge Li
  2. Shujie Liu
  3. Linjun Shou
  4. Duyu Tang
  5. Nan Duan
  6. Ming Gong
  7. Daxin Jiang

In Code Generation & Program Synthesis

  1. Ge Li
  2. Nan Duan
  3. Daya Guo
  4. Neel Sundaresan
  5. Shao Kun Deng
  6. Colin B. Clement
  7. Shengyu Fu
  8. Michele Tufano

Citations in the corpus