GGlyphMetrum
Workflows

Coding workflows · Levenshtein edit distance

03
Built around your work

A concrete starting point

Measure Levenshtein distance by Unicode code point without normalizing the strings. Check empty input, one emoji substitution and composed versus decomposed text, counting the original sequences rather than claiming visual-character equivalence.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Levenshtein edit distance

A concrete starting point
def edit_distance(a, b):
    if not isinstance(a, str) or not isinstance(b, str):
        raise ValueError("text.required")
    previous = list(range(len(b) + 1))
    for i, left in enumerate(a, 1):
        current = [i]
        for j, right in enumerate(b, 1):
            current.append(min(current[-1] + 1, previous[j] + 1,
                               previous[j - 1] + (left != right)))
        previous = current
    return previous[-1]

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗