Skip to main content

A code similarity analyzer using AST analysis.

Project description

DeepCSIM - Code Similarity Analyzer

DeepCSIM is a Python library and tool for analyzing code similarity between Python files using Abstract Syntax Tree (AST) analysis. It can detect structural and semantic similarities.

Installation

pip install deepcsim

Usage

You can use DeepCSIM in three ways: as a command-line tool, as a local web server, or as a Python library.

1. CLI Tool

Scan a directory for code duplicates directly from your terminal.

# Scan current directory
deepcsim-cli

# Scan a specific directory
deepcsim-cli /path/to/project

# Set similarity threshold (default: 80.0)
deepcsim-cli /path/to/project --threshold 90

# Output results in JSON format
deepcsim-cli /path/to/project --json

2. Web Server

Start the built-in web interface to view results interactively.

deepcsim-server

Then open http://localhost:8000/ in your browser.

3. Python Library

Use DeepCSIM programmatically in your Python scripts.

from deepcsim import compare_source
from deepcsim.core.analyzer import CodeAnalyzer # Optional, for advanced usage

# --- Example 1: Compare two code snippets (Easy Way) ---

source1 = """
def hello():
    print("Hello world")
"""

source2 = """
def greet():
    print("Hello world")
"""

# Compare directly
report = compare_source(source1, source2)
# The report contains full details, similar to scan_directory output
print(f"Similarity: {report['results'][0]['similarity']}%")

# --- Example 2: Scan a directory ---

results = scan_directory("/path/to/project", threshold=80.0)
print(f"Found {results['count']} similar pairs.")

API

If running the server, you have access to the following endpoints:

  • GET / — Web interface for browsing project files and scanning directories
  • POST /api/file-info/ — Get metadata and similar files for a specific file
  • POST /scan-project — Recursively scan a directory for duplicate/similar files (JSON response)

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

deepcsim-0.1.1.tar.gz (71.1 kB view details)

Uploaded Source

Built Distribution

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

deepcsim-0.1.1-py3-none-any.whl (77.1 kB view details)

Uploaded Python 3

File details

Details for the file deepcsim-0.1.1.tar.gz.

File metadata

  • Download URL: deepcsim-0.1.1.tar.gz
  • Upload date:
  • Size: 71.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for deepcsim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 08b5222e541a084ea63b551a87f963c5d8bb95f52b35493026f4d0375adb3f48
MD5 b4f0a6d74e62a2b823793dcb4ed300de
BLAKE2b-256 da3636d9f37d06134bc7c766bb517ca03b0bf0e2085cf2b4db26522574bb8e02

See more details on using hashes here.

File details

Details for the file deepcsim-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: deepcsim-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 77.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for deepcsim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ddfb67e610967c8b7df7ab8a354dafe7f423f4078b35449bb4ab78b0f10535a
MD5 f9da2e892caf7af8c14b66bbb2e9cfb1
BLAKE2b-256 5aec3f04d39a12e5c481e35e504379c830675f752ca18be53c58f7c32321f2af

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