arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1910.05177cs.LGcs.PLcs.SEstat.ML
收藏

IdBench:评估Source Code中标识符名称的语义表示

IdBench: Evaluating Semantic Representations of Identifier Names in Source Code

TU Darmstadt(达姆施塔特工业大学);University of Stuttgart(斯图加特大学)

Yaza Wainakh, Moiz Rauf, Michael Pradel

摘要:

标识符名称传达有关代码预期语义的有用信息。基于名称的程序分析使用该信息,例如,检测错误,预测类型,提高代码的可读性。基于名称的分析的核心是标识符的语义表示,例如,以学习嵌入的形式。这种表示的高级目标是编码两个标识符,例如,Lens和Size在语义上相似。不幸的是,目前还不清楚语义表示在多大程度上与开发人员感知的语义相关性和相似性相匹配。本文介绍了IdBench,第一个基准评估语义表示对地面真相从数千个评级由500名软件开发人员。我们使用IdBench来研究为自然语言提出的最先进的嵌入技术,一种专门为源代码设计的嵌入技术,以及词汇字符串距离函数。我们的研究结果表明,语义表示的有效性差异显着,最好的嵌入成功地代表语义相关性。不利的是,没有现有技术提供语义相似性的令人满意的表示,除了其他原因之外,因为具有相反含义的标识符被错误地认为是相似的,这可能导致致命的错误,例如,一个重构工具。研究不同技术的优点和缺点表明,它们是相辅相成的。作为利用这种互补性的第一步,我们提出了一个集成模型,结合现有的技术,显然优于最好的语义表示。

英文摘要:

Identifier names convey useful information about the intended semantics of code. Name-based program analyses use this information, e.g., to detect bugs, to predict types, and to improve the readability of code. At the core of name-based analyses are semantic representations of identifiers, e.g., in the form of learned embeddings. The high-level goal of such a representation is to encode whether two identifiers, e.g., len and size, are semantically similar. Unfortunately, it is currently unclear to what extent semantic representations match the semantic relatedness and similarity perceived by developers. This paper presents IdBench, the first benchmark for evaluating semantic representations against a ground truth created from thousands of ratings by 500 software developers. We use IdBench to study state-of-the-art embedding techniques proposed for natural language, an embedding technique specifically designed for source code, and lexical string distance functions. Our results show that the effectiveness of semantic representations varies significantly and that the best available embeddings successfully represent semantic relatedness. On the downside, no existing technique provides a satisfactory representation of semantic similarities, among other reasons because identifiers with opposing meanings are incorrectly considered to be similar, which may lead to fatal mistakes, e.g., in a refactoring tool. Studying the strengths and weaknesses of the different techniques shows that they complement each other. As a first step toward exploiting this complementarity, we present an ensemble model that combines existing techniques and that clearly outperforms the best available semantic representation.

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

↑