Coder Social home page Coder Social logo

tsed's Introduction

Tree Similarity of Edit Distance (TSED) Calculator

Overview

This Python script calculates the Tree Similarity of Edit Distance (TSED) between two trees, utilizing the APTED (A Framework for Tree Edit Distance) library. TSED is commonly employed in tasks such as code review and evaluation, offering a metric for assessing the structural similarity between two tree structures.

Dependencies

  • apted
  • tree_sitter_languages

Usage

  1. Ensure that the necessary dependencies are installed:

    pip install apted tree_sitter_languages
    
  2. Modify the script as needed, providing the language, origin tree, and target tree information.

  3. Use in your code:

    import TSED
    line1 = "Code1"
    line2 = "Code2"
    ts_score=TSED.Calaulte("python",line1, line2, 1.0, 0.8, 1.0)
    

Script Explanation

  • Node: A class representing a node in the tree structure.
  • parse_tree_string(tree_string): Parses the tree string and constructs a tree structure using the Node class.
  • calculate_node_count(node): Calculates the number of nodes in the tree.
  • get_Trees(lan,origin,target): Retrieves trees for the specified language, origin tree, and target tree.
  • Calaulte(lan, str1, str2, d, i, r): Calculates the TSED using the APTED library with custom edit operation configurations.

Parameters

  • lan: Programming language for parsing (e.g., 'python', 'java').
  • str1 and str2: Strings representing the origin and target trees.
  • d, i, r: Custom edit operation weights for delete, insert, and rename.

Output

The script outputs a similarity score between 0 and 1, representing the structural similarity be

tsed's People

Contributors

etamin avatar

Stargazers

 avatar huangPengLong avatar  avatar

Watchers

 avatar

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.