一句话:提出 StatType,用统计机器翻译与共现知识为论坛代码片段中的 API 推断完全限定名。
论文关注 StackOverflow 等在线论坛代码片段中外部 API 引用常未声明、有歧义或未完全限定,导致开发者难以正确学习和使用 API 的问题。作者提出 StatType,一种统计方法,为片段中的 API 元素解析完全限定名(FQN)。方法包含两个整合因素:从大规模训练代码语料学习经常共现的 FQN,并利用目标 API 名称的邻居 API 名称构成上下文;并将任务建模为从“部分限定名的源代码”到“带 FQN 的源代码”的统计机器翻译。在真实代码和 StackOverflow 帖子上的评估表明,StatType 达到 97.6% 精确率和 96.7% 召回率,相对当前最优方法提升 16.5%。
Software developers often make use of the online forums such as StackOverflow (SO) to learn how to use software libraries and their APIs. However, the code snippets in such a forum often contain undeclared, ambiguous, or largely unqualified external references. Such declaration ambiguity and external reference ambiguity present challenges for developers in learning to correctly use the APIs. In this paper, we propose StatType, a statistical approach to resolve the fully qualified names (FQNs) for the API elements in such code snippets. Unlike existing approaches that are based on heuristics, StatType has two well-integrated factors. We first learn from a large training code corpus the FQNs that often co-occur. Then, to derive the FQN for an API name in a code snippet, we use that knowledge and also leverage the context consisting of neighboring API names. To realize those factors, we treat the problem as statistical machine translation from source code with partially qualified names to source code with FQNs of the APIs. Our empirical evaluation on real-world code and StackOverflow posts shows that StatType achieves very high accuracy with 97.6% precision and 96.7% recall, which is 16.5% relatively higher than the state-of-the-art approach.
@inproceedings{paperbot4407,
title = {Statistical learning of API fully qualified names in code snippets of online forums},
author = {Hung Phan and Hoan Anh Nguyen and Ngoc M. Tran and Linh H. Truong and Anh Tuan Nguyen and Tien N. Nguyen},
booktitle = {ICSE},
year = {2018},
doi = {10.1145/3180155.3180230}
}