arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1703.01446cs.SE
收藏

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

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

He Jiang, Liming Nie, Zeyi Sun, Zhilei Ren, Weiqiang Kong, Tao Zhang, Xiapu Luo

摘要:

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

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑