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

使用标识符嵌入的语义源代码模型

Semantic Source Code Models Using Identifier Embeddings

Vasiliki Efstathiou, Diomidis Spinellis

AI总结:

本文利用 fastText 对 Java、Python、PHP、C、C++ 和 C# 六种语言的超过 13,000 个代码仓库训练标识符嵌入模型,以构建语义代码表示,并分析了跨语言差异对预处理和训练参数的影响。

摘要:

近年来,在线开源代码仓库的出现导致可公开获取的源代码数量激增,同时伴随着与各种软件开发活动相关的元数据。因此,与机器学习研究的最新进展相一致,软件维护活动正从符号化形式方法转向数据驱动方法。在这一背景下,隐藏在源代码标识符中的丰富语义为构建代码的语义表示提供了机会,这些表示可以辅助代码搜索和复用等任务。为此,我们以预训练向量空间模型的形式,提供了六种流行编程语言的分布式代码表示,即 Java、Python、PHP、C、C++ 和 C#。这些模型使用 fastText 生成,fastText 是一个用于学习词表示的最先进库。每个模型都在单一编程语言的数据上进行训练;为生成所有模型而挖掘的代码总计超过 13,000 个仓库。我们指出了自然语言与源代码之间的差异,以及我们所处理的不同编程语言之间编码约定的变化。我们描述了这些异质性如何指导我们所采取的数据预处理决策以及已发布模型中训练参数的选择。最后,我们提出了这些模型的潜在应用,并讨论了模型的局限性。

英文摘要:

The emergence of online open source repositories in the recent years has led to an explosion in the volume of openly available source code, coupled with metadata that relate to a variety of software development activities. As an effect, in line with recent advances in machine learning research, software maintenance activities are switching from symbolic formal methods to data-driven methods. In this context, the rich semantics hidden in source code identifiers provide opportunities for building semantic representations of code which can assist tasks of code search and reuse. To this end, we deliver in the form of pretrained vector space models, distributed code representations for six popular programming languages, namely, Java, Python, PHP, C, C++, and C#. The models are produced using fastText, a state-of-the-art library for learning word representations. Each model is trained on data from a single programming language; the code mined for producing all models amounts to over 13.000 repositories. We indicate dissimilarities between natural language and source code, as well as variations in coding conventions in between the different programming languages we processed. We describe how these heterogeneities guided the data preprocessing decisions we took and the selection of the training parameters in the released models. Finally, we propose potential applications of the models and discuss limitations of the models.

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

↑