Generating Comments from Source Code

Matskevich, Sergey, Gordon, Colin S.

ACM Workshop on Natural Language for Software Engineering (NL4SE), November 2018, doi: 10.1145/3283812.3283822

Abstract

Good comments help developers understand software faster and provide better maintenance. However, comments are often missing, generally inaccurate, or out of date. Many of these problems can be avoided by automatic comment generation. This paper presents a method to generate informative comments directly from the source code using general-purpose techniques from natural language processing. We generate comments using an existing natural language model that couples words with their individual logical meaning and grammar rules, allowing comment generation to proceed by search from declarative descriptions of program text. We evaluate our algorithm on several classic algorithms implemented in Python.

Bibtex

@inproceedings{nl4se18,
  abbr = {NL4SE},
  bibtex_show = {true},
  title = {{Generating Comments from Source Code}},
  author = {Matskevich, Sergey and Gordon, Colin S.},
  booktitle = {ACM Workshop on Natural Language for Software Engineering (NL4SE)},
  doi = {10.1145/3283812.3283822},
  year = 2018,
  month = {November},
  address = {{Lake Buena Vista, FL, USA}},
  acm = {https://dl.acm.org/citation.cfm?doid=3283812.3283822},
  arxiv = {1810.06599},
  pdf = {papers/nl4se18.pdf},
  abstract = {
  Good comments help developers understand software faster and provide better
maintenance. However, comments are often missing, generally inaccurate, or out
of date. Many of these problems can be avoided by automatic comment generation.
This paper presents a method to generate informative comments directly from the
source code using general-purpose techniques from natural language processing.
We generate comments using an existing natural language model that couples
words with their individual logical meaning and grammar rules, allowing comment
generation to proceed by search from declarative descriptions of program text.
We evaluate our algorithm on several classic algorithms implemented in Python.
  }
}