Application programming interface(API)libraries are extensively used by developers.To correctly program with APIs and avoid bugs,developers shall pay attention to API directives,which illustrate the constraints of API...Application programming interface(API)libraries are extensively used by developers.To correctly program with APIs and avoid bugs,developers shall pay attention to API directives,which illustrate the constraints of APIs.Unfortunately,API directives usually have diverse morphologies,making it time-consuming and error-prone for developers to discover all the relevant API directives.In this paper,we propose an approach leveraging text classification to discover API directives from API specifications.Specifically,given a set of training sentences in API specifications,our approach first characterizes each sentence by three groups of features.Then,to deal with the unequal distribution between API directives and non-directives,our approach employs an under-sampling strategy to split the imbalanced training set into several subsets and trains several classifiers.Given a new sentence in an API specification,our approach synthesizes the trained classifiers to predict whether it is an API directive.We have evaluated our approach over a publicly available annotated API directive corpus.The experimental results reveal that our approach achieves an F-measure value of up to 82.08%.In addition,our approach statistically outperforms the state-of-the-art approach by up to 29.67%in terms of F-measure.展开更多
基金the National Key Research and Development Plan of China under Grant No.2018YFB1003900the National Natural Science Foundation of China under Grant No.61902181,the China Postdoctoral Science Foundation under Grant No.2020M671489the CCF-Tencent Open Research Fund under Grant No.RAGR20200106.
文摘Application programming interface(API)libraries are extensively used by developers.To correctly program with APIs and avoid bugs,developers shall pay attention to API directives,which illustrate the constraints of APIs.Unfortunately,API directives usually have diverse morphologies,making it time-consuming and error-prone for developers to discover all the relevant API directives.In this paper,we propose an approach leveraging text classification to discover API directives from API specifications.Specifically,given a set of training sentences in API specifications,our approach first characterizes each sentence by three groups of features.Then,to deal with the unequal distribution between API directives and non-directives,our approach employs an under-sampling strategy to split the imbalanced training set into several subsets and trains several classifiers.Given a new sentence in an API specification,our approach synthesizes the trained classifiers to predict whether it is an API directive.We have evaluated our approach over a publicly available annotated API directive corpus.The experimental results reveal that our approach achieves an F-measure value of up to 82.08%.In addition,our approach statistically outperforms the state-of-the-art approach by up to 29.67%in terms of F-measure.