At a glance
Hamid Abdul Basit and co-authors built Clone-Seeker, which indexes code by plain-language keyword documents and beats the state of the art on semantic clone recall.
The best way to find a piece of code that does what you want may be to stop searching the code and start searching a short, plain-language note attached to it. That is the bet behind a 2022 study in IEEE Access, which reports that giving each code fragment a document of descriptive keywords, drawn partly from the code's own identifiers and partly from a human-written description of what that family of code does, let a fairly ordinary search engine surface semantically similar code at higher recall than the state-of-the-art approaches it was benchmarked against.
The paper, "Clone-Seeker: Effective Code Clone Search Using Annotations," is by Muhammad Hammad, Önder Babur, Hamid Abdul Basit and Mark van den Brand, and it ran in IEEE Access in January 2022, volume 10, pages 11,696 to 11,713. Basit is listed on the paper with Prince Sultan University in Riyadh; he now holds an associate professorship in computing and technology at IQRA University in Islamabad, where his research has circled clone detection and software similarity for more than fifteen years. The co-authors come from Eindhoven University of Technology in the Netherlands.
The premise is unglamorous and hard to argue with: developers spend real working hours hunting for code that already does what they need, whether to reuse it directly, to transplant a fix, or to compare competing implementations. Existing tools match text. Developers are usually matching intent.
Four kinds of duplicate, and only one of them looks duplicate
The research community sorts code clones into a rough ladder. Type-1 clones are identical apart from whitespace and comments. Type-2 clones have the same structure but renamed identifiers. Type-3 clones are near-misses, with statements added or removed. Type-4 clones are the hard case: snippets that share almost no syntax but implement the same functionality, one written with a for-loop and one with a stream, say, or one using a library call where the other hand-rolls the logic.
Any token-matching tool catches the first three reliably. The fourth is where search breaks down, and it is the case that matters most for the tasks the paper names: automated software transplantation, software diversification and software repair. All three start with a retrieval problem, and all three are useless if the retrieval returns the obvious textual copy instead of the alternative implementation.
BigCloneBench, the benchmark most clone research is measured against, is built for exactly this difficulty. It contains more than eight million manually validated clone method pairs drawn from IJaDataset, a Java repository of 2.3 million source files, roughly 365 million lines of code, from 25,000 open-source projects. Those pairs are grouped into 43 clone classes, each corresponding to a distinct functionality.
What goes on the index card
Clone-Seeker does not index source code. It indexes a document about the source code. Think of a library that has given every folder of code a handwritten index card listing what the code does in ordinary words, then thrown away the folders and searched only the cards.
Building those cards took several passes. The team pulled 14,922 true-positive clone methods out of BigCloneBench, traced them into the underlying IJaDataset files, then stripped each method of Java reserved keywords, constant values, whitespace and comments. The cleaned code went through a tokenizer, the Javalang library, which provides a Java 8 lexer and parser in Python. Identifiers were split on camelCase and snake_case boundaries, single characters were dropped, and the remaining words were stemmed to their roots so that related forms collapse together.
Comments were deliberately excluded. The authors cite prior findings that comments are an unreliable and inconsistent source of natural-language text, note that some comments in IJaDataset are written in languages other than English, and point out that an outdated comment may describe code it no longer matches.
That produced half of each card. The other half came from the clone class: a short list of keywords describing what the whole family of snippets does. The team built this two ways. In the manual version, a person wrote the description. In the automatic version, a script counted the most frequent words across every method in the class and kept the top few.
Concatenate the two lists and you have a natural-language document for each method. Retrieval itself used TF-IDF, the classic weighting scheme that scores a term by how often it appears in a document, discounted by how common it is across the whole collection — a term like "file" counts for little because it is everywhere, while "circumference" counts for a lot. That is a deliberately plain choice, and the authors describe it as a proof of concept rather than a destination. The full text and the result tables are readable in the open-access PDF hosted by Eindhoven University of Technology.
Photo by Markus Spiske on Unsplash
Manual annotation wins on natural-language queries
The paper's own worked example is a query typed the way a frustrated developer would type it: "Error while copying files from source to destination java." After preprocessing it becomes "error copi file source destin java," and the top-ranked result is a method whose keyword document covers copying a file from source to destination, along with a batch of stream and reader-writer terms. It scored 0.464 against the query.
To measure this properly, the team used two standard information-retrieval metrics: mean reciprocal rank, which averages one over the position of the first correct hit, so a correct answer in slot one scores 1.0 and a correct answer in slot three scores 0.33; and precision at ranks 1, 5 and 10, which asks how many of the top results belong to the right clone class.
On BigCloneBench, with natural-language queries, the manual variant beat both the automatic variant and the identifiers-only baseline at p < .00001. The automatic variant, by contrast, was statistically indistinguishable from the baseline at p = .42074. The authors' explanation is almost embarrassingly simple: manual annotations and natural-language queries are both written by people, so their vocabularies overlap.
On code-to-code search in the same benchmark, the paper reports the best recall for Type-4 semantic clones among the approaches it was compared against, including the token-based detectors that dominate the field. The published version, with its full result tables, is available through the DOI record for the IEEE Access paper.
A second dataset tests whether the idea travels
A single benchmark proves little, so the team repeated the exercise on Project CodeNet, a collection mined from online judge sites where programmers submit solutions to set problems and an automatic reviewer grades them. CodeNet's Java portion holds 250 problems with roughly 300 sample solutions each, syntactically or semantically similar to one another.
The researchers filtered those down to problems generic enough that their solutions are discussed on Stack Overflow and GeeksforGeeks, then built a benchmark of 46 queries covering the remaining classes. The finding split down the middle. With natural-language queries, manual annotation again won outright, at p < .00001. With code used as the query, none of the three variants separated from the others: the difference came in at p = 0.06, short of significance.
That second result is worth dwelling on, because it is the one the authors do not spin. On Project CodeNet, adding annotation to a query made of code terms did not measurably help. The paper states plainly that better annotation techniques need to be explored before the manual and automatic variants can beat the plain baseline for code-to-code search.
The catch: a human still has to write the description
Here is where the paper puts its own brakes on. The variant that performs best depends on a person writing a description for every clone class. That is fine for 43 classes. It is not obviously fine for the millions of distinct behaviours inside a large industrial code base, and it hands a tedious, expert task to exactly the people with the least spare time.
Automatic annotation was supposed to solve that, and in this study it did not. As the authors put it, "adding more tokens in terms of automatic annotation does not improve the search a lot and different annotation techniques are required to explore in the future." They also flag that they tested only a narrow set of threshold values for how many keywords to keep, that word counting was the only automatic extraction method tried, and that the natural-language queries, though collected from real websites, do not cover everything a developer might ask.
A cautious reader might push harder. If manual annotation wins mostly because it shares vocabulary with human-written queries, then part of the gain reflects a matching style rather than evidence that the system understands what code does. The comparison set for that victory is also an internal baseline built from identifiers alone, so beating it is not the same as beating a commercial code search product. And the paper's evaluations cover two Java datasets; nothing here was tested on C++, Python or a production monorepo with years of drift in it.
The study is published open access under a Creative Commons Attribution 4.0 licence, which means the tables and the corpus construction steps can be checked and reused rather than taken on trust — a small but real advantage for anyone wanting to replicate or extend the work.
Photo by Rahul Mishra on Unsplash
Where this goes next
The authors lay out a fairly clear itinerary. TF-IDF was a placeholder; word2vec and GloVe embeddings are the obvious next step, and they suggest joint neural network models trained on both the natural-language documents and the code itself. Keyword extraction could move beyond word frequency to techniques like word degree or RAKE. Evaluation could widen to other clone datasets, and the approach could be tried on coarser granularities than methods — structural clones, the design-level similarities Basit has been publishing on since his PhD at the National University of Singapore, and clones of entirely different artifacts such as models.
There is a practical lesson buried in the null results. Two of the paper's three headline experiments found that a cheap, boring representation, a bag of English words, was enough to improve retrieval, while the clever automatic substitute added nothing. Systems that retrieve code for a living — the suggestion engine in an IDE, the assistant that autocompletes a method, the pipeline deciding which snippets are worth learning from — are being tuned and retrained at enormous expense right now. Clone-Seeker suggests that the supply of good human-written descriptions of what code does may matter as much as the sophistication of the model reading them, and that a catalogue card written by someone who understands the code still beats a word count.
- information-retrieval
- software-engineering-research
- ieee-access
- code-clone-search
- clone-seeker

