Code Monkey home page Code Monkey logo

codesim's Introduction

Source Code Clone Detection Using Unsupervised Similarity Measures

This repository contains the source code for reproducing the paper Martinez-Gil, J. (2024). Source Code Clone Detection Using Unsupervised Similarity Measures. In: Bludau, P., Ramler, R., Winkler, D., Bergsmann, J. (eds) Software Quality as a Foundation for Security. SWQD 2024. Lecture Notes in Business Information Processing, vol 505. Springer, Cham. https://doi.org/10.1007/978-3-031-56281-5_2.

arXiv Springer Link

The dataset has been created by Oscar Karnalim: https://github.com/oscarkarnalim/sourcecodeplagiarismdataset

๐ŸŒ Overview

This project implements a collection of established methods for measuring similarity. In this context, the goal is to detect similarity (and subsequently identify code clones) in Java source code using unsupervised similarity measures. It aims to check the most promising unsupervised similarity measures to identify duplicates (a.k.a. clones) in source code efficiently, offering a valuable tool for software maintenance and plagiarism detection.

๐Ÿ“š Reference

If you use this work, please cite:

@InProceedings{10.1007/978-3-031-56281-5_2,
	author="Martinez-Gil, Jorge",
	editor="Bludau, Peter
	and Ramler, Rudolf
	and Winkler, Dietmar
	and Bergsmann, Johannes",
	title="Source Code Clone Detection Using Unsupervised Similarity Measures",
	booktitle="Software Quality as a Foundation for Security",
	year="2024",
	publisher="Springer Nature Switzerland",
	address="Cham",
	pages="21--37",
	isbn="978-3-031-56281-5"
}

๐Ÿ› ๏ธ How it Works

Each script java-sim-*-opt.py processes the Java code snippets from the IR-Plag dataset. There are 21 different methods implemented. Please note that each script tries to find a threshold value for semantic similarity capable of separating clones from non-clones.

๐Ÿ“ˆ Performance Results

Approach Script Accuracy Precision Recall F-Measure Execution Time (ms)
Abstract Syntax Tree java-sim-ast-opt.py 0.77 0.77 0.78 0.78 80907.37
Bag-of-Words java-sim-bow-opt.py 0.77 0.79 0.66 0.72 57444.90
Bag-of-Words II java-sim-bow2-opt.py 0.77 0.77 1.00 0.87 59961.69
CodeBERT java-sim-codebert-opt.py* 0.54 0.75 0.34 0.47 868755.96
Comment Sim. java-sim-comments-opt.py 0.77 0.77 1.00 0.87 983231.42
Output Analysis java-sim-exec-opt.py 0.94 0.85 0.97 0.90 1381335.16
Function Calls java-sim-fcall-opt.py 0.78 0.78 0.91 0.84 30303.88
Fuzzy Matching java-sim-fuzz-opt.py 0.77 0.77 1.00 0.87 12778.62
Graph Matching java-sim-graph-opt.py 0.78 0.80 0.52 0.63 65076.91
Rolling Hash java-sim-hash-opt.py 0.59 0.93 0.18 0.30 959157.60
Perceptual Hash java-sim-image-opt.py 0.77 0.77 0.85 0.81 38152.71
Jaccard java-sim-jaccard-opt.py 0.86 0.81 0.94 0.87 2066.13
Longest Common Subsequence java-sim-lcs-opt.py 0.48 0.74 0.06 0.11 7268.67
Levenshtein java-sim-lev-opt.py 0.77 0.80 0.66 0.72 10280.09
Metrics comparison java-sim-metrics-opt.py 0.77 0.77 1.00 0.87 60508.62
N-Grams java-sim-ngrams-opt.py 0.85 0.84 0.29 0.43 66635.25
Program Dependence Graph java-sim-pdg-opt.py 0.65 0.85 0.39 0.53 40518.80
Rabin-Karp java-sim-rk-opt.py 0.81 0.79 0.99 0.88 225218.76
Semantic Clone java-sim-semclone-opt.py 0.77 0.79 0.68 0.73 41543.53
Semdiff method java-sim-semdiff-opt.py 0.77 0.79 0.38 0.51 26351.06
TDF-IDF java-sim-tdf-opt.py 0.77 0.77 0.99 0.87 68587.17
Winnow java-sim-winn-opt.py 0.86 0.81 0.98 0.88 77160.81
Winnow II java-sim-winn2-opt.py 0.83 0.80 0.94 0.87 104032.99

*CodeBERT is used without recalibration

๐Ÿ“„ License

These scripts are provided under the MIT License.

codesim's People

Contributors

jorge-martinez-gil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

2041085572

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.