Kaldi alignment methods wrapped into Python
Project description
kaldialign
A small package that exposes edit distance computation functions from Kaldi. It uses the original Kaldi code and wraps it using pybind11.
Installation
pip install --verbose kaldialign
or
pip install --verbose -U git+https://github.com/pzelasko/kaldialign.git
or
git clone https://github.com/pzelasko/kaldialign.git
cd kaldialign
python3 setup.py install --verbose
Examples
align(seq1, seq2, epsilon)
- used to obtain the alignment between two string sequences.epsilon
should be a null symbol (indicating deletion/insertion) that doesn't exist in either sequence.
from kaldialign import align
EPS = '*'
a = ['a', 'b', 'c']
b = ['a', 's', 'x', 'c']
ali = align(a, b, EPS)
assert ali == [('a', 'a'), (b, 's'), (EPS, 'x'), ('c', 'c')]
edit_distance(seq1, seq2)
- used to obtain the total edit distance, as well as the number of insertions, deletions and substitutions.
from kaldialign import edit_distance
a = ['a', 'b', 'c']
b = ['a', 's', 'x', 'c']
results = edit_distance(a, b)
assert results == {
'ins': 1,
'del': 0,
'sub': 1,
'total': 2
}
Motivation
The need for this arised from the fact that practically all implementations of the Levenshtein distance have slight differences, making it impossible to use a different scoring tool than Kaldi and get the same error rate results. This package copies code from Kaldi directly and wraps it using Cython, avoiding the issue altogether.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kaldialign-0.4.tar.gz
.
File metadata
- Download URL: kaldialign-0.4.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69a8d3638cacd661f687db5429d49cb35d411a5b5fbcc97b9287354d748cf7f2 |
|
MD5 | 4989997f09146e3b220dbc5351f02b71 |
|
BLAKE2b-256 | b13b48747e164f61423a0fee2b09f5e3e55c17cf3b0846d8580fdb027f7e7d9d |
File details
Details for the file kaldialign-0.4-cp310-cp310-macosx_12_0_arm64.whl
.
File metadata
- Download URL: kaldialign-0.4-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 42.9 kB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4904fd1233868f88f2bf9bac313a95a615aa4ea55fb55d80f715aa284691ad22 |
|
MD5 | 7253521528beb17afcc18cd580b41129 |
|
BLAKE2b-256 | 8ac916451fae1bbc36779fdf063e19f21bc981731df45a5a781f04a5e46668e5 |