Spaces:
Sleeping
Sleeping
More renaming phone_distance to phone_errors
Browse filesFiles changed (2)
- README.md+7-7
- phone_errors.py+5-5
12 unmodified lines13141516161718193 unmodified lines2324252627262728293020 unmodified lines51525354545556571 unmodified line59606162626364651 unmodified line67686970707172731 unmodified line757677787879808112 unmodified linespinned: false---
# Metric Card for Phone Distance# Metric Card for Phone Errors
## Metric DescriptionError rates in terms of distance between articulatory phonological features can help understand differences between strings in the International Phonetic Alphabet (IPA) in a linguistically motivated way. 3 unmodified lines
```pythonimport evaluatephone_distance = evaluate.load("ginic/phone_errors")phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"])phone_errors = evaluate.load("ginic/phone_errors")phone_errors.compute(predictions=["bob", "ði"], references=["pop", "ðə"])```
### Inputs20 unmodified lines
Simplest use case to compute phone error rates between two IPA strings: ```python>>> phone_distance.compute(predictions=["bob", "ði", "spin"], references=["pop", "ðə", "spʰin"])>>> phone_errors.compute(predictions=["bob", "ði", "spin"], references=["pop", "ðə", "spʰin"]){'phone_error_rates': [0.6666666666666666, 0.5, 0.25], 'mean_phone_error_rate': 0.47222222222222215, 'phone_feature_error_rates': [0.08333333333333333, 0.125, 0.041666666666666664], 'mean_phone_feature_error_rate': 0.08333333333333333, 'feature_error_rates': [0.027777777777777776, 0.0625, 0.30208333333333337], 'mean_feature_error_rate': 0.13078703703703706}1 unmodified line
Normalize phone feature error rate by the length of the reference string: ```python>>> phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"], is_normalize_pfer=True)>>> phone_errors.compute(predictions=["bob", "ði"], references=["pop", "ðə"], is_normalize_pfer=True){'phone_error_rates': [0.6666666666666666, 0.5], 'mean_phone_error_rate': 0.5833333333333333, 'phone_feature_error_rates': [0.027777777777777776, 0.0625], 'mean_phone_feature_error_rate': 0.04513888888888889, 'feature_error_rates': [0.027777777777777776, 0.0625], 'mean_feature_error_rate': 0.04513888888888889}1 unmodified line
Error rates may be greater than 1.0 if the reference string is shorter than the prediction string:```python>>> phone_distance.compute(predictions=["bob"], references=["po"])>>> phone_errors.compute(predictions=["bob"], references=["po"]){'phone_error_rates': [1.0], 'mean_phone_error_rate': 1.0, 'phone_feature_error_rates': [1.0416666666666667], 'mean_phone_feature_error_rate': 1.0416666666666667, 'feature_error_rates': [0.020833333333333332], 'mean_feature_error_rate': 0.020833333333333332}1 unmodified line
Empty reference strings will cause an ValueError, you should handle them separately:```python>>> phone_distance.compute(predictions=["bob"], references=[""])>>> phone_errors.compute(predictions=["bob"], references=[""])Traceback (most recent call last): ... raise ValueError("one or more references are empty strings")70 unmodified lines717273747574757677787980798081828348 unmodified lines13213313413513513613713870 unmodified lines
Examples: Compare articulatory differences in voicing in "bob" vs. "pop" and different pronunciations of "the":>>> phone_distance = evaluate.load("ginic/phone_errors")>>> phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"])>>> phone_errors = evaluate.load("ginic/phone_errors")>>> phone_errors.compute(predictions=["bob", "ði"], references=["pop", "ðə"]){'phone_error_rates': [0.6666666666666666, 0.5], 'mean_phone_error_rate': 0.5833333333333333, 'phone_feature_error_rates': [0.08333333333333333, 0.125], 'mean_phone_feature_error_rate': 0.10416666666666666, 'feature_error_rates': [0.027777777777777776, 0.0625], 'mean_feature_error_rate': 0.04513888888888889}
Normalize PFER by the length of string with largest number of phones: >>> phone_distance = evaluate.load("ginic/phone_errors")>>> phone_distance.compute(predictions=["bob", "ði"], references=["pop", "ðə"], is_normalize_pfer=True)>>> phone_errors = evaluate.load("ginic/phone_errors")>>> phone_errors.compute(predictions=["bob", "ði"], references=["pop", "ðə"], is_normalize_pfer=True)
"""
48 unmodified lines 'references': datasets.Value('string', id="sequence"), }), # Additional links to the codebase or references codebase_urls=["https://github.com/dmort27/panphon", "https://huggingface.co/spaces/ginic/phone_distance/tree/main"], codebase_urls=["https://github.com/dmort27/panphon", "https://huggingface.co/spaces/ginic/phone_errors/tree/main"], reference_urls=["https://pypi.org/project/panphon/", "https://arxiv.org/abs/2308.03917"] )
README.md+7-7
phone_errors.py+5-5