<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Automatic comment usefulness judgement via SVM and ANN using contextual token representations</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Yogesh Kumar Sahu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ayan Das</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science and Engineering Indian Institute of Technology Dhanbad</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2022</year>
      </pub-date>
      <fpage>9</fpage>
      <lpage>13</lpage>
      <abstract>
        <p>This paper describes the system submitted by the team from IIT(ISM) Dhanbad in IRSE shared task on automatic judgement of the usefulness of a comment towards an associated source code at FIRE 2022. We have developed a framework where we train a machine learning based model using the neural contextual representations of the comments and corresponding codes to predict whether the comment is relevant to the associated code. In the oficial evaluation, our system achieves the best F1-score of 0.88 on the test data.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Comment-code relevance</kwd>
        <kwd>Support vector machine</kwd>
        <kwd>ELMO</kwd>
        <kwd>Artificial neural network</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>For solving any maintenance task, developers spend most of the allocated time reading and
understanding the source code before performing any modifications or enhancements. This
process is tedious and worsens in the case of unreadable code. The developers often prefer it
instead of consulting documents and trackers that are often inconsistent. Reading the comments
along with the associated source code can significantly help to apprehend the design of the
code and eventually locate the relevant dependencies. The characteristics of comments can be
noisy, inconsistent, and sometimes not even be relevant to the source code.</p>
      <sec id="sec-1-1">
        <title>Comment</title>
      </sec>
      <sec id="sec-1-2">
        <title>Surrounding code context</title>
        <p>-5. if (png_ptr != NULL)
/*Free all memory used in
the read struct*/
-10. #ifdef PNG_READ_iTXt_SUP</p>
      </sec>
      <sec id="sec-1-3">
        <title>PORTED</title>
      </sec>
      <sec id="sec-1-4">
        <title>Label</title>
      </sec>
      <sec id="sec-1-5">
        <title>Not Useful</title>
      </sec>
      <sec id="sec-1-6">
        <title>Useful</title>
      </sec>
      <sec id="sec-1-7">
        <title>Explanation</title>
      </sec>
      <sec id="sec-1-8">
        <title>The code does not read</title>
        <p>int,hence the comments is</p>
      </sec>
      <sec id="sec-1-9">
        <title>Not Useful</title>
      </sec>
      <sec id="sec-1-10">
        <title>The comment correctly describes the code and hence Useful</title>
        <p>
          However, they are still easier to follow and hence also, one of the most commonly used
documentation approach for software maintenance tasks [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. Comment analysis approaches
have mainly focused on detecting inconsistent comments[
          <xref ref-type="bibr" rid="ref2">2</xref>
          ], but the work is somehow less
done on the quality and relevance of the information contained in a comment[
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. The comment
quality assessment can also help with the do’s and don’ts of writing comments thereby can help
to develop guidelines for the comment quality assessment. Thus, the approaches to evaluate
comments based on whether they increase code comprehensibility for software maintenance
tasks are important.
        </p>
        <p>
          The IRSE shared task of FIRE 2022 focuses on the automatic judgment of the relevance
of comments with respect to the corresponding source codes. The task is to determine the
usefulness of comments in source codes. It is a binary classification task for determining
whether the comment in a given pair of source codes and comment is relevant (useful) to the
corresponding source code. The details of the shared task is available in the overview paper [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
        </p>
        <p>In this paper, we report the description of our system submitted for the task. We have carried
out some experiments where we have trained some Machine Learning algorithms that takes the
representations of a piece of source code and the corresponding comment as input and predict
whether the comment is relevant to the associated source code.</p>
        <p>
          The rest of the paper is organized as follows. In Section 2 we present a review of the related
works reported in the literature. In Section 3 we present a discussion of the data made available
for the shared task. In Section 4 we present a detailed description of the system submitted for
the shared task. In Section 5 we present an analysis of the results of the diferent experiments.
In Section 6 we conclude our work.
2. Related Work
[
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]have performed the lexical matching between the code and comment pair to detect
redundancy of information.
        </p>
        <p>
          [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]have conducted a study to derive the attributes of the various categories of task comments
used by developers working with Java .They have presented a series of keywords (like todo,
ifxme) and their likely structure that are used to write comments related to subtasks, short term
tasks.
        </p>
        <p>
          [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] have manually analysed some comments that was from diferent 3 open source C projects
Linux, FreeBSD, and Open Solaris and are randomly sampled for studying their general
characteristics and categorise them based on memory, lock and like.
        </p>
        <p>
          For automated classification and quality evaluation of code comments of C codebases based
on how they can help to understand existing code [
          <xref ref-type="bibr" rid="ref7 ref8">7, 8</xref>
          ] have proposed comment probe based on
how they can help to understand existing code. Using neural networks, comments are classified
as useful, partially useful, and not useful with precision and recall scores of 86.27% and 86.42%,
respectively.
        </p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>3. Data Description</title>
      <p>The training data made available for the shared task contained 8,047 rows of comment text,
surrounding code snippets, and labels (Useful and Not useful).Out of the 8,047 rows of comment
text and surrounding codes total 3,710 code-comment pair are labelled as Not Useful and 4,337
code-comment pair are labelled as Useful.</p>
      <p>The test data provided to us contained 1,001 rows of comment text, surrounding code snippets,
and labels (Useful and Not useful).Out of the 1,001 rows of comment text and surrounding codes
total 719 code-comment pair are labelled as Not Useful and 282 code-comment pair are labelled
as Useful.</p>
      <sec id="sec-2-1">
        <title>Examples of dataset</title>
        <p>Comment Surrounding code context Label
/*This should be a binary subdi- -10. png_chunk_error(png_ptr, Useful
vision search or a hash for*/ "Missing PLTE before IDAT");
/*Finish a chunk started with -3. png_calculate_crc(png_ptr, Not Useful
png_write_chunk_header().*/ data, length);</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>4. System Description</title>
      <p>In this section, we present the details of our system developed for automatic judgement of
usefulness of a comment for the associated code.
4.1. Data preprocessing
We have preprocessed the data by defining a function for removing the punctuation marks
followed by replacing Not Useful label with 0 and Useful Label with 1. We have extracted out
word sequences for comments as well as for codes and after applying above preprocessing we
have stored code and comment into a separate lists. We have applied the above preprocessing
for both training data as well as for test data.
4.2. Data representation
In the recent NLP systems it is the common practice to represent the data in the form of
distributed representations while training diferent machine learning models. These word
representations essentially are neural representation that also contain the information about
the contextual words.</p>
      <p>We have used ELMO [9] for generating the word representations. The Information Retrieval
in Software Engineering(IRSE) Team have provided us with ELMO code link.</p>
      <p>ELMO is a type of deep contextualized word representation in which the word vectors are
learned functions of the internal states of a deep bidirectional language model (biLM), which is
pre-trained on a large text corpus.</p>
      <p>We have extracted the word embedding separately for comments and surrounding code. For
each comment we obtained the representations by taking the means of contextual representation
to get a resultant sentence embedding of size. For associated code also we followed the same
procedure as in for comments.</p>
      <p>For each pair of comments and surrounding code we derived separate representations for the
code and comment. Finally we concatenated these two representation to generate a resultant
representation for the comment-code pair so obtained.
4.3. System description
We initially trained support vector machine (SVM) model[10] with the linear kernel using the
representation so obtained. We also trained SVM model with the Radial Basis Function (RBF)
kernel using the representation so obtained. We also experimented and trained Artificial Neural
Network[11] using the representation so obtained. The details of the experimental settings are
summarized in table 2.</p>
      <p>Our artificial neural network based model contains two input layers and we used one output
layer. For training the model we have used "Adam optimizer" [12] with a learning rate of 0.0001.
In the training process we have taken a batch size of 32 and 50 epochs.</p>
      <p>We have applied same preprocessing of data and extracted the representation in the same
manner as we did for our training data. We have applied the trained SVM model and Artificial
Neural network based models to classify comment text and surrounding code snippets of test
data as Useful and Non Useful comments. Followed by we have also applied our trained ANN
model to classify comment text and surrounding code snippets of test data as Useful and Non</p>
    </sec>
    <sec id="sec-4">
      <title>5. Result Analysis</title>
      <p>We have applied the trained SVM model(both with linear kernel and RBF kernel) to classify
comment text and surrounding code snippets of test data as Useful and Non Useful comments.
5.1. SVM with Linear Kernel
After applying our trained SVM model with kernel as RBF on test data we achieved an overall
accuracy of 87.7 %. Confusion matrices are as follows:</p>
      <p>Predicted</p>
      <p>Useful Not Useful Total
Actual UNsoetfUulseful 28465 63373 278129</p>
      <p>Total 331 670 1001
Precision,recall,F1 score are as follows:</p>
      <sec id="sec-4-1">
        <title>Results</title>
        <p>Label Precision Recall F1-score
Useful 0.74 0.87 0.80</p>
        <p>Not useful 0.94 0.88 0.91</p>
        <p>When using SVM with linear kernel as our model ,for predicting useful comment-code pair
we achieved Precision ,Recall, F1-score as 0.74,0.87,0.80 respectively whereas for predicting
Non-useful comment-code pair we achieved Precision, Recall and F1-score as 0.94,0.88 and 0.91
respectively.
5.2. SVM with RBF Kernel
5.3. Artificial Neural Network</p>
      </sec>
      <sec id="sec-4-2">
        <title>Results</title>
        <p>Label Precision Recall F1-score
Useful 0.81 0.93 0.86</p>
        <p>Not useful 0.97 0.91 0.94
When using ANN as our model ,for predicting useful comment-code pair we achieved Precision
,Recall and F1-score of 0.81, 0.93 and 0.86 respectively whereas for predicting Non-useful
comment-code pair we achieved Precision ,Recall and F1-score as 0.97, 0.91 and 0.94 respectively.</p>
        <p>As compared to our previous model (SVM with RBF kernel) the precision,recall and F1-score
dropped while using ANN as our Model.</p>
        <p>The accuracy of our best model for this shared task turns out to be 92.4%. Best precision for
predicting useful comments is 0.81 which is given by ANN and SVM with RBF kernel, whereas
precision for predicting Non-useful comments is 0.98 which is given by SVM with RBF kernel.</p>
        <p>Best recall for predicting useful comments is 0.96 which is given by SVM with RBF
kernel,whereas recall for predicting Non-useful comments is 0.91 which is given by SVM with RBF
kernel and ANN.</p>
        <p>Best F1-score for predicting useful comments is 0.88 which is given by SVM with RBF kernel,
whereas recall for predicting Non-useful comments is 0.95 which is given by SVM with RBF
kernel.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>6. Conclusion</title>
      <p>In this work we report our system submitted for participating in the IRSE shared task of FIRE
2022. The shared task is aimed towards development of a system that takes a source code
comment and the associated source code as input and predicts whether the given comment
is useful or not useful for the given source code. We have come up with a machine learning
based system that takes the representations of the source code and corresponding comment
derived from the distributed contextual representations of the constituent words as input and
predicts the usefulness of the comment. To this end, we have trained support vector machine
with diferent kernels and artificial neural network. Our best performing system achieved an
best F1-score at 0.88.
[9] M. E. Peters, M. Neumann, M. Iyyer, M. Gardner, C. Clark, K. Lee, L. Zettlemoyer, Deep
contextualized word representations (2018) 2227–2237. URL: https://aclanthology.org/
N18-1202. doi:10.18653/v1/N18-1202.
[10] C. Cortes, V. Vapnik, Support-vector networks, Machine learning 20 (1995) 273–297.
[11] W. S. McCulloch, W. Pitts, A logical calculus of the ideas immanent in nervous activity,</p>
      <p>The bulletin of mathematical biophysics 5 (1943) 115–133.
[12] D. P. Kingma, J. Ba, Adam: A method for stochastic optimization (2014). URL: https:
//arxiv.org/abs/1412.6980. doi:10.48550/ARXIV.1412.6980.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>S.</given-names>
            <surname>C. B. de Souza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Anquetil</surname>
          </string-name>
          ,
          <string-name>
            <surname>K. M. de Oliveira</surname>
          </string-name>
          ,
          <article-title>A study of the documentation essential to software maintenance (</article-title>
          <year>2005</year>
          )
          <fpage>68</fpage>
          -
          <lpage>75</lpage>
          . URL: https://doi.org/10.1145/1085313.1085331. doi:
          <volume>10</volume>
          . 1145/1085313.1085331.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Tan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Yuan</surname>
          </string-name>
          , G. Krishna,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhou</surname>
          </string-name>
          , /*icomment: Bugs or bad comments?*/, SIGOPS Oper.
          <source>Syst. Rev</source>
          .
          <volume>41</volume>
          (
          <year>2007</year>
          )
          <fpage>145</fpage>
          -
          <lpage>158</lpage>
          . URL: https://doi.org/10.1145/1323293.1294276. doi:
          <volume>10</volume>
          . 1145/1323293.1294276.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>I. K.</given-names>
            <surname>Ratol</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. P.</given-names>
            <surname>Robillard</surname>
          </string-name>
          , Detecting fragile comments (
          <year>2017</year>
          )
          <fpage>112</fpage>
          -
          <lpage>122</lpage>
          . doi:
          <volume>10</volume>
          .1109/ASE.
          <year>2017</year>
          .
          <volume>8115624</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S.</given-names>
            <surname>Majumdar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bandyopadhyay</surname>
          </string-name>
          ,
          <string-name>
            <surname>P. P. Das</surname>
          </string-name>
          ,
          <string-name>
            <surname>P. D Clough</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Chattopadhyay</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Majumder</surname>
          </string-name>
          ,
          <article-title>Overview of the IRSE track at FIRE 2022: Information Retrieval in Software Engineering, in: Forum for Information Retrieval Evaluation</article-title>
          ,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          ,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A. T. T.</given-names>
            <surname>Ying</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. L.</given-names>
            <surname>Wright</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Abrams</surname>
          </string-name>
          ,
          <article-title>Source code that talks: an exploration of eclipse task comments and their implications to repository mining</article-title>
          ,
          <source>ACM SIGSOFT Software Engineering Notes</source>
          (
          <year>2005</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Padioleau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Tan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <article-title>Listening to programmers taxonomies and characteristics of comments in operating system code (</article-title>
          <year>2009</year>
          )
          <fpage>331</fpage>
          -
          <lpage>341</lpage>
          . URL: https://doi.org/10.1109/ICSE.
          <year>2009</year>
          .
          <volume>5070533</volume>
          . doi:
          <volume>10</volume>
          .1109/ICSE.
          <year>2009</year>
          .
          <volume>5070533</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>S.</given-names>
            <surname>Majumdar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bansal</surname>
          </string-name>
          ,
          <string-name>
            <surname>P. Das</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Clough</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Datta</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Ghosh</surname>
          </string-name>
          ,
          <article-title>Automated evaluation of comments to aid software maintenance</article-title>
          ,
          <source>Journal of Software: Evolution and Process</source>
          <volume>34</volume>
          (
          <year>2022</year>
          ). doi:
          <volume>10</volume>
          .1002/smr.2463.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S.</given-names>
            <surname>Majumdar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Papdeja</surname>
          </string-name>
          ,
          <string-name>
            <surname>P. P. Das</surname>
            ,
            <given-names>S. K.</given-names>
          </string-name>
          <string-name>
            <surname>Ghosh</surname>
          </string-name>
          ,
          <string-name>
            <surname>Comment-Mine-A Semantic</surname>
          </string-name>
          Search Approach to Program
          <source>Comprehension from Code Comments</source>
          , Springer Singapore, Singapore,
          <year>2020</year>
          , pp.
          <fpage>29</fpage>
          -
          <lpage>42</lpage>
          . URL: https://doi.org/10.1007/
          <fpage>978</fpage>
          -981-15-2930-
          <issue>6</issue>
          _3. doi:
          <volume>10</volume>
          .1007/
          <fpage>978</fpage>
          -981-15-2930-
          <issue>6</issue>
          _
          <fpage>3</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>