基于编程现场大数据的API个性化推荐方法

 2022-08-08 09:08

论文总字数:25779字

摘 要

在计算机软件行业飞速发展的信息时代,开发人员如何快速编写高质量的代码成为软件工程领域研究的问题之一。如今网络上开源项目丰富,开发人员如果可以直接利用开源代码中他人实现过的功能,而不是浪费时间重复实现已有的功能,开发效率将大大得到提高。尽管目前学术界针对代码搜索和推荐方面进行了大量工作,但是基于API功能描述向用户个性化推荐API的工具仍然有限。

本文提出了一种API个性化推荐算法,并且基于该算法实现了一个面向Java语言的API个性化推荐工具。用户在分析编程现场上下文之后,提供自然语言描述的API搜索条件,工具利用搜索条件和本地代码库中的API信息进行语义相关性匹配和类型相关性匹配,根据匹配分数对候选API进行排序,向用户推荐排名最靠前的10个API。工具采用Java标准库以及30个流行的开源库作为API推荐材料。

评估实验表明,工具在推荐的前10个结果中推荐正确API的概率为46%,在第一位就推荐正确的概率为28%,平均搜索时间为1.23秒,采用语义匹配和类型匹配相结合的方式比仅仅使用语义匹配更有效。

关键词:API推荐,搜索,语义匹配,类型匹配

Abstract

In the information age where the computer technology is rapidly developing, how developers can quickly write high quality code becomes one of the problems in the field of software engineering. Nowadays, there are many open source projects on the Internet, developers can greatly improve the development efficiency if they can directly use the functions that have been implemented by others in the open source code instead of wasting time to implement the existing functions repeatedly. Although a lot of work has been done in the academia for code search and recommendation, the tools for personalizing API recommendation based on API function descriptions are still limited.

This paper presents an API personalized recommendation algorithm and implements an API personalized recommendation tool for Java based on this algorithm. After analyzing the programming context, the user provides the API search conditions described by the natural language. The tool uses the search conditions and the API information in the local code base to perform semantic relevance matching and type correlation matching, and sorts candidate APIs according to the matching scores. Top 10 APIs are recommended to users. The tool uses the Java standard library and 30 popular open source libraries as API recommendation material.

The evaluation experiment shows that the probability of the tool recommending the correct API in the top 10 results is 46%, the correct probability is 28% in the first place, the average search time is 1.23 seconds, and the combination of semantic matching and type matching is more efficient than just using semantic matching.

KEY WORDS: API recommendation, search, semantic matching, type matching

目 录

摘要 I

Abstract II

第一章 绪论 1

1.1 研究背景和意义 1

1.2 文献综述 1

1.2.1 国外研究现状分析 1

1.2.2 国内研究现状分析 2

1.2.3 发展方向 2

1.2.4 存在问题 3

1.3 本文组织与结构 3

第二章 技术路线 4

2.1 总体结构 4

2.2 API推荐算法 5

2.3 API描述 6

2.3.1 语义信息 6

2.3.2 类型信息 7

2.4 本地代码库及索引构建 7

2.4.1 程序仓库构建 8

2.4.2 数据库构建 8

2.4.3 索引构建 9

2.5 匹配及排序 13

2.5.1 语义匹配 13

2.5.2 类型匹配 14

2.5.3 总体得分 14

第三章 实验及评估 16

3.1 实验环境 16

3.2 工具实现 16

3.3 准确度评估 16

3.4 效率评估 21

第四章 结论 22

4.1 主要结论 22

4.2 局限性 22

4.3 研究展望 22

致 谢 24

参考文献 25

绪论

研究背景和意义

在计算机软件快速发展的信息时代,开发人员如何快速编写高质量的软件成为软件工程领域研究的核心问题之一。在代码开发的过程中,开发人员往往需要花费大量的时间去实现某些他人已经实现过的功能,这样的重复开发大大降低了软件行业的生产力。

随着互联网和计算机科学技术的进步,出现了更复杂的程序库来帮助开发人员简化开发,也有越来越多的开源项目被上传到开源社区,代码重用成为提高软件开发生产力的主要技术之一。如果开发人员能够搜索到符合当前编程现场的功能,直接重用这部分的代码而不是花费自己的时间去编写函数,可以极大的提高生产效率。但是,JDK8的基本库就包含了十万多个API,开源项目中的API更是数不胜数,选择合适的API成为开发人员编程过程中的瓶颈之一。

许多开发人员需要借助各种搜索引擎(如Google、百度等)来查找符合需求的API,搜索引擎可以通过搜索和排序找到相关的API的信息,例如文档、博客、论坛等,但因为搜索引擎并不专注于搜索API,其搜索结果中往往还包含了其他各种各样的网页,其中存在许多不相关的、不精确的或者对开发帮助不大的信息,浏览和学习一些不必要的信息会导致开发效率大大下降。

剩余内容已隐藏,请支付后下载全文,论文总字数:25779字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;