摘要
软件开发者在开发过程遇到应用程序编程接口(application programming interface,API)使用问题时,通常希望能够得到有效的API使用模式建议,从而帮助其学习和使用.传统的API推荐方法会挖掘和学习代码库中API的使用知识,然后给开发者推荐与上下文相关的API.然而由于上下文信息表征不够充分,以及推荐列表中冗余项和同质化内容的出现影响了推荐性能.针对这一问题,构建项目和方法与API的API层次调用图(API hierarchy call graph,AHCG)模型以更好地表达API上下文关系,充分利用API结构信息和语义信息来减少冗余项和降低同质化内容被推荐的可能性,进而提出基于上下文感知并面向多样性的API推荐(context-aware based API recommendation with diversity,CAPIRD)方法.该方法中引入相关性度量和关联性度量,最大限度地保留相关结果,同时平衡已选API与候选API的关联性,以尽可能挖掘到合理的初选API列表.最后结合最大边缘相关算法,在标准模式数据集上学习相关性和关联性的最佳权重组合,并进行多样性重排推荐.在2210个项目构成的3类数据集上进行实验并验证推荐性能,实验结果表明,CAPIRD在基于上下文的API推荐场景下能够有效提高推荐性能.在所有数据集的API推荐中,平均精度(mean average precision,MAP)指标平均提升值约9%,在Top-1的推荐中,成功率(success rate)指标平均提升约13%.
When facing API usage problems during the development process,software developers usually hope to get effective suggestions on API usage patterns to help them learn and use.Traditional API recommendation methods mine the usage knowledge of APIs in the codebase,and then recommend context-sensitive APIs to developers.However,several aspects affect the performance of the recommendation,such as the insufficient representation of contextual information,the appearance of redundant and homogeneous contents in the recommendation list.Focus on those problems,we propose an approach named as context-aware based API recommendation with diversity(CAPIRD),in which we build an API hierarchy call graph(AHCG)model of projects,methods,and APIs to represent API contextual relationships better.According to AHCG model,we can fully use API structural and semantic information to reduce redundant and homogenous contents.In addition,the measurement of relevance and correlation parts are introduced into the approach,which are used to maximize the relevant results,while balancing the correlation of selected APIs and candidate APIs,so as to dig out a reasonable list of APIs.Finally,we reorder the above relevant and correlated results using the optimal weight combination to increase the diversity.The optimal weight is learned on the standard patterns datasets combined with the maximal marginal relevance algorithm.Experiments are implemented on 3 datasets,which are consisted of 2210 projects,to verify the recommendation performance of CAPIRD.The experimental results show that CAPIRD performs better in context-based scenarios of API usage recommendation.In detail,compared with the baseline approaches,the average improvement of MAP(mean average precision)is about 9%.In the Top-1 success rate,the average improvement is about 13%.
作者
赖宝强
李征
赵瑞莲
郭俊霞
Lai Baoqiang;Li Zheng;Zhao Ruilian;Guo Junxia(College of Information Science and Technology,Beijing University of Chemical Technology,Beijing 100029)
出处
《计算机研究与发展》
EI
CSCD
北大核心
2023年第10期2335-2347,共13页
Journal of Computer Research and Development
基金
国家自然科学基金项目(61872026,62077003)
中央高校基础科学研究项目(ZY2109)。
关键词
API推荐
API使用模式
图模型
多样性推荐
重排
API recommendation
API usage pattern
graph model
diversity recommendation
reordering