对象实例化是软件工程类库复用中一个常见、复杂的问题.即根据已知源类型的对象,用户需要编写代码对目标类型进行实例化.研究人员提出了若干种API自动推荐系统辅助用户解决上述问题.然而这些系统不能同时兼顾准确率和查全率,因此在一定程度上影响了系统的实用性.该文提出了一种兼顾准确率和查全率,基于新型图模型的API推荐系统——APISynth.在查全率方面,APISynth使用一个新颖的全局图模型来表达类库中所有的API依赖关系和API历史使用信息.利用新的全局图模型具有的特殊Tag元素和可达性质以避免错误的API调用.在准确率方面,APISynth首先将对象实例化问题建模为Top-K子图查询问题,然后设计一种新的支持DAG形式解的图搜索算法,避免了传统的最短路径图搜索算法导致的查不准问题.实验结果表明,与现有多种方法相比,APISynth在准确率和查全率两方面均获得了较大提升.
How to perform object instantiation is a common and complex problem in reusing an existing library.In this problem,given the object of source type,users need to write code to instantiate the destination type.Recently,researchers have proposed a variety of related API automatic recommender systems to fulfill this problem.These systems can assist users to solve the above issue in some degree.However,it is very difficult for such systems to achieve both good recall and precision,which affects the usability.This paper presents APISynth,a new graph-based API recommender system.In order to improve the recall,APISynth utilizes a new global graph model to give a better representation for the API dependencies in the relevant class library,and to include API historical usage information in.A special tag element is added to the new graph together with a new reach ability property to avoid false invocation of APIs.Meanwhile,unlike the shortest path problem proposed by the traditional methods,in order to improve the precision,APISynth models the object instantiation issue as a Top-K subgraphs searching problem.A new graph search algorithm is designed to directly support output of DAGlike solutions.Experimental results show that APISynth wins over the state of the art with respect to both the two criteria.