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 条
[11]  
Buse RPL, 2012, PROC INT CONF SOFTW, P782, DOI 10.1109/ICSE.2012.6227140
[12]   Enzyme family classification by support vector machines [J].
Cai, CZ ;
Han, LY ;
Ji, ZL ;
Chen, YZ .
PROTEINS-STRUCTURE FUNCTION AND BIOINFORMATICS, 2004, 55 (01) :66-76
[13]   Document clustering using locality preserving indexing [J].
Cai, D ;
He, XF ;
Han, JW .
IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, 2005, 17 (12) :1624-1637
[14]  
CHUANG J, 2012, INTRO INFORM RETRIEV, V19, DOI DOI 10.1145/2362364.2362367
[15]  
d'Amorim M, 2006, IEEE INT CONF AUTOM, P59
[16]  
Davis D, 2009, BASICS, P440, DOI 10.1533/9781845696474.3.440
[17]  
Fowkes J., 2015, ARXIV151205558
[18]  
Gartner T., 2003, SIGKDD, V5, P49, DOI 10.1145/959242.959248
[19]   Mining unit test cases to synthesize API usage examples [J].
Ghafari, Mohammad ;
Rubinov, Konstantin ;
Pourhashem K, Mohammad Mehdi .
JOURNAL OF SOFTWARE-EVOLUTION AND PROCESS, 2017, 29 (12)
[20]   Deep Code Search [J].
Gu, Xiaodong ;
Zhang, Hongyu ;
Kim, Sunghun .
PROCEEDINGS 2018 IEEE/ACM 40TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE), 2018, :933-944