Download tests/test_reader_parity.py from Omarrran/ks-g2p: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/Omarrran/ks-g2p/resolve/main/tests/test_reader_parity.py
- Command line
-
hf download hf://Omarrran/ks-g2p/tests/test_reader_parity.py
-
curl -L -o test_reader_parity.py https://huggingface.co/Omarrran/ks-g2p/resolve/main/tests/test_reader_parity.py
710 Bytes
| """The vendored reader must stay identical to ks-devanagari's parser (skipped if it is not installed).""" | |
| import gzip | |
| import json | |
| from pathlib import Path | |
| import pytest | |
| from ks_g2p import _reader | |
| parser = pytest.importorskip('ks_devanagari._parser') | |
| WORDS = Path(__file__).with_name('data') / 'ks_words.jsonl.gz' | |
| def test_vendored_reader_matches_ks_devanagari(): | |
| words = set() | |
| with gzip.open(WORDS, 'rt', encoding='utf-8') as f: | |
| for line in f: | |
| words.update(t for t, w in _reader.tokenize(json.loads(line)['input']) if w) | |
| diff = [w for w in words if _reader.parse_word(w) != parser.parse_word(w)] | |
| assert not diff, f'{len(diff)} words read differently, e.g. {diff[:5]}' | |