<!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>Semantic Patterns Extraction of Code Smells: Retrieving the Solutions of Bugs</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Tampere</institution>
          ,
          <country country="FI">Finland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The understanding of code smells have exerted profound inuence in the quality and the performance of programming codes. There are various type of code smells require various solutions. In order to interpret the solutions available in code smells, this research uses NLP (natural language programming) techniques to comprehend contents of messages from Technical Debt Dataset. Based on phrase structure rules, semantic patterns were extracted from the Dataset to build connection between trigger words and dependency tree. Verb Phrases are considered as the actions taken by programmers encountering code smells.</p>
      </abstract>
      <kwd-group>
        <kwd>Code smells NLP Phrase structure rules Semantic patterns</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        With the development of software design, the improvement of existing codes
have began to attract more and more attentions nowadays. In the perspective
of technical debt which re ect limited performance and lower e ciency of code,
there is an opportunity for programmers to interpret and update the existing
codes by code smells. In computer programming, codes smells were introduced
by Martin Fowler on improving the design of existing codes [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Codes smells
indicates the current poor designing and quality of codes [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] that may trigger
future labour and nancial costs, such as blob; complex class; function
decomposition; spaghetti code and so on [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. With the emerging of big data, there are
growing numbers of discussions on the domains of code smells available in social
media. There are multiple code smell detection tools, such as SonarQube, PWD,
JSpIRIT which can be used to identify unused variables, empty objection and so
on. Moreover, the di useness of code smells has triggered di erent level of
severity to developers and organizations [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Researches has tended to focus on code
smells themselves, rather than the contents of messages of raised by code smells.
In spite of these early observations, what are the exact contents of messages
attract our research interests. NLP (natural language programming) techniques
are used to analyze large scale dataset collections [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. This present study uses
NLP techniques to decompose the contents of codes smells with follow research
questions: How the messages are composed of users to make commit changes?
What kind of semantic patterns can be extracted from the dataset?
      </p>
    </sec>
    <sec id="sec-2">
      <title>Method</title>
      <p>In this subsection, the method for extracting semantic patterns of the
COMMIT CHANGE messages is discussed. The dynamics of extracting key
perspectives includes focus; technique; domain. Then we describe about the data
collection in the code smells domain.
2.1</p>
      <sec id="sec-2-1">
        <title>Study Design</title>
        <p>
          Regarding code smells, there is a growing tendency of researches to evaluate
the quality of codes. NLP (natural language programming) tools can be used
to extract semantic patterns to identify the content of codes smells. Bird et al.
(2009) suggested the pipeline architecture for an information extraction system
(Fig. 1.) to extract structure data from raw text [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. In the designing of this study,
similar method is applied to extract relationships between various entities.
        </p>
        <p>The messages of COMMIT CHANGES can explore the content of code smells
with in-depth understanding of the fault proneness and valuable responding
strategies. Encountering various code smells, COMMIT CHANGES messages
are used for programmers to communicate towards various problems. In order
to extract the contents of code smells, we use Phrase Structure Rules to extract
semantic patterns as syntactic categories. For example, "You merge the branch
in the trunk", Fig. 2. provides the sorting of reservation to claim the
languagespeci c contexts.</p>
        <p>
          In a certain type of research work, Gupta et al. provided a method for
characterizing into three aspects as Focus, Domain, and Techniques[
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. Similarly, the
above three aspects can be applied in this research with focus on software
engineering and validation, domain is in the perspective of code smells; technical
debts; software quality. Techniques are bugs detection; faults- xing; solutions
providing and so on. Semantic patterns are extracted from dependency tree of
sentences from T the trigger word to (d ) the dependency tree which is the T 's
successor[
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], such as T can be 'update', 'edit', d can be 'bugs', 'fault'.
        </p>
        <p>
          In the attempt to understand how the semantic patterns are composed in
the messages extracted from COMMIT CHANGES, Feature Request Mining
[
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] techniques can be used to extract keywords and phrase structure rules in
the context. Based on the analysis of feature requests in the domains of codes
smells, the sentences can be labelled from keywords to denotes the sentence as a
request [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. For example, "merge the branch in the trunk" is merge &lt;request&gt;
in the trunk. Comparatively to the phrase structure rules, the combination of
"V" + "NP" can suggests the triggered words to direct-object and subject in
the sentence.
In the domain of codes smells, the data is coming from Technical Debt Dataset
which is a curated dataset provides measurement data of 33 Java projects
related information, the dataset is from Apache Software Foundation during the
period of Oct 2000 to Jun 2018 [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. This research analyzed the messages from
COMMIT CHANGES which are about the suggestions and recommendations
concerning a speci c COMMIT, COMMIT CHANGES contains commitHash;
le; projectID; Date; message and so on . COMMITS are the tags that users
generate the comments, COMMIT CHANGES directly connect with COMMITS
which are the users generate solutions for the speci c COMMIT. The message
of COMMIT CHANGES provides the contents of provided of the programmers.
For example: " xed globbing for zookeeper jar"; "changed all to libthrift".
        </p>
        <p>In the initial screening of the dataset, the commitHash tag represent a single
COMMIT object, and the commitHash might be duplicated with the same
messages to the same COMMIT, therefore, the duplicates of messages are removed
based on commitHash. The cleaning process of the dataset provides one unique
messages from each COMMIT object.
2.3</p>
      </sec>
      <sec id="sec-2-2">
        <title>Analysis of the Data</title>
        <p>At beginning, all the raw texts with tags of COMMIT CHANGES are extracted.
After initial screening, the tag of messages are extracted from the raw texts.
After duplicate checking, there are 6307 unique messages. Because the research
interests are in semantic patterns, the number, stopword, punctuation, plain
text, white space are removed before tokenization. Each tokens are labelled by
postagged methods to categorize into present tense verb (VBP), noun (NN),
preposition (PRP), coordinating conjunction (CC), adjective (JJ) and son on.
In order to extract most frequent used verbs, base (VB), 3rd singular present
(VBZ), past participle (VBN), gerund (VBG), simple past (VBD) categories are
collected to build the keywords for expressing feature requests.</p>
        <p>In the next stage, the tag of Verb Phrase (VP in Fig. 2.) was extracted from
the sentence, from T trigger word to d which is the dependency connecting with
the trigger words, such as direct-object or subject. In feature request mining, it
is the &lt;request&gt; or &lt;existing feature&gt;'s contents which represent the phrase
structure rules. Such as, "use generic method for emptyMap instead of
EMPTYMAP constant" can be clari ed into: use &lt;request&gt; instead of &lt;existing
feature&gt;.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Results and Findings</title>
      <p>This section is to report the results and ndings of the methodologies applied
in study design. The rst subsection illustrates verbs as keywords to express
feature requests. The second subsection indicates how the phrase structure rules
applied to extract &lt;request&gt; and &lt;existing feature&gt; from the sentences.
3.1</p>
      <sec id="sec-3-1">
        <title>Verbs as Keywords</title>
        <p>
          In order to extract the lexical categories of verbs, the NLTK python packages
were used to classify words into POS-tagging which tags words automatically
[
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. All types of verbs formats were extracted from the sentences. In Table 2.
there are the most frequent used verbs extracted. A threshold boundary was set
with verbs &gt;5, verbs less or equal than 5 are not considered in current stage.
The threshold boundary can be modi ed based on the simple size.
3.2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Phrase Structure Rules Extraction</title>
        <p>There are various constituent parts to form phrase structure rules. In this
research, Verb Phrase (VP in Fig.2.) gives an internal structure of semantic
patterns. A verbal phrase might consist V, NP, PP. In order to built the dependency
remov, make, get, build, exist, failur, depend, refer, tri, expect, nd, origin, resourc,
exclud, take, tracer, expand, know, occur, transit, accumuloconfdir, appear,
gitignor, walk, detect, intend, think, span, fri, seem, lenam, mdrobclouderacom,
suspend, favor, protect, remain, restor, deepcopi, sensit, accumuloenvsh, save, collect,
hold, hope, startsh, accumuloinputformat, david, defend, prefer, referenc
graph which is the Verb Phrase for semantic patterns, we use below Bi-gram
formula to test the combinations of verb plus &lt;request&gt; or &lt;existing feature&gt; to
form the connection between T trigger word to d direct-object or subject.
Bigram uses the co-occurrence of two words, to divide the probability of the rst
words. P() represents the conditional probability of the token and next one:
W k; Wk 1:
Bi-gram formula for probability on two adjacent elements on tokens.</p>
        <p>P (Wk 1jWk) =</p>
        <p>P (Wk 1; Wk)</p>
        <p>P (Wk 1)
(1)</p>
        <p>After the calculation of Bi-gram, the semantic patterns were extracted based
on the Table 2.'s verbs collection. For example, in Table 3. it is the "remove" verb
based patterns extracted from the dataset. It can be seen clearly that "remove
stray" takes 68.18 in Bi-gram result, and "remove references" takes 46.49. Based
on the phrase structure rules, irrelevant semantic patterns were removed such as
"remove the" and so on.
In order to improve the quality and performance of codes, this research uses
NLP techniques to interpret contents of messages in Technical Debt Dataset.
Phrase structure rules are applied to extract semantic patterns from the dataset
to understand techniques and methods used in the domain of codes smells. This
research sheds the lights on addressing the contents of code smells by feature
request mining. Moreover, this research can help programmers to understand the
contents of code smells and what actions can be taken to improve the quality of
codes.
4.1</p>
      </sec>
      <sec id="sec-3-3">
        <title>Limitations and Future Studies</title>
        <p>The semantic pattern extraction is based on the phrase structure rules, with
various phrase structure rules, the interpretation of the results may vary a lot. This
study apples the typical of V + NP, other rules can also be applied, such as NP
= Det (determiner) + N (noun) and so on. Deeply, based on the domain of code
smells, speci c trigger words and dependency tree can be collected to understand
the contents of messages. In the current stage, Bi-gram method is used to extract
the patterns on two tokens. The future can utilize Tri-gram to interpret 3 tokens
patterns. And the multi-word expressions can also be taken into consideration,
such as "scrip command" can be interpreted as one word, similarly as "new
york" is understand as one city location not "new" and "york". Furthermore, it
is possible to utilize RNN (Recurrent Neural Networks) techniques to provide
additional advantage of gathering all pre-order vocabulary into consideration for
semantic patterns extraction. And also the applying of LSTM (Long Short-Term
Memory) method can provide semantic parsing for the task of mapping contents
of messages in the domain of code smells.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Flower</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Refactoring</surname>
          </string-name>
          .
          <article-title>Improving the Design of Existing Code</article-title>
          . Addison-Wesley,
          <article-title>(</article-title>
          <year>1999</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Vidal</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vazquez</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Diaz-Pace</surname>
            ,
            <given-names>J. A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marcos</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garcia</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Oizumi</surname>
          </string-name>
          , W.:
          <article-title>JSpIRIT: a exible tool for the analysis of code smells</article-title>
          ,
          <source>34th International Conference of the Chilean Computer Science Society (SCCC)</source>
          , Santiago, pp.
          <fpage>1</fpage>
          -
          <lpage>6</lpage>
          (
          <year>2015</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Fontana</surname>
            ,
            <given-names>F. A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lenarduzzi</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roveda</surname>
            ,
            <given-names>R</given-names>
          </string-name>
          and Taibi D.:
          <article-title>Are Architectural Smells Independent from Code Smells? An Empirical Study</article-title>
          .
          <source>Journal of Systems and Software. 154.10</source>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. Sarimaki, N.,
          <string-name>
            <surname>Lenarduzzi</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Taibi</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>On the Di useness of Code Technical Debt in Java Projects of the Apache Ecosystem</article-title>
          . Proceeding of International Conference on TechnicalDebt (TechDebt
          <year>2019</year>
          ), Montreal, Canada, (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Manning</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Surdeanu</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bauer</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Finkel</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bethard</surname>
            ,
            <given-names>S</given-names>
          </string-name>
          and
          <string-name>
            <surname>McClosky D.: The Standford CoreNLP Natural Language Processing Toolkit</surname>
          </string-name>
          .
          <source>Proceedings of 52nd Annual Meeting of the Association for Computational Linguistics: System Demonstrations</source>
          ,Baltimore, Maryland. pp.
          <fpage>55</fpage>
          -
          <lpage>60</lpage>
          . (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Bird</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Klein</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Loper</surname>
          </string-name>
          . E.:
          <article-title>Natural Language Processing with Python 1st edn.</article-title>
          <string-name>
            <surname>O'Reilly Media</surname>
          </string-name>
          , Inc, (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Gupta</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Manning</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Analyzing the Dynamics of Research by Extracting Key Aspects of Scienti c Papers</article-title>
          ,
          <source>Proceedings of 5th International Joint Conference on Natural Language Processing</source>
          , pp.
          <volume>1</volume>
          {
          <issue>9</issue>
          .
          <source>Asian Federation of Natural Language Processing</source>
          , (
          <year>2011</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Iacob</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Harrison</surname>
          </string-name>
          , R.:
          <article-title>Retrieving and Analyzing Mobile Apps Feature Requests from Online Reviews</article-title>
          .
          <source>MSR</source>
          <year>2013</year>
          , San Francisco, CA, USA. pp.
          <volume>41</volume>
          {
          <fpage>44</fpage>
          , (
          <year>2013</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Lenarduzzi</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          , Sarimaki, N., and
          <string-name>
            <surname>Taibi</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>The Technical Debt Dataset</article-title>
          .
          <source>Proceedings of the 15th International Conference on Predictive Models and Data Analytics in Software Engineering (PROMISE19)</source>
          , Recife, Brazil, (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>