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

被引:48
作者
Jiang, He [1 ,2 ,3 ]
Nie, Liming [1 ,2 ]
Sun, Zeyi [1 ,2 ]
Ren, Zhilei [1 ,2 ]
Kong, Weiqiang [1 ,2 ]
Zhang, Tao [4 ]
Luo, Xiapu [5 ]
机构
[1] Dalian Univ Technol, Sch Software, Dalian 116024, Peoples R China
[2] Key Lab Ubiquitous Network & Serv Software Liaoni, Dalian, Peoples R China
[3] Wuhan Univ, State Key Lab Software Engn, Wuhan 116024, Hubei, Peoples R China
[4] Harbin Engn Univ, Coll Comp Sci & Technol, Harbin, Heilongjiang, Peoples R China
[5] Hong Kong Polytech Univ, Dept Comp, Hong Kong, Peoples R China
基金
中国国家自然科学基金;
关键词
Code snippets recommendation; information retrieval; supervised learning; topic model; feature; SEARCH; REUSE;
D O I
10.1109/TSC.2016.2592909
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
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-formquery 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-41 percent in Precision and 13-33 percent in NDCG.
引用
收藏
页码:34 / 46
页数:13
相关论文
共 52 条
[1]  
[Anonymous], 35 INT ACM SIGIR C R
[2]  
[Anonymous], ACM IEEE INT S EMP S
[3]  
[Anonymous], 18 TEXT RETR C GAITH
[4]  
[Anonymous], 2016, EMPIR SOFTW ENG
[5]  
[Anonymous], 2013 INT C SOFTW ENG
[6]  
[Anonymous], 18 ACM SIGSOFT INT S
[7]  
[Anonymous], ICSE WORKSH SEARCH D
[8]  
[Anonymous], 4 INT WORKSH REC SYS
[9]  
[Anonymous], 37 INT C SOFTW ENG F
[10]  
[Anonymous], 36 INT C SOFTW ENG H