edit_distance()¶
- audmetric.edit_distance(truth, prediction)[source]¶
Edit distance between two sequences of chars or ints.
The implementation follows the Wagner-Fischer algorithm.
- Parameters
truth (
Union
[str
,Sequence
[int
]]) – ground truth sequenceprediction (
Union
[str
,Sequence
[int
]]) – predicted sequence
- Return type
int
- Returns
edit distance
Examples
>>> truth = "lorem" >>> prediction = "lorm" >>> edit_distance(truth, prediction) 1 >>> truth = [0, 1, 2] >>> prediction = [0, 1] >>> edit_distance(truth, prediction) 1