Skip to main content
QUICK REVIEW

[论文解读] Deep Learning to Detect Redundant Method Comments

Annie Louis, Santanu Kumar Dash|arXiv (Cornell University)|Jun 12, 2018
Software Engineering Research参考文献 28被引用 9
一句话总结

本文提出一种深度学习方法,通过从代码中建模注释蕴涵关系来检测冗余的方法注释,采用在代码-注释对上微调的序列到序列模型。该工具Craic可识别仅重述代码的注释(高蕴涵度),结果显示Javadoc标签如@param和@throws的可预测性至少是自由格式注释的两倍,表明其信息量较低。

ABSTRACT

Comments in software are critical for maintenance and reuse. But apart from prescriptive advice, there is little practical support or quantitative understanding of what makes a comment useful. In this paper, we introduce the task of identifying comments which are uninformative about the code they are meant to document. To address this problem, we introduce the notion of comment entailment from code, high entailment indicating that a comment's natural language semantics can be inferred directly from the code. Although not all entailed comments are low quality, comments that are too easily inferred, for example, comments that restate the code, are widely discouraged by authorities on software style. Based on this, we develop a tool called CRAIC which scores method-level comments for redundancy. Highly redundant comments can then be expanded or alternately removed by the developer. CRAIC uses deep language models to exploit large software corpora without requiring expensive manual annotations of entailment. We show that CRAIC can perform the comment entailment task with good agreement with human judgements. Our findings also have implications for documentation tools. For example, we find that common tags in Javadoc are at least two times more predictable from code than non-Javadoc sentences, suggesting that Javadoc tags are less informative than more free-form comments

研究动机与目标

  • 为解决缺乏实用支持以识别仅重述代码的无信息注释的问题。
  • 开发一种机器学习框架,用于评分注释冗余性,而无需昂贵的手动标注。
  • 调查常见Javadoc标签是否比自由格式注释更具可预测性,从而信息量更低。
  • 评估使用深度学习自动检测可从代码轻松推断的注释的可行性。

提出的方法

  • 作者将'注释蕴涵'定义为注释语义可从代码中推断的程度,高蕴涵度表示冗余。
  • 在GitHub上大规模Java代码-注释对语料库上训练序列到序列深度学习模型,以从代码预测注释。
  • 通过在代码上预训练并结合标注数据进行微调,使用困惑度作为蕴涵度的代理指标。
  • 构建名为Craic的工具,基于预测困惑度对方法级注释进行评分,低困惑度表示高冗余性。
  • 该方法利用预训练语言模型,利用大规模软件语料库,而无需手动标注蕴涵关系。
  • 通过将Javadoc标签(如@param、@return)的平均困惑度与非Javadoc注释进行比较,评估注释类型。

实验结果

研究问题

  • RQ1在多大程度上可基于代码的可预测性自动检测注释为冗余?
  • RQ2Javadoc标签如@param和@return是否比自由格式注释更具可预测性,表明其信息量更低?
  • RQ3在注释冗余性的人工判断上,基于代码-注释对训练的深度学习模型预测结果与人类判断的一致性如何?
  • RQ4序列到序列模型的困惑度能否作为注释蕴涵和冗余性的可靠代理指标?
  • RQ5这些发现对文档生成器和开发者指南的设计有何启示?

主要发现

  • Javadoc标签如@param和@throws的可预测性至少是非Javadoc注释的两倍,表明其信息量较低。
  • @param和@throws注释的平均困惑度分别为6.49和2.50,显著低于非Javadoc注释的15.58的平均值。
  • 在190对标注的Javadoc注释对中,有180对被人工标注者判断为蕴涵或部分蕴涵,证实了高度冗余性。
  • 深度学习模型的预测结果与人类对注释冗余性的判断高度一致,验证了其有效性。
  • 常见Javadoc字段系统性地信息量低于自由格式注释,提示文档工具需重新设计。
  • 结果表明,深度学习模型可自动化生成基本注释字段,使开发人员能专注于高层次解释。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。