paperbot · PL 论文追踪

全部论文 待读 收藏

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

CodeKernel:一种基于图核的 API 用法示例选择方法
ASE 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE)2019匹配度 2/10 · 该论文属于机器学习与程序语言交叉,但研究目标是基于对象使用图和图核聚类选择 API 用法示例,不涉及 LLM/Agent、静态分析、浮点程序分析或贝叶斯程序分析等用户核心方向,仅与代码表示学习有微弱关联。引用 26 inbox
Xiaodong Gu, Hongyu Zhang, Sunghun Kim
crossref: 2026-09-12

AI 速览

一句话:提出 CodeKernel,用对象使用图与图核聚类选择更准确的 API 用法示例。

开发者常需要了解特定 API 的用法,但从代码库自动生成示例颇具挑战。现有方法多把源码简化为方法调用序列或特征向量,只建模部分信息,导致示例不准确。本文提出 CodeKernel,将源码片段表示为对象使用图(object usage graph),以保留方法调用与对象间结构关系;随后利用图核将图嵌入连续空间并进行聚类,再通过设计的排序指标从每个簇中选取代表性图作为代码示例。实验表明,CodeKernel 在示例准确性上优于 MUSE 与 eXoaDocs;一项涉及跨国公司 25 名开发者的用户研究也证实了其选择 API 用法示例的有效性。

问题
如何从代码库中自动选择准确、有用的 API 用法示例,避免现有方法将代码简化为方法调用序列或特征向量而丢失结构信息。
方法
CodeKernel 将源码片段建模为对象使用图,使用图核将图嵌入连续空间后聚类,并依据排序指标从各簇中选出代表性图作为示例。
评估
在 API 用法示例选择任务上与 MUSE、eXoaDocs 进行实证对比,并开展包含跨国公司 25 名开发者的用户研究。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot5316,
  title = {CodeKernel: A Graph Kernel Based Approach to the Selection of API Usage Examples},
  author = {Xiaodong Gu and Hongyu Zhang and Sunghun Kim},
  booktitle = {ASE},
  year = {2019},
  doi = {10.1109/ase.2019.00061}
}