arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2102.04706cs.SE
收藏

PyART:Python API实时的推荐

PyART: Python API Recommendation in Real-Time

Xincheng He, Lei Xu, Xiangyu Zhang, Rui Hao, Yang Feng, Baowen Xu

摘要:

实时的【形】API推荐对于像Python这样的动态语言来说是一个挑战。现有的许多API推荐技术都是非常有效的,但它们主要支持静态语言。一些Python IDE提供了基于类型推断的API推荐功能,并在大量Python库和第三方库上进行了训练。因此,当类型信息丢失或目标API是特定于项目时,它们可能无法推荐或做出糟糕的推荐。在本文中,我们提出了一种新的方法,PyART,为Python程序实时的【形】推荐API。它的特点是轻量级的分析,以获得所谓的乐观数据流,这是既不健全也不完整,但模拟人类可以获得的本地数据流信息。它提取了三种特征:数据流,令牌相似性和令牌同现,在程序点的上下文中,征求建议。使用随机森林算法在这些特征上训练预测模型。对8个流行Python项目的评估表明,PyART可以提供有效的API建议。当可以利用历史提交时,这是最先进的工具ARIREC的目标场景,我们的平均前1准确率超过50%,平均前10准确率超过70%,优于APIREC和Intellicode(即,Visual Studio中的推荐组件)的前1名准确率提高了28.48%-39.05%,前10名准确率提高了24.41%-30.49%。在其他应用中,例如当历史注释不可用时,以及跨项目推荐时,PyART也显示出更好的整体性能。推荐时间平均不到一秒,满足实时的【形】要求。

英文摘要:

API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they mainly support static languages. A few Python IDEs provide API recommendation functionalities based on type inference and training on a large corpus of Python libraries and third-party libraries. As such, they may fail to recommend or make poor recommendations when type information is missing or target APIs are project-specific. In this paper, we propose a novel approach, PyART, to recommend APIs for Python programs in real-time. It features a light-weight analysis to derives so-called optimistic data-flow, which is neither sound nor complete, but simulates the local data-flow information humans can derive. It extracts three kinds of features: data-flow, token similarity, and token co-occurrence, in the context of the program point where a recommendation is solicited. A predictive model is trained on these features using the Random Forest algorithm. Evaluation on 8 popular Python projects demonstrates that PyART can provide effective API recommendations. When historic commits can be leveraged, which is the target scenario of a state-of-the-art tool ARIREC, our average top-1 accuracy is over 50% and average top-10 accuracy over 70%, outperforming APIREC and Intellicode (i.e., the recommendation component in Visual Studio) by 28.48%-39.05% for top-1 accuracy and 24.41%-30.49% for top-10 accuracy. In other applications such as when historic comments are not available and cross-project recommendation, PyART also shows better overall performance. The time to make a recommendation is less than a second on average, satisfying the real-time requirement.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑