Descriptive code comments are essential for supporting code comprehension and maintenance. We propose the task of automatically generating comments for overriding methods. We formulate a novel framework which accommodates the unique contextual and linguistic reasoning that is required for performing this task. Our approach features: (1) incorporating context from the class hierarchy; (2) conditioning on learned, latent representations of specificity to generate comments that capture the more specialized behavior of the overriding method; and (3) unlikelihood training to discourage predictions which do not conform to invariant characteristics of the comment corresponding to the overridden method. Our experiments show that the proposed approach is able to generate comments for overriding methods of higher quality compared to prevailing comment generation techniques.
翻译:描述性代码评论对于支持代码理解和维护至关重要。我们提议自动为压倒一切的方法生成评论的任务。我们制定了一个新框架,其中考虑到执行这项任务所需的独特的背景和语言推理。我们的方法特征有:(1) 将等级等级制度的背景纳入其中;(2) 以学习的、潜在的具体表现为条件,提出反映压倒一切方法更专业行为的评论;(3) 进行不同寻常的培训,以阻止与压倒一切的方法相对应的评论的不变特性不相符的预测。我们的实验表明,拟议的方法能够产生与普遍评论生成技术相比,质量高于一切的方法的意见。