一句话:构建语义关系知识图谱并从语料中学习搜索策略,将标识符缩写扩展的精度从 29% 提升到 85%。
标识符在源代码字符中占约 70%,其质量直接影响程序理解与软件维护,但标识符中普遍存在的缩写降低了可读性与可维护性。已有缩写扩展方法要么精度不足,要么只能处理特定类型的标识符。本文提出一种通用且准确的标识符缩写扩展方法,其核心洞察是:软件实体 e 名称中的缩写,有很大概率能在与 e 语义相关的其他实体名称中找到对应完整词。据此,方法为实体及其语义关系构建知识图谱,并在图上搜索完整词汇;图上的最优搜索策略可从人工扩展的缩写语料中自动学习得到。作者在九个知名开源项目上开展 k 折评估,结果显示该方法优于现有工作:精度从 29% 提升至 85%,召回率从 29% 提升至 77%;在参数缩写扩展上,这一通用方法甚至优于针对参数设计的专用方法,F1 分数从 75% 提升至 87%。
Identifiers account for 70% of source code in terms of characters, and thus the quality of such identifiers is critical for program comprehension and software maintenance. For various reasons, however, many identifiers contain abbreviations, which reduces the readability and maintainability of source code. To this end, a number of approaches have been proposed to expand abbreviations in identifiers. However, such approaches are either inaccurate or confined to specific identifiers. To this end, in this paper we propose a generic and accurate approach to expand identifier abbreviations. The key insight of the approach is that abbreviations in the name of software entity e have great chance to find their full terms in names of software entities that are semantically related to e. Consequently, the proposed approach builds a knowledge graph to represent such entities and their relationships with e, and searches the graph for full terms. The optimal searching strategy for the graph could be learned automatically from a corpus of manually expanded abbreviations. We evaluate the proposed approach on nine well known open-source projects. Results of our k-fold evaluation suggest that the proposed approach improves the state of the art. It improves precision significantly from 29% to 85%, and recall from 29% to 77%. Evaluation results also suggest that the proposed generic approach is even better than the state-of-the-art parameter-specific approach in expanding parameter abbreviations, improving F1 score significantly from 75% to 87%.
DOI 原文 ·
@inproceedings{paperbot5175,
title = {Semantic relation based expansion of abbreviations},
author = {Yanjie Jiang and Hui Liu and Lu Zhang},
booktitle = {FSE},
year = {2019},
doi = {10.1145/3338906.3338929}
}