Download source/tests/test_score.py from bingokingooo/shruti-coreml: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/bingokingooo/shruti-coreml/resolve/main/source/tests/test_score.py
- Command line
-
hf download hf://bingokingooo/shruti-coreml/source/tests/test_score.py
-
curl -L -o test_score.py https://huggingface.co/bingokingooo/shruti-coreml/resolve/main/source/tests/test_score.py
1.18 kB
| import unittest | |
| from shruti_coreml.score import edit_distance, score_paired, words | |
| class ScoreTests(unittest.TestCase): | |
| def test_nfc_lowercase_punctuation_and_numbers(self): | |
| self.assertEqual(words(" E\u0301CO, 200! चालीस। "), ["éco", "200", "चालीस"]) | |
| def test_token_insert_delete_and_replace(self): | |
| self.assertEqual(edit_distance(["a", "b", "c"], ["a", "d", "e", "f"]), 3) | |
| self.assertEqual(edit_distance(["a"], []), 1) | |
| self.assertEqual(edit_distance([], ["a", "b"]), 2) | |
| def test_weighting_and_pairing(self): | |
| rows = [ | |
| {"reference": "one two", "baseline": {"text": "one"}, "coreml": {"text": "one two"}}, | |
| {"reference": "three", "baseline": {"text": "three"}, "coreml": {"text": "three"}}, | |
| ] | |
| scored = score_paired(rows) | |
| self.assertAlmostEqual(scored["difference_wer_points"], -100 / 3) | |
| self.assertEqual(scored["exact_text_matches"], 1) | |
| def test_silence_counts_words(self): | |
| scored = score_paired([{"reference": "", "baseline": {"text": ""}, "coreml": {"text": "one two"}}]) | |
| self.assertEqual(scored["coreml_words_on_silence"], 2) | |