Back to Search Start Over

ROSF: Leveraging Information Retrieval and Supervised Learning for Recommending Code Snippets.

Authors :
Jiang, He
Nie, Liming
Sun, Zeyi
Ren, Zhilei
Kong, Weiqiang
Zhang, Tao
Luo, Xiapu
Source :
IEEE Transactions on Services Computing; 1/1/2019, Vol. 12 Issue 1, p34-46, 13p
Publication Year :
2019

Abstract

When implementing unfamiliar programming tasks, developers commonly search code examples and learn usage patterns of APIs from the code examples or reuse them by copy-pasting and modifying. For providing high-quality code examples, previous studies present several methods to recommend code snippets mainly based on information retrieval. In this paper, to provide better recommendation results, we propose ROSF, Recommending code Snippets with multi-aspect Features, a novel method combining both information retrieval and supervised learning. In our method, we recommend Top-K code snippets for a given free-form query based on two stages, i.e., coarse-grained searching and fine-grained re-ranking. First, we generate a code snippet candidate set by searching a code snippet corpus using an information retrieval method. Second, we predict probability values of the code snippets for different relevance scores in the candidate set by the learned prediction model from a training set, re-rank these candidate code snippets according to the probability values, and recommend the final results to developers. We conduct several experiments to evaluate our method in a large-scale corpus containing 921,713 real-world code snippets. The results show that ROSF is an effective method for code snippets recommendation and outperforms the-state-of-the-art methods by 20-41percent in Precision and 13-33 percent in NDCG. [ABSTRACT FROM AUTHOR]

Details

Language :
English
ISSN :
19391374
Volume :
12
Issue :
1
Database :
Complementary Index
Journal :
IEEE Transactions on Services Computing
Publication Type :
Academic Journal
Accession number :
134602260
Full Text :
https://doi.org/10.1109/TSC.2016.2592909