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

ROSF: Leveraging Information Retrieval and Supervised Learning for Recommending Code Snippets
复制标题

ROSF:利用信息检索和监督学习来推荐代码片段

DOI:
10.1109/tsc.2016.2592909
复制
发表时间:
2019-01-01
影响因子:
8.1
通讯作者:
Luo, Xiapu
Luo, Xiapu
中科院分区:
计算机科学2区
文献类型:
--
作者:
Jiang, He;Nie, Liming;Luo, Xiapu

文献摘要

被引文献

相似文献

在实施不熟悉的编程任务时,开发人员通常会搜索代码示例并从代码示例中学习API的使用模式,或通过复制和修改来重复使用它们。对于提供高质量的代码示例,先前的研究提出了几种方法,主要根据信息检索推荐代码段。在本文中,为了提供更好的建议结果,我们提出了ROSF,推荐具有多个特征功能的代码片段,这是一种新颖的方法,结合了信息检索和监督学习。在我们的方法中,我们建议基于两个阶段的给定自由格式的Top-K代码段,即粗粒搜索和细粒度的重新排列。首先,我们通过使用信息检索方法搜索代码片段语料库来生成一个代码段候选者。其次,我们根据训练集,根据概率值对学到的预测模型设置的候选预测模型设置的不同相关性分数预测代码段的概率值,并根据概率值对这些候选代码snippets进行了重新升级,并将最终结果推荐给开发人员。我们进行了几项实验,以在包含921,713个现实世界代码段的大规模语料库中评估我们的方法。结果表明,ROSF是一种有效的代码段建议方法,优于先进方法的精度为20-41%,而在NDCG中,胜过13-33%。
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.