Citation: | Lai Baoqiang, Li Zheng, Zhao Ruilian, Guo Junxia. Context-Aware Based API Recommendation with Diversity[J]. Journal of Computer Research and Development, 2023, 60(10): 2335-2347. DOI: 10.7544/issn1000-1239.202220317 |
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%.
[1] |
Qiu Dong, Li Bixin, Leung H. Understanding the API usage in Java[J]. Information and Software Technology, 2016, 73: 81−100 doi: 10.1016/j.infsof.2016.01.011
|
[2] |
Treude C, Robillard M P. Augmenting API documentation with insights from stack overflow[C] //Proc of the 38th Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2016: 392−403
|
[3] |
Aghajani E, Nagy C, Vega-Márquez O L, et al. Software documentation issues unveiled[C] //Proc of the 41st Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2019: 1199−1210
|
[4] |
Li Hongwei, Li Sirui, Sun Jiamou, et al. Improving API caveats accessibility by mining API caveats knowledge graph[C] //Proc of the 34th IEEE Int Conf on Software Maintenance and Evolution (ICSME). Piscataway, NJ: IEEE, 2018: 183−193
|
[5] |
Bhasin T, Murray A, Storey M A. Student experiences with GitHub and stack overflow: An exploratory study[C] //Proc of the 13th Int Workshop on Cooperative and Human Aspects of Software Engineering (CHASE). Piscataway, NJ: IEEE, 2021: 81−90
|
[6] |
Uddin G, Robillard M P. How API documentation fails[J]. IEEE Software, 2015, 32(4): 68−75 doi: 10.1109/MS.2014.80
|
[7] |
Yu Haibo, Song Wenhao, Mine T. Apibook: An effective approach for finding APIs[C] //Proc of the 8th Asia-Pacific Symp on Int[J]. New York: ACM, 2016: 45−53
|
[8] |
Zhong Hao, Xie Tao, Zhang Lu, et al. MAPO: Mining and recommending API usage patterns[C] //Proc of the 23rd European Conf on Object-Oriented Programming. Berlin: Springer, 2009: 318−343
|
[9] |
Wang Jue, Dang Yingnong, Zhang Hongyu, et al. Mining succinct and high-coverage API usage patterns from source code[C] //Proc of the 10th Working Conf on Mining Software Repositories (MSR). Piscataway, NJ: IEEE, 2013: 319−328
|
[10] |
Fowkes J, Sutton C. Parameter-free probabilistic API mining across GitHub[C] //Proc of the 24th ACM SIGSOFT Int Symp on Foundations of Software Engineering. New York: ACM, 2016: 254−265
|
[11] |
李正,吴敬征,李明树. API使用的关键问题研究[J]. 软件学报,2018,29(6):1716−1738 doi: 10.13328/j.cnki.jos.005541
Li Zheng, Wu Jingzheng, Li Mingshu. Study on key issues in API usage[J]. Journal of Software, 2018, 29(6): 1716−1738 (in Chinese) doi: 10.13328/j.cnki.jos.005541
|
[12] |
Nguyen A T, Nguyen T N. Graph-based statistical language model for code[C] //Proc of the 37th IEEE Int Conf on Software Engineering. Piscataway, NJ: IEEE, 2015: 858−868
|
[13] |
Raychev V, Vechev M, Yahav E. Code completion with statistical language models[C] //Proc of the 35th ACM SIGPLAN Conf on Programming Language Design and Implementation. New York: ACM, 2014: 419−428
|
[14] |
Gu Xiaodong, Zhang Hongyu, Zhang Dongmei, et al. Deep API learning[C] //Proc of the 24th ACM SIGSOFT Int Symp on Foundations of Software Engineering. New York: ACM, 2016: 631−642
|
[15] |
Ling Chunyang, Zou Yanzhen, Xie Bing. Graph neural network based collaborative filtering for API usage recommendation[C] //Proc of the 28th Int Conf on Software Analysis, Evolution and Reengineering (SANER). Piscataway, NJ: IEEE, 2021: 36−47
|
[16] |
Rahman M M, Roy C K, Lo D. RACK: Automatic API recommendation using crowdsourced knowledge[C] //Proc of the 23rd Int Conf on Software Analysis, Evolution, and Reengineering (SANER). Piscataway, NJ: IEEE, 2016: 349−359
|
[17] |
Rahman M M, Roy C. Effective reformulation of query for code search using crowdsourced knowledge and extra-large data analytics[C] //Proc of the 34th Int Conf on Software Maintenance and Evolution (ICSME). Piscataway, NJ: IEEE, 2018: 473−484
|
[18] |
Gu Xiaodong, Zhang Hongyu, Kim S. Deep code search[C] //Proc of the 40th Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2018: 933−944
|
[19] |
Huang Qiao, Xia Xin, Xing Zhenchang, et al. API method recommendation without worrying about the task-API knowledge gap[C] //Proc of the 33rd Int Conf on Automated Software Engineering (ASE). Piscataway, NJ: IEEE, 2018: 293−304
|
[20] |
张云帆,周宇,黄志球. 基于语义相似度的API使用模式推荐[J]. 计算机科学,2020,47(3):34−40 doi: 10.11896/jsjkx.190300053
Zhang Yunfan, Zhou Yu, Huang Zhiqiu. Semantic similarity based API usage pattern recommendation[J]. Computer Science, 2020, 47(3): 34−40 (in Chinese) doi: 10.11896/jsjkx.190300053
|
[21] |
Ling Chunyang, Zou Yanzhen, Lin Zeqi, et al. Graph embedding based API graph search and recommendation[J]. Journal of Computer Science and Technology, 2019, 34(5): 993−1006 doi: 10.1007/s11390-019-1956-2
|
[22] |
Xie Wenkai, Peng Xin, Liu Mingwei, et al. API method recommendation via explicit matching of functionality verb phrases[C] //Proc of the 28th ACM Joint Meeting on European Software Engineering Conf and Symp on the Foundations of Software Engineering. New York: ACM, 2020: 1015−1026
|
[23] |
Zhou Yu, Yang Xinying, Chen Taolue, et al. Boosting API recommendation with implicit feedback[J]. IEEE Transactions on Software Engineering, 2021, 48(6): 2157−2172
|
[24] |
Niu Haoran, Keivanloo I, Zou Ying. API usage pattern recommendation for software development[J]. Journal of Systems and Software, 2017, 129: 127−139 doi: 10.1016/j.jss.2016.07.026
|
[25] |
Nguyen T T, Pham H V, Vu P M, et al. Learning API usages from bytecode: A statistical approach[C] //Proc of the 38th Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2016: 416−427
|
[26] |
Nguyen P T, Di Rocco J, Di Ruscio D, et al. FOCUS: A recommender system for mining API function calls and usage patterns[C] //Proc of the 41st Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2019: 1050−1060
|
[27] |
Xie Rensong, Kong Xianglong, Wang Lulu, et al. HiRec: API recommendation using hierarchical context[C] //Proc of the 30th Int Symp on Software Reliability Engineering (ISSRE). Piscataway, NJ: IEEE, 2019: 369−379
|
[28] |
Chen Chi, Peng Xin, Xing Zhenchang, et al. Holistic combination of structural and textual code information for context based API recommendation[J]. IEEE Transactions on Software Engineering, 2022, 48(8): 2987−3009 doi: 10.1109/TSE.2021.3074309
|
[29] |
Di N T, Mirizzi R, Ostuni V C, et al. Linked open data to support content-based recommender systems[C/OL] //Proc of the 8th Int Conf on Semantic Systems. New York: ACM, 2012[2022-09-12].https://doi.org/10.1145/2362499.2362501
|
[30] |
Kipf T N, Welling M. Semi-supervised classification with graph convolutional networks[J]. arXiv preprint, arXiv: 1609.02907, 2016
|
[31] |
Chen Annie. Context-aware collaborative filtering system: Predicting the user’s preference in the ubiquitous computing environment[C] //Proc of the 1st Int Symp on Location-and Context-Awareness. Berlin: Springer, 2005: 244−253
|
[32] |
Nguyen T D, Nguyen A T, Phan H D, et al. Exploring API embedding for API usages and applications[C] //Proc of the 39th Int Conf on Software Engineering (ICSE). Piscataway, NJ: IEEE, 2017: 438−449
|
[33] |
Ullmann J R. An algorithm for subgraph isomorphism[J]. Journal of the ACM, 1976, 23(1): 31−42 doi: 10.1145/321921.321925
|
[34] |
Inokuchi A, Washio T, Motoda H. An Apriori-based algorithm for mining frequent substructures from graph data[C] //Proc of the 4th European Conf on Principles of Data Mining and Knowledge Discovery. Berlin: Springer, 2000: 13−23
|
[35] |
Carbonell J, Goldstein J. The use of MMR, diversity-based reranking for reordering documents and producing summaries[C] //Proc of the 21st Annual Int ACM SIGIR Conf on Research and Development in Information Retrieval. New York: ACM, 1998: 335−336
|