LAMNER: Code Comment Generation Using Character Language Model and Named Entity Recognition

04/05/2022
by   Rishab Sharma, et al.
0

Code comment generation is the task of generating a high-level natural language description for a given code method or function. Although researchers have been studying multiple ways to generate code comments automatically, previous work mainly considers representing a code token in its entirety semantics form only (e.g., a language model is used to learn the semantics of a code token), and additional code properties such as the tree structure of a code are included as an auxiliary input to the model. There are two limitations: 1) Learning the code token in its entirety form may not be able to capture information succinctly in source code, and 2) The code token does not contain additional syntactic information, inherently important in programming languages. In this paper, we present LAnguage Model and Named Entity Recognition (LAMNER), a code comment generator capable of encoding code constructs effectively and capturing the structural property of a code token. A character-level language model is used to learn the semantic representation to encode a code token. For the structural property of a token, a Named Entity Recognition model is trained to learn the different types of code tokens. These representations are then fed into an encoder-decoder architecture to generate code comments. We evaluate the generated comments from LAMNER and other baselines on a popular Java dataset with four commonly used metrics. Our results show that LAMNER is effective and improves over the best baseline model in BLEU-1, BLEU-2, BLEU-3, BLEU-4, ROUGE-L, METEOR, and CIDEr by 14.34 18.98 we fused LAMNER's code representation with the baseline models, and the fused models consistently showed improvement over the non-fused models. The human evaluation further shows that LAMNER produces high-quality code comments.

READ FULL TEXT
research
05/04/2020

Code and Named Entity Recognition in StackOverflow

There is an increasing interest in studying natural language and compute...
research
05/30/2018

Bilingual Character Representation for Efficiently Addressing Out-of-Vocabulary Words in Code-Switching Named Entity Recognition

We propose an LSTM-based model with hierarchical architecture on named e...
research
09/13/2018

On the Strength of Character Language Models for Multilingual Named Entity Recognition

Character-level patterns have been widely used as features in English Na...
research
10/03/2020

Code to Comment "Translation": Data, Metrics, Baselining Evaluation

The relationship of comments to code, and in particular, the task of gen...
research
10/24/2020

Unsupervised Paraphrase Generation via Dynamic Blocking

We propose Dynamic Blocking, a decoding algorithm which enables large-sc...
research
12/05/2019

Design and implementation of an open source Greek POS Tagger and Entity Recognizer using spaCy

This paper proposes a machine learning approach to part-of-speech taggin...
research
03/03/2023

APIContext2Com: Code Comment Generation by Incorporating Pre-Defined API Documentation

Code comments are significantly helpful in comprehending software progra...

Please sign up or login with your details

Forgot password? Click here to reset