基于上下文的API推荐中结构和文本代码信息的整体结合
Holistic Combination of Structural and Textual Code Information for Context based API Recommendation
摘要:
基于上下文的API推荐是帮助开发人员有效且高效地找到所需API的重要方法。对于有效的API推荐,我们不仅需要结构和文本代码信息的联合视图,而且还需要控制和数据流图中相关API使用的整体视图。不幸的是,现有的API推荐方法分别利用结构或文本代码信息。在这项工作中,我们提出了一种新的API推荐方法,称为APIRec-CST(API推荐结合结构和文本代码信息)。APIRec-CST是一个深度学习模型,它基于API上下文图网络和代码令牌网络,将API使用与源代码中的文本信息相结合,同时学习结构和文本特征,以进行API推荐。我们应用APIRec-CST对1,914个开源Java项目的JDK库进行了训练,并对另外6个开源项目的API推荐的准确性和MRR(Mean Reciprocal Rank)进行了评估。实验结果表明,该方法分别获得了top1、top5、top10的准确率和60.3%、81.5%、87.7%和69.4%的MRR,显著优于现有的基于图的统计方法和基于树的深度学习方法。进一步的分析表明,文本代码信息是有意义的,提高了准确性和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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。