Skip to main content

Code Similarity (csim) is a method designed to detect similarity between source codes

Project description

Code Similarity (csim)

Code Similarity (csim) provide a module designed to detect similarities between source code files, even when obfuscation techniques have been applied. It is particularly useful for programming instructors and students who need to verify code originality.

Key Features

  • Source Code Similarity Analysis: Compares source code files to determine their degree of similarity.
  • Advanced Analysis: Utilizes parse trees and the tree edit distance algorithm for in-depth analysis.
  • Parse Trees: Represents the syntactic structure of source code, enabling detailed comparisons.
  • Tree Edit Distance: Measures the similarity between different code structures.

Technologies Used

  • Python: The core programming language for the tool.
  • ANTLR: A parser generator for creating parse trees from source code.
  • zss: A library for calculating the tree edit distance.

Installation

  1. Clone the repository:
    git clone https://github.com/EdsonEddy/csim.git
    
  2. Navigate to the project directory:
    cd csim
    
  3. Install the package:
    pip install .
    

Usage

csim can be used from the command line, for now only Python files are supported. In the future more languages will be added. For example, to compare two Python files, run:

csim -f file1.py file2.py

Alternatively, you can use csim as a Python module:

from csim import Compare
code_a = "a = 5"
code_b = "c = 50"
similarity = Compare(code_a, code_b)
print(f"Similarity: {similarity}")

ANTLR4 Instalation and Parser/Lexer Generation

This instalation is not required the files are already included in the project. But if you can review the steps to generate them yourself in the grammars/README.md file.

Contributing

Contributions are welcome! To contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/new-feature).
  3. Make your changes and commit them (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Links

Additional Resources

For more information on the techniques and tools used in this project, refer to the following resources:

Third-Party Licenses

This project utilizes the following third-party libraries:

ANTLR (ANother Tool for Language Recognition)

ANTLR4-parser-for-Python-3.14 by RobEin

zss (Zhang-Shasha)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csim-1.4.0.tar.gz (457.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csim-1.4.0-py3-none-any.whl (94.1 kB view details)

Uploaded Python 3

File details

Details for the file csim-1.4.0.tar.gz.

File metadata

  • Download URL: csim-1.4.0.tar.gz
  • Upload date:
  • Size: 457.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for csim-1.4.0.tar.gz
Algorithm Hash digest
SHA256 02011fbf20aa4ce01bd1e0fc841653caef0015cc25cc72b7a8ce23cd8e8683c3
MD5 d171860e42ba82f358e410d3344a2d2e
BLAKE2b-256 97bfafd5d6b5a2f580817d96aff5a62837e4a0386f1f5cfcdb209af154b9cc96

See more details on using hashes here.

File details

Details for the file csim-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: csim-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 94.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for csim-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24811039dce648cf29fd369431b477f5344c273d7fbd0859d79135d0eff7a9cd
MD5 4f69622d0043f9b11f6eb6f7bcaa8e7c
BLAKE2b-256 7ea9156c804fab17b4735eccd190b8648ee4da49a60449e9e491df1933171c9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page