scriptconv 0.0.3a9__tar.gz → 0.0.3a10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/PKG-INFO +1 -1
  2. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/scripts.py +38 -3
  3. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/version.py +1 -1
  4. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv.egg-info/PKG-INFO +1 -1
  5. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv.egg-info/SOURCES.txt +1 -0
  6. scriptconv-0.0.3a10/tests/test_scripts_stressonnx_compat.py +47 -0
  7. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/LICENSE +0 -0
  8. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/README.md +0 -0
  9. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/pyproject.toml +0 -0
  10. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/requirements.txt +0 -0
  11. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/__init__.py +0 -0
  12. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/__main__.py +0 -0
  13. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/cangjie.py +0 -0
  14. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/conventions.py +0 -0
  15. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/data/__init__.py +0 -0
  16. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/data/cangjie5_tc.tsv.gz +0 -0
  17. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/graph.py +0 -0
  18. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/notation.py +0 -0
  19. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/py.typed +0 -0
  20. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/readings.py +0 -0
  21. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv/translit.py +0 -0
  22. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv.egg-info/dependency_links.txt +0 -0
  23. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv.egg-info/requires.txt +0 -0
  24. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/scriptconv.egg-info/top_level.txt +0 -0
  25. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/setup.cfg +0 -0
  26. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_cangjie.py +0 -0
  27. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_cli.py +0 -0
  28. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_conventions.py +0 -0
  29. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_errors_policy.py +0 -0
  30. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_examples.py +0 -0
  31. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_graph.py +0 -0
  32. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_notation.py +0 -0
  33. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_readings.py +0 -0
  34. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_readings_zh.py +0 -0
  35. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_scripts.py +0 -0
  36. {scriptconv-0.0.3a9 → scriptconv-0.0.3a10}/tests/test_translit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv
3
- Version: 0.0.3a9
3
+ Version: 0.0.3a10
4
4
  Summary: Zero-dependency script & phoneme-notation core — ISO-15924 detection & metadata, IPA↔ARPABET/X-SAMPA/Lexique/Kirshenbaum/Cotovía/RFE, Buckwalter↔Arabic, Hangul→jamo, kana
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
@@ -652,6 +652,34 @@ _LANG_TO_SCRIPT: dict[str, str] = {
652
652
  "rw": "Latn", # Kinyarwanda
653
653
  "tk": "Latn", # Turkmen (Latin since 1993)
654
654
  "eo": "Latn", # Esperanto
655
+ # Languages with no ISO 639-1 code (keyed by their 639-3 code directly)
656
+ "kjh": "Cyrl", # Khakas
657
+ "xal": "Cyrl", # Kalmyk (Cyrillic since 1938)
658
+ "kbd": "Cyrl", # Kabardian
659
+ "erz": "Cyrl", # Erzya
660
+ "mdf": "Cyrl", # Moksha
661
+ }
662
+
663
+ # ISO 639-2/3 (incl. bibliographic variants) -> the 639-1 key used above.
664
+ # Reference: Library of Congress ISO 639-2 code list.
665
+ _ISO639_ALIASES: dict[str, str] = {
666
+ "rus": "ru", "ukr": "uk", "bel": "be", "bul": "bg", "srp": "sr",
667
+ "mkd": "mk", "mac": "mk", "kaz": "kk", "kir": "ky", "tgk": "tg",
668
+ "mon": "mn", "tat": "tt", "bak": "ba", "chv": "cv", "oss": "os",
669
+ "che": "ce", "hye": "hy", "arm": "hy", "kat": "ka", "geo": "ka",
670
+ "aze": "az", "uzb": "uz", "tuk": "tk", "eng": "en", "deu": "de",
671
+ "ger": "de", "fra": "fr", "fre": "fr", "spa": "es", "por": "pt",
672
+ "ita": "it", "nld": "nl", "dut": "nl", "ell": "el", "gre": "el",
673
+ "ara": "ar", "heb": "he", "zho": "zh", "chi": "zh", "jpn": "ja",
674
+ "kor": "ko", "tur": "tr", "fas": "fa", "per": "fa", "urd": "ur",
675
+ "hin": "hi", "tha": "th", "vie": "vi", "pol": "pl", "ces": "cs",
676
+ "cze": "cs", "slk": "sk", "slo": "sk", "ron": "ro", "rum": "ro",
677
+ "hun": "hu", "fin": "fi", "swe": "sv", "nor": "no", "dan": "da",
678
+ "isl": "is", "ice": "is", "mya": "my", "bur": "my", "khm": "km",
679
+ "lao": "lo", "amh": "am", "tam": "ta", "tel": "te", "ben": "bn",
680
+ "guj": "gu", "kan": "kn", "mal": "ml", "mar": "mr", "pan": "pa",
681
+ "sin": "si", "nep": "ne", "eus": "eu", "baq": "eu", "cat": "ca",
682
+ "glg": "gl", "cym": "cy", "wel": "cy", "gle": "ga", "epo": "eo",
655
683
  }
656
684
 
657
685
 
@@ -674,14 +702,21 @@ def lang_to_script(lang: str) -> Optional[str]:
674
702
  'Latn'
675
703
  """
676
704
  subtags = lang.replace("_", "-").split("-")
677
- # An explicit script subtag (4 letters, e.g. "Latn") overrides the
678
- # language's default script.
705
+ # An explicit script subtag overrides the language's default script:
706
+ # 4-letter ISO-15924 codes ("sr-Latn"), and the widespread informal
707
+ # 3-letter forms "cyr"/"lat" ("uzb_cyr", "aze_lat").
679
708
  for sub in subtags[1:]:
709
+ low = sub.lower()
680
710
  if len(sub) == 4 and sub.isalpha():
681
711
  resolved = normalize_script_tag(sub)
682
712
  if resolved is not None:
683
713
  return resolved
684
- return _LANG_TO_SCRIPT.get(subtags[0].lower())
714
+ elif low in ("cyr", "lat"):
715
+ return "Cyrl" if low == "cyr" else "Latn"
716
+ key = subtags[0].lower()
717
+ if key in _LANG_TO_SCRIPT:
718
+ return _LANG_TO_SCRIPT[key]
719
+ return _LANG_TO_SCRIPT.get(_ISO639_ALIASES.get(key, ""))
685
720
 
686
721
 
687
722
  # ---------------------------------------------------------------------------
@@ -2,7 +2,7 @@
2
2
  VERSION_MAJOR = 0
3
3
  VERSION_MINOR = 0
4
4
  VERSION_BUILD = 3
5
- VERSION_ALPHA = 9
5
+ VERSION_ALPHA = 10
6
6
  # END_VERSION_BLOCK
7
7
 
8
8
  VERSION_STR = f"{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_BUILD}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv
3
- Version: 0.0.3a9
3
+ Version: 0.0.3a10
4
4
  Summary: Zero-dependency script & phoneme-notation core — ISO-15924 detection & metadata, IPA↔ARPABET/X-SAMPA/Lexique/Kirshenbaum/Cotovía/RFE, Buckwalter↔Arabic, Hangul→jamo, kana
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
@@ -30,4 +30,5 @@ tests/test_notation.py
30
30
  tests/test_readings.py
31
31
  tests/test_readings_zh.py
32
32
  tests/test_scripts.py
33
+ tests/test_scripts_stressonnx_compat.py
33
34
  tests/test_translit.py
@@ -0,0 +1,47 @@
1
+ """Downstream compat: the script tags scriptconv returns are a wire format.
2
+
3
+ stressonnx (accentor.py) maps its supported languages to a private script
4
+ taxonomy that mirrors phoonnx's Alphabet enum. These fixtures pin, key by
5
+ key, that scriptconv resolves every one of those language codes to the
6
+ expected ISO-15924 tag — so stressonnx's migration to scriptconv is a pure
7
+ deletion, and future edits here cannot silently break it.
8
+ """
9
+ import pytest
10
+
11
+ from scriptconv import lang_to_script
12
+
13
+ # stressonnx LANG_SCRIPT, verbatim keys -> the ISO-15924 tag its Script
14
+ # enum value corresponds to (cyrillic->Cyrl, latin->Latn, armenian->Armn,
15
+ # georgian->Geor).
16
+ STRESSONNX_LANGS = {
17
+ "ru": "Cyrl", "ukr": "Cyrl", "bel": "Cyrl", "bel_simple": "Cyrl",
18
+ "kaz": "Cyrl", "tat": "Cyrl", "bak": "Cyrl", "chv": "Cyrl",
19
+ "sah": "Cyrl", "kir": "Cyrl", "kjh": "Cyrl", "tgk": "Cyrl",
20
+ "udm": "Cyrl", "xal": "Cyrl", "kbd": "Cyrl", "erz": "Cyrl",
21
+ "mdf": "Cyrl", "uzb_cyr": "Cyrl", "aze_cyr": "Cyrl",
22
+ "aze_lat": "Latn", "uzb_lat": "Latn",
23
+ "hye": "Armn",
24
+ "kat": "Geor",
25
+ }
26
+
27
+
28
+ @pytest.mark.parametrize("lang,expected", sorted(STRESSONNX_LANGS.items()))
29
+ def test_stressonnx_language_resolves(lang, expected):
30
+ assert lang_to_script(lang) == expected
31
+
32
+
33
+ def test_iso639_bibliographic_variants():
34
+ assert lang_to_script("ger") == lang_to_script("deu") == "Latn"
35
+ assert lang_to_script("gre") == lang_to_script("ell") == "Grek"
36
+ assert lang_to_script("arm") == lang_to_script("hye") == "Armn"
37
+
38
+
39
+ def test_explicit_script_subtag_still_authoritative():
40
+ assert lang_to_script("uzb-Latn") == "Latn"
41
+ assert lang_to_script("sr_lat") == "Latn"
42
+ assert lang_to_script("sr") == "Cyrl"
43
+
44
+
45
+ def test_unknown_language_stays_none():
46
+ assert lang_to_script("zzz") is None
47
+ assert lang_to_script("qqq_cyr") == "Cyrl" # variant subtag wins even unknown-lang
File without changes
File without changes
File without changes