计算机科学 ›› 2021, Vol. 48 ›› Issue (12): 100-106.doi: 10.11896/jsjkx.201000127

• 计算机软件 • 上一篇    下一篇

基于情境感知的API个性化推荐

陈晨1, 周宇1,2, 王永超1, 黄志球1,2   

  1. 1 南京航空航天大学计算机科学与工程学院 南京211100
    2 南京航空航天大学高安全系统的软件开发与验证技术工信部重点实验室 南京211100
  • 收稿日期:2020-10-22 修回日期:2021-03-12 出版日期:2021-12-15 发布日期:2021-11-26
  • 通讯作者: 周宇(zhouyu@nuaa.edu.cn)
  • 作者简介:786324182@qq.com
  • 基金资助:
    国家重点研发计划项目(2018YFB1003900);国家自然科学基金(61972197);江苏省自然科学基金(BK20201292);江苏高校“青蓝工程”;南京航空航天大学研究生创新基地(实验室)开放基金(kfjj20191606)

Context-aware Based API Personalized Recommendation

CHEN Chen1, ZHOU Yu1,2, WANG Yong-chao1, HUANG Zhi-qiu1,2   

  1. 1 School of Computer Science and Engineering,Nanjing University of Aeronautics and Astronautics,Nanjing 211100,China
    2 Key Laboratory of Safety-Critical Software,Ministry of Industry and Information Technology,Nanjing University of Aeronautics and Astronautics,Nanjing 211100,China
  • Received:2020-10-22 Revised:2021-03-12 Online:2021-12-15 Published:2021-11-26
  • About author:CHEN Chen,born in 1995,postgra-duate.His main research interests include software evolution analysis,artificial intelligence,and mining software repositories.
    ZHOU Yu,born in 1981,Ph.D,professor.His main research interests mainly include software evolution analysis,mining software repositories,software architecture,and reliability analysis.
  • Supported by:
    National Key R & D Program of China(2018YFB1003900),National Natural Science Foundation of China(61972197),Natural Science Foundation of Jiangsu Province,China(BK20201292),Qing-Lan Project of Jiangsu Province and Foundation of Gra-duate Innovation Center in NUAA(kfjj20191606).

摘要: 在软件开发的过程中,开发人员在遇到编程困境时通常会检索合适的API来完成编程任务。情境信息和开发者画像在有效的API推荐中起着至关重要的作用,却在很大程度上被忽视了。因而文中提出了一种基于情境感知的API个性化推荐方法。该方法利用程序静态分析技术,对代码文件做抽象语法树解析,提取信息构建代码库,并对开发者API使用偏好建模。然后计算开发者当前查询语句与历史代码库中查询的语义相似度,检索出top-k个相似历史查询。最终利用查询语句信息、方法名信息、情境信息以及开发者API使用偏好信息对API进行重排序并推荐给开发者。通过模拟编程任务开发的不同阶段,使用MRR,MAP,Hit,NDCG评估指标来验证所提方法的有效性。实验结果表明,所提方法的API推荐效果优于基准方法,能够为开发者推荐更想要的API。

关键词: API推荐, 程序静态分析, 情境感知, 开发者画像

Abstract: In the process of software development,developers often search for appropriate APIs to complete programming tasks when encountering programming difficulties.Contextual information and developer portraits play a critical role in effective API recommendation,but they are largely overlooked.This paper proposes a novel context-aware based API personalized recommendation approach.This approach leverages program static analysis technology (abstract syntax tree) to parse the code file to extract information to construct the code base and model developer API usage preferences.Then it calculates the semantic simila-rity between the developer's current query and the queries in the historical code base,and retrieves top-k similar historical queries.Finally,it leverages the information of query,method name,context and developer API usage preference to re-rank the candidate APIs and recommend to developers.MRR,MAP,Hit and NDCG are used to verify the effectiveness of the method in dif-ferent stages of simulation programming.The experimental results show that the proposed approach outperforms the baseline me-thod and it is more likely to recommend the APIs that developers want.

Key words: API recommendation, Program static analysis, Context awareness, Developer portraits

中图分类号: 

  • TP391
[1]RAHMAN M M,ROY C K,LO D.Rack:Automatic api recommendation using crowdsourced knowledge[C]//Proceedings of the 2016 IEEE 23rd International Conference on Software Ana-lysis,Evolution,and Reengineering (SANER).IEEE,2016:349-359.
[2]LV F,ZHANG H,LOU J G,et al.Codehow:Effective code search based on api understanding and extended boolean model (e)[C]//Proceedings of the 2015 30th IEEE/ACM Internatio-nal Conference on Automated Software Engineering (ASE).IEEE,2015:260-270.
[3]THUNG F,WANG S,LO D,et al.Automatic recommendation of API methods from feature requests[C]//Proceedings of the 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).IEEE,2013:290-300.
[4]CAI L,WANG H,HUANG Q,et al.BIKER:a tool for Bi-information source based API method recommendation[C]//Procee-dings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering.2019:1075-1079.
[5]AI L,HUANG Z,LI W,et al.Sensory:Leveraging code statement sequence information for code snippets recommendation[C]//Proceedings of the 2019 IEEE 43rd Annual Computer Software and Applications Conference (COMPSAC).IEEE,2019:27-36.
[6]CHAN W K,CHENG H,LO D.Searching connected API sub- graph via text phrases[C]//Proceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering.2012:1-11.
[7]NGUYEN A T,NGUYEN T N.Graph-based statistical lan- guage model for code[C]//Proceedings of the 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.IEEE,2015:858-868.
[8]HAIDUC S,BAVOTA G,MARCUS A,et al.Automatic query reformulations for text retrieval in software engineering[C]//Proceedings of the 2013 35th International Conference on Software Engineering (ICSE).IEEE,2013:842-851.
[9]MCMILLAN C,GRECHANIK M,POSHYVANYK D,et al. Exemplar:A source code search engine for finding highly relevant applications[J].Proceedings of the IEEE Transactions on Software Engineering,2012,38(5):1069-1087.
[10]BAJRACHARYA S K,OSSHER J,LOPES C V.Leveraging usage similarity for effective retrieval of examples in code repo-sitories[C]//Proceedings of the Eighteenth ACM SIGSOFT International Symposium on Foundations of Software Enginee-ring.2010:157-166.
[11]YE X,BUNESCU R,LIU C.Learning to rank relevant files for bug reports using domain knowledge[C]//Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering.2014:689-699.
[12]PONZANELLI L,BAVOTA G,DI PENTA M,et al.Mining Stack Overflow to turn the IDE into a self-confident programming prompter[C]//Proceedings of the 11th Working Confe-rence on Mining Software Repositories.2014:102-111.
[13]PONZANELLI L,SCALABRINO S,BAVOTA G,et al.Sup- porting software developers with a holistic recommender system[C]//Proceedings of the 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE).IEEE,2017:94-105.
[14]TREUDE C,ROBILLARD M P.Augmenting api documentation with insights from stack overflow[C]//Proceedings of the 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).IEEE,2016:392-403.
[15]ZHANG J,JIANG H,REN Z,et al.Recommending apis for api related questions in stack overflow[C]//Proceedings of the 2018 IEEE Access.2018,6:6205-6219.
[16]ZHOU Y,YANG X,CHEN T,et al. Boosting API Recommendation with Implicit Feedback[C]//Proceedings of the IEEE Transactions on Software Engineering.2021.
[17]BAEZA-YATES R,RIBEIRO-NETO B.Modern information retrieval[C]//Proceedings of the ACM Press/Addison-Wesley.1999:463.
[18]VILLARROEL L,BAVOTA G,RUSSO B,et al.Release planning of mobile apps based on user reviews[C]//Proceedings of the 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).IEEE,2016:14-24.
[19]YANG W,PAN M,ZHOU Y,et al.Developer Portraying:A Quick Approach to Understanding Developers on OSS Platforms[J].Proceedings of the Inf.Softw.Technol.,2020,125:106336.
[20]NGUYEN P T,DI ROCCO J,DI RUSCIO D,et al.Focus:A recommender system for mining api function calls and usage patterns[C]//Proceedings of the 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).IEEE,2019:1050-1060.
[21]LAM A N,NGUYEN A T,NGUYEN H A,et al.Combining deep learning with information retrieval to localize buggy files for bug reports (n)[C]//Proceedings of the 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).IEEE,2015:476-481.
[22]AVAZPOUR I,PITAKRAT T,GRUNSKE L,et al.Dimensions and metrics for evaluating recommendation systems[C]//Proceedings of the Recommendation Systems in Software Enginee-ring.Springer,2014:245-273.
[23]YE X,SHEN H,MA X,et al.From word embeddings to document similarities for improved information retrieval in software engineering[C]//Proceedings of the 38th International Confe-rence on Software Engineering.2016:404-415.
[24]ZHOU J,ZHANG H,LO D.Where should the bugs be fixed? more accurate information retrieval-based bug localization based on bug reports[C]//Proceedings of the 2012 34th International Conference on Software Engineering (ICSE).IEEE,2012:14-24.
[25]GU X,ZHANG H,ZHANG D,et al.Deep API learning[C]//Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering.2016:631-642.
[1] 张宏丽, 白翔宇, 李改梅. 利用最近邻域推荐且结合情境感知的个性化推荐算法[J]. 计算机科学, 2019, 46(4): 235-240.
[2] 韩立, 刘正捷. CAUXT:帮助研究人员在感兴趣的情境中采集用户体验数据[J]. 计算机科学, 2018, 45(7): 278-285.
[3] 聂黎明,江贺,高国军,王涵,徐秀娟. 代码搜索与API推荐文献分析[J]. 计算机科学, 2017, 44(Z6): 475-482.
[4] 郭斌,陈荟慧,李文鹏,於志文,姜佳君,王文辉. 记忆计算:概念、特性及研究进展[J]. 计算机科学, 2016, 43(9): 32-38.
[5] 江梦涛,荆琦. C语言静态代码分析中的调用关系提取方法[J]. 计算机科学, 2014, 41(Z6): 442-444.
[6] 徐步刊,周兴社,梁韵基,王海鹏,於志文. 一种场景驱动的情境感知计算框架[J]. 计算机科学, 2012, 39(3): 216-222.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
[1] 张银玲,武彤,邓少勋. 基于快速排序和huffman树的物化视图增量保持算法[J]. 计算机科学, 2014, 41(Z6): 451 -454 .
[2] 张培玲,张洪欣. 基于改进PSO_GA联合算法的电力线多用户通信资源分配[J]. 计算机科学, 2016, 43(5): 51 -55 .
[3] 杜威, 丁世飞. 多智能体强化学习综述[J]. 计算机科学, 2019, 46(8): 1 -8 .
[4] 潘孝勤, 芦天亮, 杜彦辉, 仝鑫. 基于深度学习的语音合成与转换技术综述[J]. 计算机科学, 2021, 48(8): 200 -208 .
[5] 王俊, 王修来, 庞威, 赵鸿飞. 面向科技前瞻预测的大数据治理研究[J]. 计算机科学, 2021, 48(9): 36 -42 .
[6] 余力, 杜启翰, 岳博妍, 向君瑶, 徐冠宇, 冷友方. 基于强化学习的推荐研究综述[J]. 计算机科学, 2021, 48(10): 1 -18 .
[7] 王梓强, 胡晓光, 李晓筱, 杜卓群. 移动机器人全局路径规划算法综述[J]. 计算机科学, 2021, 48(10): 19 -29 .
[8] 高洪皓, 郑子彬, 殷昱煜, 丁勇. 区块链技术专题序言[J]. 计算机科学, 2021, 48(11): 1 -3 .
[9] 毛瀚宇, 聂铁铮, 申德荣, 于戈, 徐石成, 何光宇. 区块链即服务平台关键技术及发展综述[J]. 计算机科学, 2021, 48(11): 4 -11 .
[10] 肖锋, 张鹏程, 罗夏朴. 基于正则表达式、程序插桩和代码替换的以太坊智能合约bug检测和修复方法[J]. 计算机科学, 2021, 48(11): 89 -101 .