scriptconv 0.0.1a5__tar.gz → 0.0.1a6__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.
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/PKG-INFO +6 -3
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/README.md +5 -2
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/__init__.py +2 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/notation.py +54 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/version.py +1 -1
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv.egg-info/PKG-INFO +6 -3
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/tests/test_notation.py +30 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/LICENSE +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/pyproject.toml +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/requirements.txt +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/__main__.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/py.typed +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/scripts.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv/translit.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv.egg-info/SOURCES.txt +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv.egg-info/dependency_links.txt +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv.egg-info/requires.txt +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/scriptconv.egg-info/top_level.txt +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/setup.cfg +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/tests/test_cli.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/tests/test_examples.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/tests/test_scripts.py +0 -0
- {scriptconv-0.0.1a5 → scriptconv-0.0.1a6}/tests/test_translit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptconv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.1a6
|
|
4
4
|
Summary: Shared script-conversion core — ISO-15924 detection, IPA↔ARPA/X-SAMPA/Lexique, Buckwalter, Hangul→jamo
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
|
|
@@ -75,7 +75,7 @@ from scriptconv import (
|
|
|
75
75
|
xsampa_to_ipa, ipa_to_xsampa,
|
|
76
76
|
buckwalter_to_arabic, arabic_to_buckwalter,
|
|
77
77
|
lexique_to_ipa, ipa_to_lexique,
|
|
78
|
-
kirshenbaum_to_ipa, ipa_to_kirshenbaum,
|
|
78
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, looks_like_ipa,
|
|
79
79
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
80
80
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
81
81
|
)
|
|
@@ -107,6 +107,9 @@ ipa_to_lexique("vɛ̃") # "v5" (vin)
|
|
|
107
107
|
kirshenbaum_to_ipa("S") # "ʃ" (espeak-ng ASCII-IPA)
|
|
108
108
|
ipa_to_kirshenbaum("ŋ") # "N"
|
|
109
109
|
|
|
110
|
+
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
111
|
+
looks_like_ipa("hello") # False
|
|
112
|
+
|
|
110
113
|
decompose_hangul("국민") # "ㄱㅜㄱㅁㅣㄴ" (orthographic jamo, no assimilation)
|
|
111
114
|
hira_to_kana("ひらがな") # "ヒラガナ"
|
|
112
115
|
kana_to_hira("カタカナ") # "かたかな"
|
|
@@ -136,7 +139,7 @@ python -m scriptconv lang ko
|
|
|
136
139
|
| Module | Contents |
|
|
137
140
|
|--------|----------|
|
|
138
141
|
| `scriptconv.scripts` | `Script` dataclass (with `script_type`), `SCRIPT_REGISTRY` (34 scripts), `detect_script`, `char_script`, `script_distribution`, `script_runs`, `base_direction`, `lang_to_script`, `script_to_langs`, `normalize_script_tag` |
|
|
139
|
-
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA) |
|
|
142
|
+
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA), `looks_like_ipa` detector |
|
|
140
143
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
141
144
|
|
|
142
145
|
## Documentation
|
|
@@ -48,7 +48,7 @@ from scriptconv import (
|
|
|
48
48
|
xsampa_to_ipa, ipa_to_xsampa,
|
|
49
49
|
buckwalter_to_arabic, arabic_to_buckwalter,
|
|
50
50
|
lexique_to_ipa, ipa_to_lexique,
|
|
51
|
-
kirshenbaum_to_ipa, ipa_to_kirshenbaum,
|
|
51
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, looks_like_ipa,
|
|
52
52
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
53
53
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
54
54
|
)
|
|
@@ -80,6 +80,9 @@ ipa_to_lexique("vɛ̃") # "v5" (vin)
|
|
|
80
80
|
kirshenbaum_to_ipa("S") # "ʃ" (espeak-ng ASCII-IPA)
|
|
81
81
|
ipa_to_kirshenbaum("ŋ") # "N"
|
|
82
82
|
|
|
83
|
+
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
84
|
+
looks_like_ipa("hello") # False
|
|
85
|
+
|
|
83
86
|
decompose_hangul("국민") # "ㄱㅜㄱㅁㅣㄴ" (orthographic jamo, no assimilation)
|
|
84
87
|
hira_to_kana("ひらがな") # "ヒラガナ"
|
|
85
88
|
kana_to_hira("カタカナ") # "かたかな"
|
|
@@ -109,7 +112,7 @@ python -m scriptconv lang ko
|
|
|
109
112
|
| Module | Contents |
|
|
110
113
|
|--------|----------|
|
|
111
114
|
| `scriptconv.scripts` | `Script` dataclass (with `script_type`), `SCRIPT_REGISTRY` (34 scripts), `detect_script`, `char_script`, `script_distribution`, `script_runs`, `base_direction`, `lang_to_script`, `script_to_langs`, `normalize_script_tag` |
|
|
112
|
-
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA) |
|
|
115
|
+
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA), `looks_like_ipa` detector |
|
|
113
116
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
114
117
|
|
|
115
118
|
## Documentation
|
|
@@ -50,6 +50,7 @@ from scriptconv.notation import (
|
|
|
50
50
|
ipa_to_lexique,
|
|
51
51
|
kirshenbaum_to_ipa,
|
|
52
52
|
ipa_to_kirshenbaum,
|
|
53
|
+
looks_like_ipa,
|
|
53
54
|
)
|
|
54
55
|
from scriptconv.translit import (
|
|
55
56
|
decompose_hangul,
|
|
@@ -86,6 +87,7 @@ __all__ = [
|
|
|
86
87
|
"ipa_to_lexique",
|
|
87
88
|
"kirshenbaum_to_ipa",
|
|
88
89
|
"ipa_to_kirshenbaum",
|
|
90
|
+
"looks_like_ipa",
|
|
89
91
|
# translit
|
|
90
92
|
"decompose_hangul",
|
|
91
93
|
"hira_to_kana",
|
|
@@ -37,6 +37,7 @@ __all__ = [
|
|
|
37
37
|
"ipa_to_lexique",
|
|
38
38
|
"kirshenbaum_to_ipa",
|
|
39
39
|
"ipa_to_kirshenbaum",
|
|
40
|
+
"looks_like_ipa",
|
|
40
41
|
]
|
|
41
42
|
|
|
42
43
|
|
|
@@ -894,3 +895,56 @@ def convert_batch(
|
|
|
894
895
|
yield stripped
|
|
895
896
|
else:
|
|
896
897
|
yield convert(stripped, _src, _dst)
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
# ---------------------------------------------------------------------------
|
|
901
|
+
# looks_like_ipa — heuristic notation detection
|
|
902
|
+
# ---------------------------------------------------------------------------
|
|
903
|
+
|
|
904
|
+
# Unicode blocks/characters that are distinctive to IPA transcription. Basic
|
|
905
|
+
# Latin letters (p, a, t, …) and the Greek letters IPA borrows (β, θ, χ) are
|
|
906
|
+
# deliberately excluded: they are indistinguishable from ordinary Latin/Greek
|
|
907
|
+
# text, so they carry no signal.
|
|
908
|
+
_IPA_DISTINCTIVE_RANGES = (
|
|
909
|
+
(0x0250, 0x02AF), # IPA Extensions
|
|
910
|
+
(0x02B0, 0x02FF), # Spacing Modifier Letters (ˈ ˌ ː ˑ ʰ ʲ …)
|
|
911
|
+
(0x0363, 0x036F), # Combining diacritics used in IPA
|
|
912
|
+
(0x1D00, 0x1D7F), # Phonetic Extensions
|
|
913
|
+
(0x1D80, 0x1DBF), # Phonetic Extensions Supplement
|
|
914
|
+
)
|
|
915
|
+
# Individual combining marks common in IPA (nasalisation, syllabicity, etc.).
|
|
916
|
+
_IPA_DISTINCTIVE_CHARS = frozenset("̩̪̥̃̊͜͡")
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
def _is_ipa_distinctive(ch: str) -> bool:
|
|
920
|
+
cp = ord(ch)
|
|
921
|
+
if ch in _IPA_DISTINCTIVE_CHARS:
|
|
922
|
+
return True
|
|
923
|
+
return any(lo <= cp <= hi for lo, hi in _IPA_DISTINCTIVE_RANGES)
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
def looks_like_ipa(text: str) -> bool:
|
|
927
|
+
"""Heuristically decide whether *text* is an IPA transcription.
|
|
928
|
+
|
|
929
|
+
Returns ``True`` when *text* contains at least one character that is
|
|
930
|
+
distinctive to IPA — from the IPA Extensions, Spacing Modifier Letters,
|
|
931
|
+
or Phonetic Extensions blocks, or an IPA combining diacritic (e.g.
|
|
932
|
+
``ɑ``, ``ʃ``, ``ː``, ``ˈ``, nasalisation).
|
|
933
|
+
|
|
934
|
+
This is a positive-signal heuristic, not a classifier: a transcription
|
|
935
|
+
written only with characters IPA shares with the Latin alphabet
|
|
936
|
+
(``"pat"``, ``"bad"``) has no distinctive marker and returns ``False``.
|
|
937
|
+
It cannot be otherwise — those characters are the same codepoints as
|
|
938
|
+
ordinary text. Use it to *guard* against feeding IPA where orthography
|
|
939
|
+
is expected, not to prove a string is not IPA.
|
|
940
|
+
|
|
941
|
+
Examples
|
|
942
|
+
--------
|
|
943
|
+
>>> looks_like_ipa("pʰɑtʃ")
|
|
944
|
+
True
|
|
945
|
+
>>> looks_like_ipa("ˈhɛloʊ")
|
|
946
|
+
True
|
|
947
|
+
>>> looks_like_ipa("hello")
|
|
948
|
+
False
|
|
949
|
+
"""
|
|
950
|
+
return any(_is_ipa_distinctive(ch) for ch in text)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptconv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.1a6
|
|
4
4
|
Summary: Shared script-conversion core — ISO-15924 detection, IPA↔ARPA/X-SAMPA/Lexique, Buckwalter, Hangul→jamo
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
|
|
@@ -75,7 +75,7 @@ from scriptconv import (
|
|
|
75
75
|
xsampa_to_ipa, ipa_to_xsampa,
|
|
76
76
|
buckwalter_to_arabic, arabic_to_buckwalter,
|
|
77
77
|
lexique_to_ipa, ipa_to_lexique,
|
|
78
|
-
kirshenbaum_to_ipa, ipa_to_kirshenbaum,
|
|
78
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, looks_like_ipa,
|
|
79
79
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
80
80
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
81
81
|
)
|
|
@@ -107,6 +107,9 @@ ipa_to_lexique("vɛ̃") # "v5" (vin)
|
|
|
107
107
|
kirshenbaum_to_ipa("S") # "ʃ" (espeak-ng ASCII-IPA)
|
|
108
108
|
ipa_to_kirshenbaum("ŋ") # "N"
|
|
109
109
|
|
|
110
|
+
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
111
|
+
looks_like_ipa("hello") # False
|
|
112
|
+
|
|
110
113
|
decompose_hangul("국민") # "ㄱㅜㄱㅁㅣㄴ" (orthographic jamo, no assimilation)
|
|
111
114
|
hira_to_kana("ひらがな") # "ヒラガナ"
|
|
112
115
|
kana_to_hira("カタカナ") # "かたかな"
|
|
@@ -136,7 +139,7 @@ python -m scriptconv lang ko
|
|
|
136
139
|
| Module | Contents |
|
|
137
140
|
|--------|----------|
|
|
138
141
|
| `scriptconv.scripts` | `Script` dataclass (with `script_type`), `SCRIPT_REGISTRY` (34 scripts), `detect_script`, `char_script`, `script_distribution`, `script_runs`, `base_direction`, `lang_to_script`, `script_to_langs`, `normalize_script_tag` |
|
|
139
|
-
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA) |
|
|
142
|
+
| `scriptconv.notation` | `Notation` enum, `NotationInfo`/`NOTATION_INFO` fidelity registry, `convert` facade, `can_convert` predicate, `convert_batch` generator, pair-wise converters (ARPABET ↔ IPA, X-SAMPA ↔ IPA, Buckwalter ↔ Arabic, Lexique ↔ IPA, Kirshenbaum ↔ IPA), `looks_like_ipa` detector |
|
|
140
143
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
141
144
|
|
|
142
145
|
## Documentation
|
|
@@ -1027,3 +1027,33 @@ def test_lossless_to_ipa_flag_backed_by_round_trip():
|
|
|
1027
1027
|
if info.lossless_to_ipa and notation in samples:
|
|
1028
1028
|
for ch in samples[notation]:
|
|
1029
1029
|
assert from_ipa[notation](to_ipa[notation](ch)) == ch, notation
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
# ---------------------------------------------------------------------------
|
|
1033
|
+
# looks_like_ipa — heuristic notation detection
|
|
1034
|
+
# ---------------------------------------------------------------------------
|
|
1035
|
+
|
|
1036
|
+
from scriptconv.notation import looks_like_ipa # noqa: E402
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
@pytest.mark.parametrize("text", [
|
|
1040
|
+
"pʰɑtʃ", # IPA Extensions + modifier
|
|
1041
|
+
"ˈhɛloʊ", # stress mark + IPA Extensions
|
|
1042
|
+
"ɑ", # single IPA Extensions char
|
|
1043
|
+
"næ̃", # combining nasalisation
|
|
1044
|
+
"kat̪", # combining dental diacritic
|
|
1045
|
+
])
|
|
1046
|
+
def test_looks_like_ipa_true(text):
|
|
1047
|
+
assert looks_like_ipa(text) is True
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
@pytest.mark.parametrize("text", [
|
|
1051
|
+
"", # empty
|
|
1052
|
+
"hello", # plain Latin — ambiguous, no distinctive marker
|
|
1053
|
+
"att", # overlaps Latin
|
|
1054
|
+
"café", # accented Latin is not IPA-distinctive
|
|
1055
|
+
"θaβ", # bare Greek letters carry no IPA signal
|
|
1056
|
+
"مرحبا", # Arabic
|
|
1057
|
+
])
|
|
1058
|
+
def test_looks_like_ipa_false(text):
|
|
1059
|
+
assert looks_like_ipa(text) is False
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|