Abstract
Code comments are critical for maintaining and comprehending software programs, but they are often missing, mismatched, or outdated in practice. Code comment generation task aims to automatically produce descriptive comments for code snippets. Recently, methods based on the neural encoder-decoder architecture have achieved impressive performance. These methods assume that all the information required to generate comments is encoded in the target function itself, yet in most realistic situations, it is hard to understand a function in isolation from the surrounding context. Furthermore, the global context may contain redundant information that should not be introduced. To address the above issues, we present a novel graph-based learning framework to capture various relations among functions in a class file. Our approach is based on a common real-world scenario in which only a few functions in the source file have human-written comments. Guided by intra-class function relations, our model incorporates contextual information extracted from both the source code and available comments to generate missing comments. We conduct experiments on a Java dataset collected from real-world projects. Experimental results show that the proposed method outperforms competitive baseline models on all automatic and human evaluation metrics.- Anthology ID:
- 2023.findings-eacl.97
- Volume:
- Findings of the Association for Computational Linguistics: EACL 2023
- Month:
- May
- Year:
- 2023
- Address:
- Dubrovnik, Croatia
- Editors:
- Andreas Vlachos, Isabelle Augenstein
- Venue:
- Findings
- SIG:
- Publisher:
- Association for Computational Linguistics
- Note:
- Pages:
- 1321–1333
- Language:
- URL:
- https://aclanthology.org/2023.findings-eacl.97
- DOI:
- 10.18653/v1/2023.findings-eacl.97
- Cite (ACL):
- Zhenni Wang, Xiaohan Yu, Yansong Feng, and Dongyan Zhao. 2023. An Intra-Class Relation Guided Approach for Code Comment Generation. In Findings of the Association for Computational Linguistics: EACL 2023, pages 1321–1333, Dubrovnik, Croatia. Association for Computational Linguistics.
- Cite (Informal):
- An Intra-Class Relation Guided Approach for Code Comment Generation (Wang et al., Findings 2023)
- PDF:
- https://preview.aclanthology.org/landing_page/2023.findings-eacl.97.pdf