or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/python-levenshtein@0.27.x
tile.json

tessl/pypi-python-levenshtein

tessl install tessl/pypi-python-levenshtein@0.27.0

Python compatibility wrapper for computing string edit distances and similarities using fast Levenshtein algorithms.

Agent Success

Agent success rate when using this tile

88%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.38x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-4/

String Transformation System

Overview

Build a string transformation system that can record, apply, and reverse text editing operations. The system should track changes made to strings and allow replaying or undoing those changes.

Requirements

Core Functionality

  1. Transform Tracker: Create a class TransformTracker that records how to transform one string into another.

    • Initialize with source and target strings
    • Store the transformation internally
    • Provide a method to get the number of operations needed
  2. Apply Transformation: Implement a method apply_transformation(source_text) that:

    • Takes a source string as input
    • Applies the recorded transformation
    • Returns the transformed string
  3. Reverse Transformation: Implement a method get_reverse_tracker() that:

    • Returns a new TransformTracker object
    • This new tracker performs the inverse transformation
    • When applied, it should reverse the original transformation
  4. Transformation Details: Implement a method get_operation_count() that:

    • Returns the number of edit operations in the transformation

Dependencies { .dependencies }

Levenshtein { .dependency }

Provides fast string edit distance and transformation operations.

Test Cases

Test 1: Basic Transformation @test

# test_transform.py
from transform import TransformTracker

def test_basic_transformation():
    tracker = TransformTracker("hello", "hallo")
    result = tracker.apply_transformation("hello")
    assert result == "hallo"
    assert tracker.get_operation_count() == 1

Test 2: Reverse Transformation @test

# test_transform.py
def test_reverse_transformation():
    tracker = TransformTracker("cat", "dog")
    reverse = tracker.get_reverse_tracker()

    # Apply forward then reverse
    forward_result = tracker.apply_transformation("cat")
    assert forward_result == "dog"

    reverse_result = reverse.apply_transformation("dog")
    assert reverse_result == "cat"

Test 3: Complex Transformation @test

# test_transform.py
def test_complex_transformation():
    tracker = TransformTracker("kitten", "sitting")
    result = tracker.apply_transformation("kitten")
    assert result == "sitting"
    assert tracker.get_operation_count() > 1

Implementation Notes

  • The system should handle any string transformations, not just the specific examples
  • Focus on correctness and simplicity
  • Store transformations efficiently for reuse