Skip to content

Allow to set addition, replacement and deletion costs by function parameters #16

@Darker

Description

@Darker

Currently, the algorithm sets the same cost for addition, removal and replacement:

            current[ m_idx ] = Math.min
              ( previous[ m_idx ]     + 1   // Deletion
              , current[  m_idx - 1 ] + 1   // Insertion
              , previous[ m_idx - 1 ] + 1   // Subtraction
              )

But in my case, I'd like to make deletions and subtractions more expensive than insertions. General solution would be to have function that takes 3 more parameters:

function Levenshtein(string_1, string_2, deletion_cost, insertion_cost, subtraction_cost) {...}

Does this make any sense? If it does, would my commit that adds this feature be accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions