Code Parameter Summarization Based on Transformer and Fusion Strategy

Fanlong Zhang, Jiancheng Fan, Weiqi Li, Siau‐Cheng Khoo · IET Software · 2024

Context: As more time has been spent on code comprehension activities during software development, automatic code summarization has received much attention in software engineering research, with the goal of enhancing software comprehensibility. In the meantime, it is prevalently known that a good knowledge about the declaration and the use of method parameters can effectively enhance the understanding of the associated methods. A traditional approach used in software development is to declare the types of method parameters. Objective: In this work, we advocate parameter‐level code summarization and propose a novel approach to automatically generate parameter summaries of a given method. Parameter summarization is considerably challenging, as neither do we know the kind of information of the parameters that can be employed for summarization nor do we know the methods for retrieving such information. Method: We present paramTrans, which is a novel approach for parameter summarization. paramTrans characterizes the semantic features from parameter‐related information based on transformer; it also explores three fusion strategies for absorbing the method‐level information to enhance the performance. Moreover, to retrieve parameter‐related information, a parameter slicing algorithm (named paramSlice) is proposed, which slices the parameter‐related node from the abstract syntax tree (AST) at the statement level. Results: We conducted experiments to verify the effectiveness of our approach. Experimental results show that our approach possesses an effective ability in summarizing parameters; such ability can be further enhanced by understanding the available summaries about individual methods, through the introduction of three fusion strategies. Conclusion: We recommend developers employ our approach as well as the fusion strategies to produce parameter summaries to enhance the comprehensibility of code.

Read the paper · More papers on PaperTik