Abstract

With the development of deep learning, many approaches based on neural networks are proposed for code clone. In this paper, we propose a novel source code detection model At-biLSTM based on a bidirectional LSTM network with a self-attention layer. At-biLSTM is composed of a representation model and a discriminative model. The representation model firstly transforms the source code into an abstract syntactic tree and splits it into a sequence of statement trees; then, it encodes each of the statement trees with a deep-first traversal algorithm. Finally, the representation model encodes the sequence of statement vectors via a bidirectional LSTM network, which is a classical deep learning framework, with a self-attention layer and outputs a vector representing the given source code. The discriminative model identifies the code clone depending on the vectors generated by the presentation model. Our proposed model retains both the syntactics and semantics of the source code in the process of encoding, and the self-attention algorithm makes the classifier concentrate on the effect of key statements and improves the classification performance. The contrast experiments on the benchmarks OJClone and BigCloneBench indicate that At-LSTM is effective and outperforms the state-of-art approaches in source code clone detection.

Highlights

  • In modern society, the application of computers and software has already pervasively permeated our lives. e necessities of life such as medical care, resources, communication, and public security depend on the running of the software of high quality

  • ASTNN adopts the strategy of subtree decomposition and recursive encoding, combined with a bidirectional LSTM to leverage the naturalness of statements. e representation model of ASTNN reduces the depth of syntax trees and employs the natural sequence of statements in the code

  • We have presented a novel source code clone detection model At-Bidirectional LSTM (BiLSTM) based on deep learning with self-attention mechanism, which successfully captures both the syntactic and semantic information of the code in the process of encoding

Read more

Summary

Introduction

The application of computers and software has already pervasively permeated our lives. e necessities of life such as medical care, resources, communication, and public security depend on the running of the software of high quality. Scholars [7, 8] try to represent the source code with other techniques such as the latent semantic index [9] and hash mapping [10], in order to improve the detection efficiency of the model. These representation approaches are based on NLP methods, which mean only simple clone pairs, i.e., type 1 and type 2 clones, are detectable. We propose a source code clone detection model At-BiLSTM using bidirectional LSTM with self-attention mechanism, which retains both the syntactics and semantics of code in the process of representation.

Related Work
Preliminaries
Our Proposed Approach
Method Declaration
Experiments
Findings
Discussion
Conclusion

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.