<!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>A New Dataset for Source Code Comment Coherence</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anna Corazza DIETI</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Univ. di Napoli Federico II anna.corazza@unina.it</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Giuseppe Scanniello Dept. of Mathematics</string-name>
          <email>giuseppe.scanniello@unibas.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Information Technology</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Economics</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Univ. della Basilicata</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Valerio Maggio Fondazione Bruno Kessler</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>English. Source code comments provide useful insights on a codebase and on the intent behind design decisions and goals. Often, the information provided in the comment of a method and in its corresponding implementation may be not coherent with each other (i.e., the comment does not properly describe the implementation). Several could be the motivations for this issue (e.g., comment and source code do not evolve coherently). In this paper, we present the results of a manual assessment on the coherence between comments and implementations of 3; 636 methods, gathered from 4 Java open-source software. The results of this assessment has been collected in a dataset that we made publicly available on the web. We also sketch here the protocol to create this dataset.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Italiano. I commenti al codice
sorgente forniscono informazioni utili
sull’implementazione del codice e sulle
intenzioni relative alle decisioni e agli
scopi del progetto. Spesso, le informazioni
presenti nel commento di un metodo e
nella sua implementazione possono non
essere coerenti (nel senso che il
commento non da` una descrizione adeguata
dell’implementazione). Ci possono
essere diverse spiegazioni per questo (ad
esempio, commenti e codice sorgente non
sono stati modificati in modo coerente). In
questo articolo, presentiamo i risultati di
una valutazione manuale della coerenza
tra commenti e implementazione di 3; 636
metodi, raccolti da 4 applicazioni open
source in Java. I risultati di questa
valutazione sono stati raccolti in un
dataset che abbiamo pubblicato sul web.
Accenniamo anche al protocollo seguito
per la preparazione del dataset.</p>
    </sec>
    <sec id="sec-2">
      <title>1 Introduction</title>
      <p>
        Natural language is used in different ways in the
development process of a software system and
therefore techniques of natural language
processing (NLP) and information retrieval (IR) are more
and more frequently integrated into software
development and maintenance tools. Many
automated or semi-automated techniques have been
proposed to aid developers in the
comprehension and in the evolution of existing systems,
e.g.,
        <xref ref-type="bibr" rid="ref12 ref6">(Corazza et al., 2016; Scanniello et al., 2010)</xref>
        .
      </p>
      <p>
        Natural language information is provided in
source code comments and in the name of
identifiers. In the former case, standard natural language
is usually adopted, although quite technical.
Comments are written in English, even when
developers have different mother-tongues. On the other
hand, identifiers are typically constructed by
composing multiple terms and abbreviations.
Therefore, more sophisticated techniques are necessary
to extract the lexical information contained in each
identifier
        <xref ref-type="bibr" rid="ref4">(Corazza et al., 2012)</xref>
        .
      </p>
      <p>
        Most of these techniques assume that the same
words are used whenever referring to a
particular concept
        <xref ref-type="bibr" rid="ref9">(Lawrie et al., 2010)</xref>
        . In many
cases, this represents an oversimplification:
methods are often modified without updating the
corresponding comments
        <xref ref-type="bibr" rid="ref11">(Salviulo and Scanniello,
2014)</xref>
        . In these cases, comments might convey
information unrelated or inconsistent with the
corresponding implementation. Nevertheless,
comments are extremely important because they are
expected to convey the main intent behind design
decisions, along with some implementation details
(e.g., types of parameters and of returned values).
      </p>
      <p>Therefore, more sophisticated models are
necessary to determine if there is coherence between
the lexicon provided in comments and in its
corresponding source code. Hence, there exists
coherence between a lead comment of a method and its
source code (also simply coherence, from here on)
if that comment describes the intent of the method
and its actual implementation.</p>
      <p>
        In this work, we focus on the lead comment of
methods. This kind of comments precedes the
definition of a given method and is supposed to
provide its documentation and details about the
implementation. We discuss here a dataset we made
publicly available on the web.1 It contains
annotations about the coherence of 3; 636 methods
collected from 4 implementations of 3 open source
projects written in Java. The defined protocol used
for its creation is also sketched, to give researchers
the opportunity to possibly extend it. Further
details on this protocol can be found in
        <xref ref-type="bibr" rid="ref5">(Corazza et
al., 2015)</xref>
        .
      </p>
      <p>
        For the assessment of the quality of the
annotation with special focus on computational
linguistics applications, a few indexes have been
considered
        <xref ref-type="bibr" rid="ref1 ref10 ref7">(Eugenio and Glass, 2004; Artstein and
Poesio, 2008; Mathet et al., 2015)</xref>
        , among which
the kappa index
        <xref ref-type="bibr" rid="ref2">(Cohen, 1960)</xref>
        is the most widely
adopted because of its favorable characteristics.
The inter-annotator agreement has therefore been
assessed by this parameter.
      </p>
      <p>We expect that making freely available this
dataset could give impulse to the research for
approaches to assess the coherence between the
implementation of a method and its lead comment
(simply coherence, from here on). In fact,
although no approach has been yet proposed in this
regard, they could be of great help for software
maintenance and evolution activities.</p>
      <p>The paper is structured as follows. In Section 2,
we discuss the methodology used to create our
dataset. A description of the main characteristics
of the dataset is given in Section 3, while in
Section 4 the annotation is assessed. Some final
considerations conclude the paper.</p>
      <p>1www2.unibas.it/gscanniello/coherence/</p>
    </sec>
    <sec id="sec-3">
      <title>Dataset Construction</title>
      <p>
        To create our dataset, we adopted the
perspectivebased and the checklist-based review
methods
        <xref ref-type="bibr" rid="ref13">(Wohlin et al., 2012)</xref>
        . The perspective is the
one of the Researcher aiming at assessing the
coherence between the lead comment of a method
and its implementation. The process of creation is
based on the following elements:
1. Working Meetings. We used meetings to
determine the goals of our research work and
the process to create the dataset.
2. Dataset Creation. We instantiated the
defined process to create our dataset.
3. Outcomes. We gathered results during and
after the creation of our dataset.
      </p>
    </sec>
    <sec id="sec-4">
      <title>4. Publishing Results and Dataset. We</title>
      <p>
        shared our experience with the community
in
        <xref ref-type="bibr" rid="ref5">(Corazza et al., 2015)</xref>
        and released the
dataset on the web.
      </p>
      <p>The construction of the dataset has been
completed in two main consecutive phases by using an
ad-hoc web system implemented for the purpose:
Verify coherence. Annotators verify by
means of a checklist the coherence between
the lead comments of a set of methods and
their corresponding implementation.</p>
      <p>Resolve conflicts. The intervention of
experts is required whenever the judgements of
the annotators differ. In our case, two of the
authors, with a background in software
engineering, assumed the role of experts and
examined the problematic cases. For each
conflicting method, the experts should reach an
agreement about the coherence or the
noncoherence. Methods on which experts do not
get a consensus are automatically discarded.
3</p>
    </sec>
    <sec id="sec-5">
      <title>Dataset Description</title>
      <p>Some descriptive statistics (e.g., number of classes
and methods) of the software systems in our
dataset are shown in Table 1.</p>
      <p>CoffeeMaker2 is a software to manage
inventory and recipes and to purchase
beverages. We chose this software because it has
2agile.csc.ncsu.edu/SEMaterials/
tutorials/coffee_maker/
a simple and clear design (being it developed
for educational purposes).</p>
      <p>JFreechart3 is a Java tool supporting the
visualization of data charts (e.g., scatter plots
and histograms). We included two versions
of this software. As reported in Table 1,
both these versions contain almost the 80%
of methods with lead comments. This
suggests an extensive use of comments, which is
the main reason why we decided to include
this software in the dataset.</p>
      <p>
        JHotDraw4 is a framework for technical and
structured graphics. Even if the source code
of JHotDraw is scarcely commented (see
Table 1), it is well-known in the software
maintenance community due to its good
ObjectOriented design
        <xref ref-type="bibr" rid="ref12">(Scanniello et al., 2010)</xref>
        .
      </p>
      <p>In Figure 1, we report the
implementation and the lead comment of
setTickLabelsVisible (extracted from
JFreeChart ver. 0.7.1, included in our dataset).
According to our definition of coherence, we
can assert that this method is coherent. On the
other hand, the save method reported in Figure 2
provides a very poor and inadequate
description of the design intent of the method, thus
reflecting a lack of coherence with the underlying
implementation.</p>
      <p>Three annotators were involved in the dataset
creation process. Two of them hold a Bachelor
degree in Computer Science, and have very
similar technical backgrounds. On the other hand,
the third annotator can be considered more
experienced than the other two since he holds a Master
degree in Computer Science. We distributed the
effort among the annotators so that each software
3www.jfree.org/jfreechart/
4www.jhotdraw.org/
/**
* Sets the flag that determines whether or not
* the tick labels are visible.
* Registered listeners are notified of a
* general change to the axis.
*
* @param flag The flag to set.
*/
public void setTickLabelsVisible(boolean flag) {
if (flag!=tickLabelsVisible) {
tickLabelsVisible = flag;
notifyListeners(new AxisChangeEvent(this));}
}
}
would be separately evaluated by at least two
annotators. This allowed us to have multiple
judgements for each method in the dataset, and to
calculate the rate of agreement among annotators.
4</p>
    </sec>
    <sec id="sec-6">
      <title>Annotation Assessment</title>
      <p>The whole dataset creation process occurred from
January, 15th 2014 to June, 20th 2014, for a
total of 800 man-hours. This gives an estimation of
the effort required to conduct the study presented
in this paper, and provides an indication to the
researcher interested in extending our dataset.</p>
      <p>The annotators provided indications on the
coherence of methods by assigning them one
out of three following possible values:
NonCoherent, Don’t Know, and Coherent.</p>
      <p>
        In this scenario, we use the kappa index
        <xref ref-type="bibr" rid="ref2">(Cohen,
1960)</xref>
        to obtain an assessment of the agreement
among annotators, thus estimating the reliability
of their evaluations. In fact, if annotators agree
on a large number of methods, we can conclude
that their annotations are reliable. The kappa index
is designed for categorical judgments and refers
the agreement rate calculation to the rate of chance
agreement:
kappa = po
1
pc
pc
;
po is the observed probability of agreement, while
pc is the chance probability of agreement. Both
probabilities are estimated by the corresponding
frequencies. By a simple algebraic manipulation,
Equation 1 can be written as:
kappa = 1
qo
qc
;
(1)
(2)
where qo = 1 po and qc = 1 pc and
correspond to the observed and the chance
probabilities of disagreement, respectively. Usually the
index assumes values in ]0; 1]5, as it can be expected
that the observed disagreement is less likely than
chance. A null value signals that observed
disagreement is exactly as likely as chance, while the
kappa index assumes negative values in the
unwanted case where disagreement is more likely
than chance. Perfect agreement corresponds to
k = 1. Values greater than 0:80 are usually
considered as a cue of good agreement. Values
in the interval [0:67; 0:80] are considered
acceptable
        <xref ref-type="bibr" rid="ref2">(Cohen, 1960)</xref>
        .
      </p>
      <p>
        The classical formulation of the kappa index
considers a binary classification problem (e.g.,
Non-Coherent or Coherent). However in our case,
the neutral judgement (i.e., Don’t know) is also
allowed. Therefore, possible disagreements
include the case where one of the two answers is
the neutral one. In this case, it is possible to
differently weigh the possible disagreements among
annotators. In fact, disagreements due to the
neutral answers are less serious than disagreements
where judgments are totally divergent (i.e.,
Coherent and Non-Coherent, in our case). To this
end, Cohen
        <xref ref-type="bibr" rid="ref3">(Cohen, 1968)</xref>
        presents a variant of the
kappa index, where in case of a disagreement,
different weights can be applied. In case the same
weight is assigned to all possible disagreement
combinations, the original (unweighted)
formulation is obtained. The formulation of the Weighted
Kappa (WK) is the one in the equation (2), but for
the computation of qo and qc the contributions are
5The notation means that 1 is included in the interval,
while 0 is not.
weighted according to the importance given to the
corresponding disagreement cases. By contrast,
we refer to the original formulation of the kappa
index as Unweighted Kappa (UK). We assign to
the Don’t know response a weight that is half the
weight assigned to the Not-Coherent (or
Coherent) one. This is the same schema reported by
Cohen
        <xref ref-type="bibr" rid="ref3">(Cohen, 1968)</xref>
        . Weighted and Unweighted
kappa indexes are reported in Table 2.
      </p>
      <p>The agreement between annotators is good on
the first three systems, and acceptable for
JHotDraw. However, on this system the difference
between the values for UK and WK is large, thus
providing a more accurate indication on the
agreement of the evaluations on this software.</p>
      <p>At the end of the first step of the dataset
creation process, the number of methods on which
annotators did not agree was 302, corresponding
to the 8:3% of the total number of methods from
all the systems in the dataset. Most of these
methods are those in JHotDraw, as suggested by the
kappa index values (see Table 2). These methods
were reviewed by two of the authors. An
agreement was reached on all of these methods, which
were then included in the dataset. The total
number of methods in the dataset is reported in Table 3
(i.e., 2; 883).
5</p>
    </sec>
    <sec id="sec-7">
      <title>Conclusions and future work</title>
      <p>In this paper, we have presented the early steps
of our research on the coherence between the lead
comment of methods and their implementations.
In particular, we have provided a description of
the problem settings, along with the experimental
protocol defined to create our dataset. We made it
publicly available on the web. We also sketched
the results of quantitative analysis conducted on a
codebase of 3; 636 methods, gathered from 4
different open-source systems written in Java.</p>
      <p>
        There could be many possible future directions
for our research. For example, it would be
interesting to conduct an empirical study to investigate
the effect of maintenance operations on the
coherence for multiple versions of the same system. As
a step forward in this future research direction, we
already included in the dataset two versions of the
JFreeChart system. Our results and those by Fluri
et al.
        <xref ref-type="bibr" rid="ref8">(Fluri et al., 2007)</xref>
        represent a viable
starting point. Finally, we would like to exploit the
collected data as an evaluation set to assess the
performance of approaches able to discern method
coherence.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <given-names>Ron</given-names>
            <surname>Artstein</surname>
          </string-name>
          and
          <string-name>
            <given-names>Massimo</given-names>
            <surname>Poesio</surname>
          </string-name>
          .
          <year>2008</year>
          .
          <article-title>Inter-coder agreement for computational linguistics</article-title>
          .
          <source>Computational Linguistics</source>
          ,
          <volume>34</volume>
          (
          <issue>4</issue>
          ):
          <fpage>555</fpage>
          -
          <lpage>596</lpage>
          , December.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>J.</given-names>
            <surname>Cohen</surname>
          </string-name>
          .
          <year>1960</year>
          .
          <article-title>A coefficient of agreement for nominal scales</article-title>
          .
          <source>Educational and Psychological Measurement</source>
          ,
          <volume>20</volume>
          (
          <issue>1</issue>
          ):
          <fpage>37</fpage>
          -
          <lpage>46</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>J.</given-names>
            <surname>Cohen</surname>
          </string-name>
          .
          <year>1968</year>
          .
          <article-title>Weighted kappa: Nominal scale agreement provision for scaled disagreement or partial credit</article-title>
          .
          <source>Psychological Bulletin.</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <given-names>A.</given-names>
            <surname>Corazza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. Di</given-names>
            <surname>Martino</surname>
          </string-name>
          , and
          <string-name>
            <given-names>V.</given-names>
            <surname>Maggio</surname>
          </string-name>
          .
          <year>2012</year>
          .
          <article-title>LINSEN: An efficient approach to split identifiers and expand abbreviations</article-title>
          .
          <source>In Proceedings of International Conference on Software Maintenance</source>
          , pages
          <fpage>233</fpage>
          -
          <lpage>242</lpage>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <given-names>A.</given-names>
            <surname>Corazza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Maggio</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G.</given-names>
            <surname>Scanniello</surname>
          </string-name>
          .
          <year>2015</year>
          .
          <article-title>On the coherence between comments and implementations in source code</article-title>
          .
          <source>In 41st Euromicro Conference on Software Engineering and Advanced Applications</source>
          , EUROMICRO-SEAA
          <year>2015</year>
          , Madeira, Portugal,
          <source>August 26-28</source>
          ,
          <year>2015</year>
          , pages
          <fpage>76</fpage>
          -
          <lpage>83</lpage>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <given-names>A.</given-names>
            <surname>Corazza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. Di</given-names>
            <surname>Martino</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Maggio</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G.</given-names>
            <surname>Scanniello</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Weighing lexical information for software clustering in the context of architecture recovery</article-title>
          .
          <source>Empirical Software Engineering</source>
          ,
          <volume>21</volume>
          (
          <issue>1</issue>
          ):
          <fpage>72</fpage>
          -
          <lpage>103</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <given-names>Barbara</given-names>
            <surname>Di Eugenio</surname>
          </string-name>
          and
          <string-name>
            <given-names>Michael</given-names>
            <surname>Glass</surname>
          </string-name>
          .
          <year>2004</year>
          .
          <article-title>The Kappa statistic: a second look</article-title>
          .
          <source>Computational Linguistics</source>
          ,
          <volume>30</volume>
          (
          <issue>1</issue>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <given-names>B.</given-names>
            <surname>Fluri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wursch</surname>
          </string-name>
          , and
          <string-name>
            <given-names>H.C.</given-names>
            <surname>Gall</surname>
          </string-name>
          .
          <year>2007</year>
          .
          <article-title>Do code and comments co-evolve? on the relation between source code and comment changes</article-title>
          .
          <source>In Proceedings of the Working Conference on Reverse Engineering</source>
          , pages
          <fpage>70</fpage>
          -
          <lpage>79</lpage>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <given-names>D</given-names>
            <surname>Lawrie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D</given-names>
            <surname>Binkley</surname>
          </string-name>
          , and
          <string-name>
            <given-names>C</given-names>
            <surname>Morrell</surname>
          </string-name>
          .
          <year>2010</year>
          .
          <article-title>Normalizing Source Code Vocabulary</article-title>
          .
          <source>In Proceedings of Working Conference on Reverse Engineering</source>
          , pages
          <fpage>3</fpage>
          -
          <lpage>12</lpage>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <given-names>Yann</given-names>
            <surname>Mathet</surname>
          </string-name>
          , Antoine Widlo¨cher, and
          <string-name>
            <surname>Jean-Philippe Me</surname>
          </string-name>
          ´tivier.
          <year>2015</year>
          .
          <article-title>The unified and holistic method gamma for inter-annotator agreement measure and alignment</article-title>
          .
          <source>Computational Linguistics</source>
          ,
          <volume>41</volume>
          (
          <issue>3</issue>
          ):
          <fpage>437</fpage>
          -
          <lpage>479</lpage>
          , September.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <given-names>F.</given-names>
            <surname>Salviulo</surname>
          </string-name>
          and
          <string-name>
            <given-names>G.</given-names>
            <surname>Scanniello</surname>
          </string-name>
          .
          <year>2014</year>
          .
          <article-title>Dealing with identifiers and comments in source code comprehension and maintenance: Results from an ethnographically-informed study with students and professionals</article-title>
          .
          <source>In Proceedings of International Conference on Evaluation and Assessment in Software Engineering</source>
          , pages
          <fpage>423</fpage>
          -
          <lpage>432</lpage>
          . ACM Press.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <given-names>G.</given-names>
            <surname>Scanniello</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. D'Amico</surname>
          </string-name>
          ,
          <string-name>
            <surname>C. D'Amico</surname>
          </string-name>
          , and
          <string-name>
            <surname>T. D'Amico</surname>
          </string-name>
          .
          <year>2010</year>
          .
          <article-title>Using the kleinberg algorithm and vector space model for software system clustering</article-title>
          .
          <source>In Proceedings of International Conference on Program Comprehension</source>
          , pages
          <fpage>180</fpage>
          -
          <lpage>189</lpage>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <given-names>C.</given-names>
            <surname>Wohlin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Runeson</surname>
          </string-name>
          , M. Ho¨st,
          <string-name>
            <given-names>M.C.</given-names>
            <surname>Ohlsson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Regnell</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <surname>A</surname>
          </string-name>
          . Wessle´n.
          <year>2012</year>
          .
          <article-title>Experimentation in Software Engineering</article-title>
          . Computer Science. Springer.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>