CodeKernel: A Graph Kernel based Approach to the Selection of API Usage Examples

被引:22
作者
Gu, Xiaodong [1 ,3 ]
Zhang, Hongyu [2 ]
Kim, Sunghun [1 ,3 ]
机构
[1] Hong Kong Univ Sci & Technol, Hong Kong, Peoples R China
[2] Univ Newcastle, Callaghan, NSW, Australia
[3] NAVER Corp, Clova AI Res, Seongnam Si, South Korea
来源
34TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING (ASE 2019) | 2019年
关键词
CLASSIFICATION;
D O I
10.1109/ASE.2019.00061
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
Developers often want to find out how to use a certain API (e.g., FileReader.read in JDK library). API usage examples are very helpful in this regard. Over the years, many automated methods have been proposed to generate code examples by clustering and summarizing relevant code snippets extracted from a code corpus. These approaches simplify source code as method invocation sequences or feature vectors. Such simplifications only model partial aspects of the code and tend to yield inaccurate examples. We propose CodeKernel, a graph kernel based approach to the selection of API usage examples. Instead of approximating source code as method invocation sequences or feature vectors, CodeKernel represents source code as object usage graphs. Then, it clusters graphs by embedding them into a continuous space using a graph kernel. Finally, it outputs code examples by selecting a representative graph from each cluster using designed ranking metrics. Our empirical evaluation shows that CodeKernel selects more accurate code examples than the related work (MUSE and EXOADOCS). A user study involving 25 developers in a multinational company also confirms the usefulness of CodeKernel in selecting API usage examples.
引用
收藏
页码:602 / 613
页数:12
相关论文
共 50 条
[1]   Mining Idioms from Source Code [J].
Allamanis, Miltiadis ;
Sutton, Charles .
22ND ACM SIGSOFT INTERNATIONAL SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING (FSE 2014), 2014, :472-483
[2]  
Nguyen AT, 2018, 2018 25TH IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION AND REENGINEERING (SANER 2018), P323, DOI 10.1109/SANER.2018.8330220
[3]   API Code Recommendation using Statistical Learning from Fine-Grained Changes [J].
Anh Tuan Nguyen ;
Hilton, Michael ;
Codoban, Mihai ;
Hoan Anh Nguyen ;
Mast, Lily ;
Rademacher, Eli ;
Nguyen, Tien N. ;
Dig, Danny .
FSE'16: PROCEEDINGS OF THE 2016 24TH ACM SIGSOFT INTERNATIONAL SYMPOSIUM ON FOUNDATIONS OF SOFTWARE ENGINEERING, 2016, :511-522
[4]  
Nguyen AT, 2012, PROC INT CONF SOFTW, P69, DOI 10.1109/ICSE.2012.6227205
[5]  
[Anonymous], 24 AAAI C ART INT
[6]  
[Anonymous], ARXIV150707306
[7]  
BISHOP C. M., 2006, Pattern recognition and machine learning, DOI [DOI 10.1117/1.2819119, 10.1007/978-0-387-45528-0]
[8]  
Borgwardt K. M., 2005, ICDM, DOI DOI 10.1109/ICDM.2005.132
[9]   Protein function prediction via graph kernels [J].
Borgwardt, KM ;
Ong, CS ;
Schönauer, S ;
Vishwanathan, SVN ;
Smola, AJ ;
Kriegel, HP .
BIOINFORMATICS, 2005, 21 :I47-I56
[10]   Learning from Examples to Improve Code Completion Systems [J].
Bruch, Marcel ;
Monperrus, Martin ;
Mezini, Mira .
7TH JOINT MEETING OF THE EUROPEAN SOFTWARE ENGINEERING CONFERENCE AND THE ACM SIGSOFT SYMPOSIUM ON THE FOUNDATIONS OF SOFTWARE ENGINEERING, 2009, :213-222