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
关键词
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] A Graph-based Approach to API Usage Adaptation
    Hoan Anh Nguyen
    Tung Thanh Nguyen
    Wilson, Gary, Jr.
    Anh Tuan Nguyen
    Kim, Miryung
    Nguyen, Tien N.
    ACM SIGPLAN NOTICES, 2010, 45 (10) : 302 - 321
  • [2] Synthesizing API Usage Examples
    Buse, Raymond P. L.
    Weimer, Westley
    2012 34TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE), 2012, : 782 - 792
  • [3] Synthesising Linear API Usage Examples for API Documentation
    Alharbi, Seham
    Kolovos, Dimitris
    Matragkas, Nicholas
    2022 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE AND EVOLUTION (ICSME 2022), 2022, : 607 - 611
  • [4] Unit Tests as API Usage Examples
    Nasehi, Seyed Mehdi
    Maurer, Frank
    2010 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE, 2010,
  • [5] APISonar: Mining API usage examples
    Hora, Andre
    SOFTWARE-PRACTICE & EXPERIENCE, 2021, 51 (02): : 319 - 352
  • [6] Visualizing API Usage Examples at Scale
    Glassman, Elena L.
    Zhang, Tianyi
    Hartmann, Bjoern
    Kim, Miryung
    PROCEEDINGS OF THE 2018 CHI CONFERENCE ON HUMAN FACTORS IN COMPUTING SYSTEMS (CHI 2018), 2018,
  • [7] Task-Oriented API Usage Examples Prompting Powered By Programming Task Knowledge Graph
    Sun, Jiamou
    Xing, Zhenchang
    Peng, Xin
    Xu, Xiwei
    Zhu, Liming
    2021 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE AND EVOLUTION (ICSME 2021), 2021, : 448 - 459
  • [8] An Exploratory Study of API Usage Examples on the Web
    Wang, Lijie
    Zou, Yanzhen
    Fang, Lu
    Xie, Bing
    Yang, Fuqing
    2012 19TH ASIA-PACIFIC SOFTWARE ENGINEERING CONFERENCE (APSEC), VOL 1, 2012, : 396 - 405
  • [9] Inappropriate Usage Examples in Web API Documentations
    Hosono, Masaki
    Washizaki, Hironori
    Honda, Kiyoshi
    Nagumo, Hiromasa
    Sonoda, Hisanobu
    Fukazawa, Yoshiaki
    Munakata, Kazuki
    Nakagawa, Takao
    Nemoto, Yusuke
    Tokumoto, Susumu
    Monpratarnchai, Supasit
    2019 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE AND EVOLUTION (ICSME 2019), 2019, : 343 - 347
  • [10] Detecting API-Misuse Based on Pattern Mining via API Usage Graph with Parameters
    Wu, Yulin
    Xu, Zhiwu
    Qin, Shengchao
    THEORETICAL ASPECTS OF SOFTWARE ENGINEERING, TASE 2023, 2023, 13931 : 344 - 363