论文标题

基于上下文的API建议的结构和文本代码信息的整体组合

Holistic Combination of Structural and Textual Code Information for Context based API Recommendation

论文作者

Chen, Chi, Peng, Xin, Xing, Zhenchang, Sun, Jun, Wang, Xin, Zhao, Yifan, Zhao, Wenyun

论文摘要

基于上下文的API建议是帮助开发人员有效,有效地找到所需的API的重要方法。为了进行有效的API建议,我们不仅需要对结构和文本代码信息的联合视图,而且还需要整体对控制和数据流图中相关的API使用的整体视图。不幸的是,现有的API建议方法分别利用结构或文本代码信息。在这项工作中,我们提出了一种称为APIREC-CST的新型API推荐方法(通过结合结构和文本代码信息,推荐API推荐)。 APIREC-CST是一个深度学习模型,将API使用与基于API以下图形网络的源代码中的文本信息结合在一起,以及同时学习API推荐的结构和文本功能的代码令牌网络。我们将APIREC-CST基于1,914个开源Java项目来培训JDK库的模型,并通过另外6个开源项目评估API建议的准确性和MRR(平均值等级)。结果表明,我们的方法分别获得了TOP-1,TOP-5,前十名的准确性,MRR为60.3%,81.5%,87.7%和69.4%,并且明显优于现有的基于图的统计方法和基于树的深度学习方法。进一步的分析表明,文本代码信息有意义,并提高了准确性和MRR。我们还进行了一项用户研究,要求两组学生在有或没有APIREC-CST插件的情况下完成6个编程任务。结果表明,APIREC-CST可以帮助学生更快,更准确地完成任务,并且有关可用性的反馈是绝大多数的积极。

Context based API recommendation is an important way to help developers find the needed APIs effectively and efficiently. For effective API recommendation, we need not only a joint view of both structural and textual code information, but also a holistic view of correlated API usage in control and data flow graph as a whole. Unfortunately, existing API recommendation methods exploit structural or textual code information separately. In this work, we propose a novel API recommendation approach called APIRec-CST (API Recommendation by Combining Structural and Textual code information). APIRec-CST is a deep learning model that combines the API usage with the text information in the source code based on an API Context Graph Network and a Code Token Network that simultaneously learn structural and textual features for API recommendation. We apply APIRec-CST to train a model for JDK library based on 1,914 open-source Java projects and evaluate the accuracy and MRR (Mean Reciprocal Rank) of API recommendation with another 6 open-source projects. The results show that our approach achieves respectively a top-1, top-5, top-10 accuracy and MRR of 60.3%, 81.5%, 87.7% and 69.4%, and significantly outperforms an existing graph-based statistical approach and a tree-based deep learning approach for API recommendation. A further analysis shows that textual code information makes sense and improves the accuracy and MRR. We also conduct a user study in which two groups of students are asked to finish 6 programming tasks with or without our APIRec-CST plugin. The results show that APIRec-CST can help the students to finish the tasks faster and more accurately and the feedback on the usability is overwhelmingly positive.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源