计算机科学 ›› 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, Context awareness, Developer portraits, Program static analysis

中图分类号: 

  • 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] 张宏丽, 白翔宇, 李改梅.
利用最近邻域推荐且结合情境感知的个性化推荐算法
Personalized Recommendation Algorithm Based on Recent Neighborhood Recommendation and Combined with Context Awareness
计算机科学, 2019, 46(4): 235-240. https://doi.org/10.11896/j.issn.1002-137X.2019.04.037
[2] 韩立, 刘正捷.
CAUXT:帮助研究人员在感兴趣的情境中采集用户体验数据
CAUXT:A Tool to Help User Experience Researchers Capture Users’ Experience Data in Context of Interest
计算机科学, 2018, 45(7): 278-285. https://doi.org/10.11896/j.issn.1002-137X.2018.07.048
[3] 聂黎明,江贺,高国军,王涵,徐秀娟.
代码搜索与API推荐文献分析
Bibliographic Analysis for Code/API Recommendation Literatures
计算机科学, 2017, 44(Z6): 475-482. https://doi.org/10.11896/j.issn.1002-137X.2017.6A.106
[4] 郭斌,陈荟慧,李文鹏,於志文,姜佳君,王文辉.
记忆计算:概念、特性及研究进展
Memory Computing:Concept,Characteristics and Research Advances
计算机科学, 2016, 43(9): 32-38. https://doi.org/10.11896/j.issn.1002-137X.2016.09.006
[5] 江梦涛,荆琦.
C语言静态代码分析中的调用关系提取方法
Method of Extracting Function Call Relationship in Static Code Analysis of C Language
计算机科学, 2014, 41(Z6): 442-444.
[6] 徐步刊,周兴社,梁韵基,王海鹏,於志文.
一种场景驱动的情境感知计算框架
Situation-driven Framework for Context-aware Computing
计算机科学, 2012, 39(3): 216-222.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!