https://github.com/qedsoftware/edit-distance
https://github.com/qedsoftware/edit-distance
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/qedsoftware/edit-distance
- Owner: qedsoftware
- License: mit
- Created: 2025-06-11T09:45:53.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-30T10:17:49.000Z (12 months ago)
- Last Synced: 2025-07-22T10:29:15.735Z (11 months ago)
- Language: C++
- Size: 24.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```sh
pip install .
```
Alternatively, call `setup.py` directly:
```sh
python setup.py build_ext --inplace
python setup.py install
```
For more details on the setup, see [setup.py](setup.py).
## Usage
After installation, you can import and use the module in your Python code:
```python
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](examples/osa_example.py) directory.
## Running Tests
The test suite is located in the [tests](tests/tests_osa.py) directory. To run the tests, execute:
```sh
python -m unittest discover -v
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
```