API相关的知识通常分散隐含在多个信息源, 如API参考文档、问答网站等非结构化的文本中, 不利于API的查询与检索. 为此, 提出一种多源信息融合的API知识图谱构建方法, 以提高API检索的效率. API参考文档从设计者角度描述了API的功能和结构, Stack Overflow问答网站从用户角度提供了API的使用目的及应用场景, 二者互为补充, 可共同为API查询与检索提供支持. 通过分析API参考文档, 抽取API和领域概念作为实体, 构建API和领域概念之间的关联关系; 利用Stack Overflow问答网站, 抽取问答QA和API概念作为实体, 构建问答QA和API概念之间的关联关系. 在此基础上, 将二者进行知识融合, 构建多源API知识图谱, 以实现基于知识图谱的API推荐. 为验证本文方法, 分别从知识抽取的准确性和推荐应用两方面对本文构建API知识图谱的有效性进行评估. 实验结果表明, 基于知识图谱的API推荐, 在推荐效果及效率上均有提升.
API-related knowledge is usually scattered among multiple information sources, such as API reference documentation, Q&A forum and other unstructured texts, which is not conducive to API query and retrieval. To improve the efficiency of API retrieval, this study proposes an API knowledge graph construction method based on multi-source information fusion. API reference documentation describes the function and structure of the API from a designer’s perspective, while Stack Overflow provides the purpose and use scenarios of the API from a user’s perspective. API reference documentation and Stack Overflow complement each other, and they can provide support for API query and retrieval together. By means of analyzing API reference documentation, API and domain concepts can be extracted as entities and their relationships can be constructed. With the Stack Overflow website, Q&A and API concepts can be extracted as entities and their relationships can also be constructed. On this basis, these two kinds of information are fused to construct a multi-source API knowledge graph for the API recommendation based on the knowledge graph. To verify the proposed method, this study evaluates the effectiveness of the API knowledge graph in terms of the accuracy of knowledge extraction and the API recommendation. The experimental results show that the recommendation effectiveness and efficiency based on our knowledge graph have been improved.