paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Learning from Examples to Find Fully Qualified Names of API Elements in Code Snippets

从示例中学习以发现代码片段中 API 元素的完全限定名
ASE 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE)2019匹配度 3/10 · 该论文研究从代码片段中解析 API 元素完全限定名(FQN),属于程序分析与机器学习的交叉,但既不涉及 LLM/Agentic 程序,也不涉及静态分析在机器学习系统中的应用,更不涉及浮点程序分析或贝叶斯程序分析。它与用户“AI→PL”中用机器学习改进程序分析工具有弱关联,但并非核心方向。引用 23 inbox
C M Khaled Saifullah, Muhammad Asaduzzaman, Chanchal K. Roy
crossref: 2026-09-12

AI 速览

一句话:提出 COSTER,利用局部与全局上下文及似然词典,从示例中解析代码片段里 API 元素的完全限定名。

开发者常从 Stack Overflow 等论坛复用代码片段学习 API 用法,但片段中未声明的外部引用使 API 难以正确使用,手动解析完全限定名(FQN)成本高。本文提出上下文敏感技术 COSTER:抽取局部源码元素与全局相关 token 构成上下文,计算似然分数并构建出现似然词典(OLD);给定查询 API 元素,将其上下文与 OLD 中 FQN 匹配,并按似然、上下文相似度和名称相似度排序。在超 60 万 GitHub 示例和两个 Stack Overflow 数据集上,精度提升 4–6%,召回提升 3–22%,且训练时间显著低于 StatType 而不损失准确率。

问题
代码片段中的未声明外部引用导致 API 元素完全限定名(FQN)缺失,开发者手动解析困难且需专业知识。
方法
提出 COSTER,基于局部与全局上下文、似然分数和出现似然词典(OLD)匹配并排序候选 FQN。
评估
在 60 万+ GitHub 示例与两个 Stack Overflow 数据集上评估,精度提升 4–6%、召回提升 3–22%,并显著减少训练时间。
原文摘要(Abstract)

Developers often reuse code snippets from online forums, such as Stack Overflow, to learn API usages of software frameworks or libraries. These code snippets often contain ambiguous undeclared external references. Such external references make it difficult to learn and use those APIs correctly. In particular, reusing code snippets containing such ambiguous undeclared external references requires significant manual efforts and expertise to resolve them. Manually resolving fully qualified names (FQN) of API elements is a non-trivial task. In this paper, we propose a novel context-sensitive technique, called COSTER, to resolve FQNs of API elements in such code snippets. The proposed technique collects locally specific source code elements as well as globally related tokens as the context of FQNs, calculates likelihood scores, and builds an occurrence likelihood dictionary (OLD). Given an API element as a query, COSTER captures the context of the query API element, matches that with the FQNs of API elements stored in the OLD, and rank those matched FQNs leveraging three different scores: likelihood, context similarity, and name similarity scores. Evaluation with more than 600K code examples collected from GitHub and two different Stack Overflow datasets shows that our proposed technique improves precision by 4-6% and recall by 3-22% compared to state-of-the-art techniques. The proposed technique significantly reduces the training time compared to the StatType, a state-of-the-art technique, without sacrificing accuracy. Extensive analyses on results demonstrate the robustness of the proposed technique.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot5256,
  title = {Learning from Examples to Find Fully Qualified Names of API Elements in Code Snippets},
  author = {C M Khaled Saifullah and Muhammad Asaduzzaman and Chanchal K. Roy},
  booktitle = {ASE},
  year = {2019},
  doi = {10.1109/ase.2019.00032}
}