Skip to content

qedsoftware/edit-distance

Repository files navigation

edit-distance

edit-distance is a Python package that provides an implementation of the Optimal String Alignment (OSA) algorithm for calculating edit distances. The package leverages C++ extensions via Cython for improved performance.

Features

  • Calculate edit distances using the OSA algorithm.
  • Enables custom weights for each edit operation.
  • Find all edit paths resulting in the minimal OSA distance between strings.
  • High-performance implementation using C++ and Cython.
  • Easy integration into Python projects.

Installation

Ensure you have a C++ compiler installed. Then, clone the repository and install the package using:

pip install .

Alternatively, call setup.py directly:

python setup.py build_ext --inplace
python setup.py install

For more details on the setup, see setup.py.

Usage

After installation, you can import and use the module in your Python code:

import editdistance.osa

# Example usage:
str1 = "kitten"
str2 = "sitting"
distance = editdistance.osa.calculate_distance(str1, str2, swap_weight=0.1)
print(f"The edit distance between '{{}}' and '{{}}' is {{}}".format(str1, str2, distance))

See examples located in examples directory.

Running Tests

The test suite is located in the tests directory. To run the tests, execute:

python -m unittest discover -v

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •