一句话:用机器学习从 Stack Overflow 抽取可比 API 方法并提供工具提示,用户研究证明其能帮助开发者理解 API 设计空间。
开发者学习新 API 时常常缺乏文档信息,转而依赖 Stack Overflow 等问答平台。本文研究如何用基于机器学习的知识抽取技术,自动识别 Stack Overflow 回答中可比的 API 方法对及描述其比较的句子。作者先实现了一个由可比 API 方法数据集驱动的原型工具,在搜索结果和 API 文档中向用户提供工具提示;随后基于 198 条人工标注的 TensorFlow 事实开展用户研究,发现使用该工具的开发者显著更了解可比 API 方法,也更能理解其间的差异。作者进一步构建了抽取工具 SOREL,在人工标注语料上训练,发现事实的精确率为 71%、召回率为 55%,并从数千条未见过的 Stack Overflow 帖子中抽取了 433 对可比 API 方法。该工作表明,联合研究编程辅助工具与支撑它的机器学习技术具有价值。
Developers constantly learn new APIs, but often lack necessary information from documentation, resorting instead to popular question-and-answer platforms such as Stack Overflow. In this paper, we investigate how to use recent machine-Iearning-based knowledge extraction techniques to automatically identify pairs of comparable API methods and the sentences describing the comparison from Stack Overflow answers. We first built a prototype that can be stocked with a dataset of comparable API methods and provides tool-tips to users in search results and in API documentation. We conducted a user study with this tool based on a dataset of TensorFlow comparable API methods spanning 198 hand-annotated facts from Stack Overflow posts. This study confirmed that providing comparable API methods can be useful for helping developers understand the design space of APIs: developers using our tool were significantly more aware of the comparable API methods and better understood the differences between them. We then created SOREL, an comparable API methods knowledge extraction tool trained on our hand-annotated corpus, which achieves a 71% precision and 55% recall at discovering our manually extracted facts and discovers 433 pairs of comparable API methods from thousands of unseen Stack Overflow posts. This work highlights the merit of jointly studying programming assistance tools and constructing machine learning techniques to power them.