Contrastive learning based cross-language code clone detection

Lyu Quanrun
Xie Chunli
Wan Zexuan
Wei Jiajin
School of computer science & technology, Jiangsu Normal University, Xuzhou Jiangsu 221116, China

Abstract

Code clone detection is an important technology to improve software development efficiency, quality, and reliability. Single-language clone detection based on an abstract syntax tree (AST) has achieved significant performance. However, the existence of synonyms and near-synonyms in AST nodes of cross-language codes and the high cost of manual labeling limit the effectiveness and usefulness of existing clone detection methods. To address these issues, it propose a cross-language code clone detection method based on contrastive tree convolutional neural network (CTCNN) . Firstly, the codes of different programming languages are parsed into ASTs, and the node types and values of ASTs are processed by synonym conversion to reduce the differences between ASTs in different programming languages. At the same time, it employ contrastive learning to augment negative samples and train the model, so that this approach ensures the minimization of distances between clone pairs and the maximization of distances between non-clone pairs in small sample datasets. Finally, it evaluate the proposed method on a public dataset with precision, recall, and F1 scores of 95.6%, 99.98%, and 97.56%. The results show that compared to the best existing methods CLCDSA and C4, the proposed model improves the detection accuracy by 43.92% and 3.73%, and increases the F1 score by 29.84% and 6.29%. the validation confirms that the proposed model is an effective cross-language code clone detection method.

Foundation Support

国家自然科学基金面上基金项目(62276119)
江苏师范大学研究生科研与实践创新计划资助项目(2022XKT1538)

Publish Information

DOI: 10.19734/j.issn.1001-3695.2023.11.0534
Publish at: Application Research of Computers Accepted Paper, Vol. 41, 2024 No. 7

Publish History

[2024-01-22] Accepted Paper

Cite This Article

吕泉润, 谢春丽, 万泽轩, 等. 基于对比学习的跨语言代码克隆检测方法 [J]. 计算机应用研究, 2024, 41 (7). (2024-04-10). https://doi.org/10.19734/j.issn.1001-3695.2023.11.0534. (Lyu Quanrun, Xie Chunli, Wan Zexuan, et al. Contrastive learning based cross-language code clone detection [J]. Application Research of Computers, 2024, 41 (7). (2024-04-10). https://doi.org/10.19734/j.issn.1001-3695.2023.11.0534. )

About the Journal

  • Application Research of Computers Monthly Journal
  • Journal ID ISSN 1001-3695
    CN  51-1196/TP

Application Research of Computers, founded in 1984, is an academic journal of computing technology sponsored by Sichuan Institute of Computer Sciences under the Science and Technology Department of Sichuan Province.

Aiming at the urgently needed cutting-edge technology in this discipline, Application Research of Computers reflects the mainstream technology, hot technology and the latest development trend of computer application research at home and abroad in a timely manner. The main contents of the journal include high-level academic papers in this discipline, the latest scientific research results and major application results. The contents of the columns involve new theories of computer discipline, basic computer theory, algorithm theory research, algorithm design and analysis, blockchain technology, system software and software engineering technology, pattern recognition and artificial intelligence, architecture, advanced computing, parallel processing, database technology, computer network and communication technology, information security technology, computer image graphics and its latest hot application technology.

Application Research of Computers has many high-level readers and authors, and its readers are mainly senior and middle-level researchers and engineers engaged in the field of computer science, as well as teachers and students majoring in computer science and related majors in colleges and universities. Over the years, the total citation frequency and Web download rate of Application Research of Computers have been ranked among the top of similar academic journals in this discipline, and the academic papers published are highly popular among the readers for their novelty, academics, foresight, orientation and practicality.


Indexed & Evaluation

  • The Second National Periodical Award 100 Key Journals
  • Double Effect Journal of China Journal Formation
  • the Core Journal of China (Peking University 2023 Edition)
  • the Core Journal for Science
  • Chinese Science Citation Database (CSCD) Source Journals
  • RCCSE Chinese Core Academic Journals
  • Journal of China Computer Federation
  • 2020-2022 The World Journal Clout Index (WJCI) Report of Scientific and Technological Periodicals
  • Full-text Source Journal of China Science and Technology Periodicals Database
  • Source Journal of China Academic Journals Comprehensive Evaluation Database
  • Source Journals of China Academic Journals (CD-ROM Version), China Journal Network
  • 2017-2019 China Outstanding Academic Journals with International Influence (Natural Science and Engineering Technology)
  • Source Journal of Top Academic Papers (F5000) Program of China's Excellent Science and Technology Journals
  • Source Journal of China Engineering Technology Electronic Information Network and Electronic Technology Literature Database
  • Source Journal of British Science Digest (INSPEC)
  • Japan Science and Technology Agency (JST) Source Journal
  • Russian Journal of Abstracts (AJ, VINITI) Source Journals
  • Full-text Journal of EBSCO, USA
  • Cambridge Scientific Abstracts (Natural Sciences) (CSA(NS)) core journals
  • Poland Copernicus Index (IC)
  • Ulrichsweb (USA)