Automatic Generation of Code Comments Based on Comment Reuse and Program Parsing

Yang Bai, Liping Zhang, Sheng Yan · 2019 2nd International Conference on Safety Produce Informatization (IICSPI) · 2019

In order to solve the problem of rare comments and low quality, a method of automatically generating code comments by comment reuse and program parsing is proposed. First, the clone code is detected by Nicad, and the codes and their comments are extracted. Then, through a series of heuristic rules such as dedrying and generalization, the code and the relatively simple code comments are streamlined and optimized. For complex code comments with obvious semantic characteristics, the program parsing method is used to optimize, finally, the comments are mapped to the code to automatically generate comments for the target code. In order to verify the validity of the experiment, the code comments in the 14 target software were manually verified, the comment results were evaluated, and then the five softwares were compared with the previous methods of ours team. The experimental results show that 33.69% of the code comments are good, the generated comments are 14.13% higher than the previous experimental methods, and the quality is improved by about 5%.

Read the paper · More papers on PaperTik