scriptconv 0.0.2a1__tar.gz → 0.0.2a2__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.2a1 → scriptconv-0.0.2a2}/PKG-INFO +11 -4
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/README.md +10 -3
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/__init__.py +4 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/notation.py +130 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/version.py +1 -1
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv.egg-info/PKG-INFO +11 -4
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/tests/test_examples.py +6 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/tests/test_notation.py +41 -1
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/LICENSE +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/pyproject.toml +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/requirements.txt +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/__main__.py +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/py.typed +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/scripts.py +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv/translit.py +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv.egg-info/SOURCES.txt +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv.egg-info/dependency_links.txt +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv.egg-info/requires.txt +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/scriptconv.egg-info/top_level.txt +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/setup.cfg +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/tests/test_cli.py +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/tests/test_scripts.py +0 -0
- {scriptconv-0.0.2a1 → scriptconv-0.0.2a2}/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.2a2
|
|
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
|
|
@@ -33,7 +33,7 @@ Dynamic: license-file
|
|
|
33
33
|
|
|
34
34
|
**scriptconv** is a zero-dependency Python library for written-script operations:
|
|
35
35
|
ISO-15924 script identification and metadata, character-range detection, language-to-script
|
|
36
|
-
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía,
|
|
36
|
+
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía / RFE,
|
|
37
37
|
Buckwalter ↔ Arabic script), and orthographic decomposition of Hangul syllable blocks into
|
|
38
38
|
jamo letters. Every conversion is a pure data table or arithmetic operation; no linguistic
|
|
39
39
|
rules, no external files, no runtime dependencies beyond the Python standard library.
|
|
@@ -75,7 +75,8 @@ 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, cotovia_to_ipa, ipa_to_cotovia,
|
|
78
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, cotovia_to_ipa, ipa_to_cotovia,
|
|
79
|
+
rfe_to_ipa, ipa_to_rfe, looks_like_ipa,
|
|
79
80
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
80
81
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
81
82
|
)
|
|
@@ -110,6 +111,9 @@ ipa_to_kirshenbaum("ŋ") # "N"
|
|
|
110
111
|
cotovia_to_ipa("karro") # "karo" (Galician Cotovía TTS notation)
|
|
111
112
|
ipa_to_cotovia("ʎ") # "L"
|
|
112
113
|
|
|
114
|
+
rfe_to_ipa("kaša") # "kaʃa" (Spanish/Romance RFE alphabet)
|
|
115
|
+
ipa_to_rfe("ɲ") # "ñ"
|
|
116
|
+
|
|
113
117
|
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
114
118
|
looks_like_ipa("hello") # False
|
|
115
119
|
|
|
@@ -142,7 +146,7 @@ python -m scriptconv lang ko
|
|
|
142
146
|
| Module | Contents |
|
|
143
147
|
|--------|----------|
|
|
144
148
|
| `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` |
|
|
145
|
-
| `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, Cotovía ↔ IPA), `looks_like_ipa` detector |
|
|
149
|
+
| `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, Cotovía ↔ IPA, RFE ↔ IPA), `looks_like_ipa` detector |
|
|
146
150
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
147
151
|
|
|
148
152
|
## Documentation
|
|
@@ -172,6 +176,7 @@ Runnable scripts in [examples/](examples/):
|
|
|
172
176
|
| `13_script_runs.py` | Per-script segmentation of mixed-script text |
|
|
173
177
|
| `14_kana_transliteration.py` | Hiragana ↔ Katakana |
|
|
174
178
|
| `15_cotovia.py` | Cotovía (Galician TTS notation) ↔ IPA |
|
|
179
|
+
| `16_rfe.py` | RFE (Spanish/Romance philology alphabet) ↔ IPA |
|
|
175
180
|
|
|
176
181
|
## Fidelity guarantees
|
|
177
182
|
|
|
@@ -187,6 +192,7 @@ round-trip is exact and what happens to a symbol the table does not know.
|
|
|
187
192
|
| **Lexique ↔ IPA** | Exact except the `°`/`3` schwa pair (both → `ə`; reverse always → `°`) | Exact | Passed through unchanged |
|
|
188
193
|
| **Kirshenbaum ↔ IPA** | Exact | **Lossy** — restricted ASCII inventory; IPA outside it passes through | Passed through unchanged |
|
|
189
194
|
| **Cotovía ↔ IPA** | Exact except the three `L`/`Z`/`jj` symbols for `ʎ` normalise to `L` | **Lossy** — Galician/Spanish inventory; IPA outside it passes through | Passed through unchanged |
|
|
195
|
+
| **RFE ↔ IPA** | Exact except `ñ`/`n̮` for `ɲ` normalise to `ñ` | **Lossy** — core Spanish/Romance inventory; IPA outside it passes through | Passed through unchanged |
|
|
190
196
|
|
|
191
197
|
This table is also available programmatically via `NOTATION_INFO`
|
|
192
198
|
(`NotationInfo` records with `lossless_to_ipa`, `lossless_from_ipa`,
|
|
@@ -213,4 +219,5 @@ Derived tables used internally:
|
|
|
213
219
|
| Lexique phoneme codes | New, B. & Pallier, C. — *Manuel de Lexique 3* v3.11, Tableau 2; [chrplr/openlexicon](https://github.com/chrplr/openlexicon) | CC BY-SA 4.0 |
|
|
214
220
|
| Kirshenbaum ↔ IPA | Kirshenbaum 1993 ASCII-IPA standard (comp.speech), cross-checked against espeak-ng | — (factual symbol mapping) |
|
|
215
221
|
| Cotovía ↔ IPA | Universidade de Vigo GTM Cotovía TTS project (`fonemas.cpp`) | — (factual symbol mapping) |
|
|
222
|
+
| RFE ↔ IPA | RFE phonetic alphabet (Revista de Filología Española, 1915) | — (factual symbol mapping) |
|
|
216
223
|
| Hangul jamo tables | [stannam/hangul_to_ipa](https://github.com/stannam/hangul_to_ipa) | — |
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
**scriptconv** is a zero-dependency Python library for written-script operations:
|
|
8
8
|
ISO-15924 script identification and metadata, character-range detection, language-to-script
|
|
9
|
-
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía,
|
|
9
|
+
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía / RFE,
|
|
10
10
|
Buckwalter ↔ Arabic script), and orthographic decomposition of Hangul syllable blocks into
|
|
11
11
|
jamo letters. Every conversion is a pure data table or arithmetic operation; no linguistic
|
|
12
12
|
rules, no external files, no runtime dependencies beyond the Python standard library.
|
|
@@ -48,7 +48,8 @@ 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, cotovia_to_ipa, ipa_to_cotovia,
|
|
51
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, cotovia_to_ipa, ipa_to_cotovia,
|
|
52
|
+
rfe_to_ipa, ipa_to_rfe, looks_like_ipa,
|
|
52
53
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
53
54
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
54
55
|
)
|
|
@@ -83,6 +84,9 @@ ipa_to_kirshenbaum("ŋ") # "N"
|
|
|
83
84
|
cotovia_to_ipa("karro") # "karo" (Galician Cotovía TTS notation)
|
|
84
85
|
ipa_to_cotovia("ʎ") # "L"
|
|
85
86
|
|
|
87
|
+
rfe_to_ipa("kaša") # "kaʃa" (Spanish/Romance RFE alphabet)
|
|
88
|
+
ipa_to_rfe("ɲ") # "ñ"
|
|
89
|
+
|
|
86
90
|
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
87
91
|
looks_like_ipa("hello") # False
|
|
88
92
|
|
|
@@ -115,7 +119,7 @@ python -m scriptconv lang ko
|
|
|
115
119
|
| Module | Contents |
|
|
116
120
|
|--------|----------|
|
|
117
121
|
| `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` |
|
|
118
|
-
| `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, Cotovía ↔ IPA), `looks_like_ipa` detector |
|
|
122
|
+
| `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, Cotovía ↔ IPA, RFE ↔ IPA), `looks_like_ipa` detector |
|
|
119
123
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
120
124
|
|
|
121
125
|
## Documentation
|
|
@@ -145,6 +149,7 @@ Runnable scripts in [examples/](examples/):
|
|
|
145
149
|
| `13_script_runs.py` | Per-script segmentation of mixed-script text |
|
|
146
150
|
| `14_kana_transliteration.py` | Hiragana ↔ Katakana |
|
|
147
151
|
| `15_cotovia.py` | Cotovía (Galician TTS notation) ↔ IPA |
|
|
152
|
+
| `16_rfe.py` | RFE (Spanish/Romance philology alphabet) ↔ IPA |
|
|
148
153
|
|
|
149
154
|
## Fidelity guarantees
|
|
150
155
|
|
|
@@ -160,6 +165,7 @@ round-trip is exact and what happens to a symbol the table does not know.
|
|
|
160
165
|
| **Lexique ↔ IPA** | Exact except the `°`/`3` schwa pair (both → `ə`; reverse always → `°`) | Exact | Passed through unchanged |
|
|
161
166
|
| **Kirshenbaum ↔ IPA** | Exact | **Lossy** — restricted ASCII inventory; IPA outside it passes through | Passed through unchanged |
|
|
162
167
|
| **Cotovía ↔ IPA** | Exact except the three `L`/`Z`/`jj` symbols for `ʎ` normalise to `L` | **Lossy** — Galician/Spanish inventory; IPA outside it passes through | Passed through unchanged |
|
|
168
|
+
| **RFE ↔ IPA** | Exact except `ñ`/`n̮` for `ɲ` normalise to `ñ` | **Lossy** — core Spanish/Romance inventory; IPA outside it passes through | Passed through unchanged |
|
|
163
169
|
|
|
164
170
|
This table is also available programmatically via `NOTATION_INFO`
|
|
165
171
|
(`NotationInfo` records with `lossless_to_ipa`, `lossless_from_ipa`,
|
|
@@ -186,4 +192,5 @@ Derived tables used internally:
|
|
|
186
192
|
| Lexique phoneme codes | New, B. & Pallier, C. — *Manuel de Lexique 3* v3.11, Tableau 2; [chrplr/openlexicon](https://github.com/chrplr/openlexicon) | CC BY-SA 4.0 |
|
|
187
193
|
| Kirshenbaum ↔ IPA | Kirshenbaum 1993 ASCII-IPA standard (comp.speech), cross-checked against espeak-ng | — (factual symbol mapping) |
|
|
188
194
|
| Cotovía ↔ IPA | Universidade de Vigo GTM Cotovía TTS project (`fonemas.cpp`) | — (factual symbol mapping) |
|
|
195
|
+
| RFE ↔ IPA | RFE phonetic alphabet (Revista de Filología Española, 1915) | — (factual symbol mapping) |
|
|
189
196
|
| Hangul jamo tables | [stannam/hangul_to_ipa](https://github.com/stannam/hangul_to_ipa) | — |
|
|
@@ -52,6 +52,8 @@ from scriptconv.notation import (
|
|
|
52
52
|
ipa_to_kirshenbaum,
|
|
53
53
|
cotovia_to_ipa,
|
|
54
54
|
ipa_to_cotovia,
|
|
55
|
+
rfe_to_ipa,
|
|
56
|
+
ipa_to_rfe,
|
|
55
57
|
looks_like_ipa,
|
|
56
58
|
)
|
|
57
59
|
from scriptconv.translit import (
|
|
@@ -91,6 +93,8 @@ __all__ = [
|
|
|
91
93
|
"ipa_to_kirshenbaum",
|
|
92
94
|
"cotovia_to_ipa",
|
|
93
95
|
"ipa_to_cotovia",
|
|
96
|
+
"rfe_to_ipa",
|
|
97
|
+
"ipa_to_rfe",
|
|
94
98
|
"looks_like_ipa",
|
|
95
99
|
# translit
|
|
96
100
|
"decompose_hangul",
|
|
@@ -39,6 +39,8 @@ __all__ = [
|
|
|
39
39
|
"ipa_to_kirshenbaum",
|
|
40
40
|
"cotovia_to_ipa",
|
|
41
41
|
"ipa_to_cotovia",
|
|
42
|
+
"rfe_to_ipa",
|
|
43
|
+
"ipa_to_rfe",
|
|
42
44
|
"looks_like_ipa",
|
|
43
45
|
]
|
|
44
46
|
|
|
@@ -54,6 +56,7 @@ class Notation(str, Enum):
|
|
|
54
56
|
LEXIQUE = "lexique" # Lexique one-char-per-phoneme French notation
|
|
55
57
|
KIRSHENBAUM = "kirshenbaum" # ASCII-IPA (espeak-ng native notation)
|
|
56
58
|
COTOVIA = "cotovia" # Universidade de Vigo Cotovía TTS notation (gl)
|
|
59
|
+
RFE = "rfe" # Revista de Filología Española phonetic alphabet
|
|
57
60
|
|
|
58
61
|
def __repr__(self) -> str:
|
|
59
62
|
return f"Notation.{self.name}"
|
|
@@ -786,6 +789,126 @@ def ipa_to_cotovia(ipa: str) -> str:
|
|
|
786
789
|
return "".join(result)
|
|
787
790
|
|
|
788
791
|
|
|
792
|
+
# ---------------------------------------------------------------------------
|
|
793
|
+
# RFE (Revista de Filología Española) ↔ IPA
|
|
794
|
+
#
|
|
795
|
+
# The RFE phonetic alphabet (Navarro Tomás, Revista de Filología Española,
|
|
796
|
+
# 1915) is the traditional transcription system of Spanish and Romance
|
|
797
|
+
# philology. This is its core, well-attested inventory; rare interdental and
|
|
798
|
+
# variant diacritic symbols from the full standard are omitted. Symbols are
|
|
799
|
+
# matched longest-first (combining-mark symbols before their base letters).
|
|
800
|
+
# Reference: RFE Phonetic Alphabet
|
|
801
|
+
# (https://en.wikipedia.org/wiki/RFE_Phonetic_Alphabet).
|
|
802
|
+
# ---------------------------------------------------------------------------
|
|
803
|
+
|
|
804
|
+
_RFE_TO_IPA: dict[str, str] = {
|
|
805
|
+
# Combining-mark symbols (longest-match first)
|
|
806
|
+
"r̄": "r", # r + macron = alveolar trill (plain r = tap ɾ)
|
|
807
|
+
"n̮": "ɲ", # n + breve below = palatal nasal ɲ
|
|
808
|
+
"l̮": "ʎ", # l + breve below = palatal lateral ʎ
|
|
809
|
+
# Palatal / postalveolar
|
|
810
|
+
"ĉ": "tʃ", # ĉ = tʃ
|
|
811
|
+
"š": "ʃ", # š = ʃ
|
|
812
|
+
"ž": "ʒ", # ž = ʒ
|
|
813
|
+
"ŷ": "ɟʝ", # ŷ = ɟʝ (voiced palatal affricate)
|
|
814
|
+
"ñ": "ɲ", # ñ = ɲ
|
|
815
|
+
"y": "ʝ", # y = ʝ
|
|
816
|
+
"j": "j", # j = j
|
|
817
|
+
# Spanish approximant/fricative allophones
|
|
818
|
+
"ƀ": "β", # ƀ = β
|
|
819
|
+
"đ": "ð", # đ = ð
|
|
820
|
+
"ǥ": "ɣ", # ǥ = ɣ
|
|
821
|
+
# Other consonants
|
|
822
|
+
"θ": "θ", # θ = θ
|
|
823
|
+
"x": "x",
|
|
824
|
+
"ł": "ɫ", # ł = ɫ (velarized l)
|
|
825
|
+
"ŋ": "ŋ", # ŋ = ŋ
|
|
826
|
+
"w": "w",
|
|
827
|
+
"h": "h",
|
|
828
|
+
"b": "b",
|
|
829
|
+
"p": "p",
|
|
830
|
+
"t": "t",
|
|
831
|
+
"d": "d",
|
|
832
|
+
"k": "k",
|
|
833
|
+
"g": "ɡ", # g = ɡ (script g, matching the other tables)
|
|
834
|
+
"f": "f",
|
|
835
|
+
"v": "v",
|
|
836
|
+
"s": "s",
|
|
837
|
+
"z": "z",
|
|
838
|
+
"m": "m",
|
|
839
|
+
"n": "n",
|
|
840
|
+
"l": "l",
|
|
841
|
+
"r": "ɾ", # r = tap ɾ
|
|
842
|
+
# Vowels
|
|
843
|
+
"a": "a", "e": "e", "i": "i", "o": "o", "u": "u",
|
|
844
|
+
"ə": "ə", # ə = ə
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
# Reverse: IPA → RFE. First-wins deduplicates; pin the canonical RFE spellings
|
|
848
|
+
# for the palatal nasal (ñ) and the trill/tap pair.
|
|
849
|
+
_IPA_TO_RFE: dict[str, str] = {}
|
|
850
|
+
for _rfe, _ip in _RFE_TO_IPA.items():
|
|
851
|
+
_IPA_TO_RFE.setdefault(_ip, _rfe)
|
|
852
|
+
_IPA_TO_RFE["ɲ"] = "ñ" # ɲ → ñ (canonical, not the n̮ variant)
|
|
853
|
+
|
|
854
|
+
_RFE_KEYS_SORTED = sorted(_RFE_TO_IPA.keys(), key=len, reverse=True)
|
|
855
|
+
_RFE_RE = re.compile("|".join(re.escape(x) for x in _RFE_KEYS_SORTED))
|
|
856
|
+
_IPA_RFE_KEYS_SORTED = sorted(_IPA_TO_RFE.keys(), key=len, reverse=True)
|
|
857
|
+
_IPA_RFE_RE = re.compile("|".join(re.escape(x) for x in _IPA_RFE_KEYS_SORTED))
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
def rfe_to_ipa(rfe: str) -> str:
|
|
861
|
+
"""Convert an RFE (Revista de Filología Española) string to IPA.
|
|
862
|
+
|
|
863
|
+
Multi-character symbols are matched longest-first. Characters outside the
|
|
864
|
+
table pass through unchanged.
|
|
865
|
+
|
|
866
|
+
Examples
|
|
867
|
+
--------
|
|
868
|
+
>>> rfe_to_ipa("š")
|
|
869
|
+
'ʃ'
|
|
870
|
+
>>> rfe_to_ipa("kaša")
|
|
871
|
+
'kaʃa'
|
|
872
|
+
"""
|
|
873
|
+
result = []
|
|
874
|
+
pos = 0
|
|
875
|
+
while pos < len(rfe):
|
|
876
|
+
m = _RFE_RE.match(rfe, pos)
|
|
877
|
+
if m:
|
|
878
|
+
result.append(_RFE_TO_IPA[m.group(0)])
|
|
879
|
+
pos = m.end()
|
|
880
|
+
else:
|
|
881
|
+
result.append(rfe[pos])
|
|
882
|
+
pos += 1
|
|
883
|
+
return "".join(result)
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
def ipa_to_rfe(ipa: str) -> str:
|
|
887
|
+
"""Convert an IPA string to RFE (Revista de Filología Española) notation.
|
|
888
|
+
|
|
889
|
+
Multi-character IPA symbols are matched longest-first. Characters outside
|
|
890
|
+
the table pass through unchanged.
|
|
891
|
+
|
|
892
|
+
Examples
|
|
893
|
+
--------
|
|
894
|
+
>>> ipa_to_rfe("ʃ")
|
|
895
|
+
'š'
|
|
896
|
+
>>> ipa_to_rfe("ɲ")
|
|
897
|
+
'ñ'
|
|
898
|
+
"""
|
|
899
|
+
result = []
|
|
900
|
+
pos = 0
|
|
901
|
+
while pos < len(ipa):
|
|
902
|
+
m = _IPA_RFE_RE.match(ipa, pos)
|
|
903
|
+
if m:
|
|
904
|
+
result.append(_IPA_TO_RFE[m.group(0)])
|
|
905
|
+
pos = m.end()
|
|
906
|
+
else:
|
|
907
|
+
result.append(ipa[pos])
|
|
908
|
+
pos += 1
|
|
909
|
+
return "".join(result)
|
|
910
|
+
|
|
911
|
+
|
|
789
912
|
# ---------------------------------------------------------------------------
|
|
790
913
|
# convert — facade routing through IPA where no direct map exists
|
|
791
914
|
# ---------------------------------------------------------------------------
|
|
@@ -857,6 +980,7 @@ _TO_IPA: dict[Notation, "callable"] = {
|
|
|
857
980
|
Notation.LEXIQUE: lexique_to_ipa,
|
|
858
981
|
Notation.KIRSHENBAUM: kirshenbaum_to_ipa,
|
|
859
982
|
Notation.COTOVIA: cotovia_to_ipa,
|
|
983
|
+
Notation.RFE: rfe_to_ipa,
|
|
860
984
|
}
|
|
861
985
|
_FROM_IPA: dict[Notation, "callable"] = {
|
|
862
986
|
Notation.ARPA: ipa_to_arpa,
|
|
@@ -864,6 +988,7 @@ _FROM_IPA: dict[Notation, "callable"] = {
|
|
|
864
988
|
Notation.LEXIQUE: ipa_to_lexique,
|
|
865
989
|
Notation.KIRSHENBAUM: ipa_to_kirshenbaum,
|
|
866
990
|
Notation.COTOVIA: ipa_to_cotovia,
|
|
991
|
+
Notation.RFE: ipa_to_rfe,
|
|
867
992
|
}
|
|
868
993
|
_DIRECT_PAIRS: dict[tuple[Notation, Notation], "callable"] = {
|
|
869
994
|
(Notation.BUCKWALTER, Notation.ARABIC): buckwalter_to_arabic,
|
|
@@ -974,6 +1099,11 @@ NOTATION_INFO: dict[Notation, NotationInfo] = {
|
|
|
974
1099
|
token_separated=False,
|
|
975
1100
|
reference="Universidade de Vigo GTM Cotovía TTS (fonemas.cpp)",
|
|
976
1101
|
),
|
|
1102
|
+
Notation.RFE: NotationInfo(
|
|
1103
|
+
Notation.RFE, lossless_to_ipa=False, lossless_from_ipa=False,
|
|
1104
|
+
token_separated=False,
|
|
1105
|
+
reference="RFE phonetic alphabet (Revista de Filología Española, 1915)",
|
|
1106
|
+
),
|
|
977
1107
|
Notation.BUCKWALTER: NotationInfo(
|
|
978
1108
|
Notation.BUCKWALTER, lossless_to_ipa=True, lossless_from_ipa=False,
|
|
979
1109
|
token_separated=False,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptconv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2a2
|
|
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
|
|
@@ -33,7 +33,7 @@ Dynamic: license-file
|
|
|
33
33
|
|
|
34
34
|
**scriptconv** is a zero-dependency Python library for written-script operations:
|
|
35
35
|
ISO-15924 script identification and metadata, character-range detection, language-to-script
|
|
36
|
-
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía,
|
|
36
|
+
mapping, phoneme-notation transcoding (IPA ↔ ARPABET / X-SAMPA / Lexique / Kirshenbaum / Cotovía / RFE,
|
|
37
37
|
Buckwalter ↔ Arabic script), and orthographic decomposition of Hangul syllable blocks into
|
|
38
38
|
jamo letters. Every conversion is a pure data table or arithmetic operation; no linguistic
|
|
39
39
|
rules, no external files, no runtime dependencies beyond the Python standard library.
|
|
@@ -75,7 +75,8 @@ 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, cotovia_to_ipa, ipa_to_cotovia,
|
|
78
|
+
kirshenbaum_to_ipa, ipa_to_kirshenbaum, cotovia_to_ipa, ipa_to_cotovia,
|
|
79
|
+
rfe_to_ipa, ipa_to_rfe, looks_like_ipa,
|
|
79
80
|
decompose_hangul, hira_to_kana, kana_to_hira,
|
|
80
81
|
convert, can_convert, convert_batch, Notation, NOTATION_INFO,
|
|
81
82
|
)
|
|
@@ -110,6 +111,9 @@ ipa_to_kirshenbaum("ŋ") # "N"
|
|
|
110
111
|
cotovia_to_ipa("karro") # "karo" (Galician Cotovía TTS notation)
|
|
111
112
|
ipa_to_cotovia("ʎ") # "L"
|
|
112
113
|
|
|
114
|
+
rfe_to_ipa("kaša") # "kaʃa" (Spanish/Romance RFE alphabet)
|
|
115
|
+
ipa_to_rfe("ɲ") # "ñ"
|
|
116
|
+
|
|
113
117
|
looks_like_ipa("pʰɑtʃ") # True (heuristic: has IPA-distinctive symbols)
|
|
114
118
|
looks_like_ipa("hello") # False
|
|
115
119
|
|
|
@@ -142,7 +146,7 @@ python -m scriptconv lang ko
|
|
|
142
146
|
| Module | Contents |
|
|
143
147
|
|--------|----------|
|
|
144
148
|
| `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` |
|
|
145
|
-
| `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, Cotovía ↔ IPA), `looks_like_ipa` detector |
|
|
149
|
+
| `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, Cotovía ↔ IPA, RFE ↔ IPA), `looks_like_ipa` detector |
|
|
146
150
|
| `scriptconv.translit` | `decompose_hangul` (Hangul blocks → jamo, compatibility or conjoining), `hira_to_kana`/`kana_to_hira` — all orthographic only |
|
|
147
151
|
|
|
148
152
|
## Documentation
|
|
@@ -172,6 +176,7 @@ Runnable scripts in [examples/](examples/):
|
|
|
172
176
|
| `13_script_runs.py` | Per-script segmentation of mixed-script text |
|
|
173
177
|
| `14_kana_transliteration.py` | Hiragana ↔ Katakana |
|
|
174
178
|
| `15_cotovia.py` | Cotovía (Galician TTS notation) ↔ IPA |
|
|
179
|
+
| `16_rfe.py` | RFE (Spanish/Romance philology alphabet) ↔ IPA |
|
|
175
180
|
|
|
176
181
|
## Fidelity guarantees
|
|
177
182
|
|
|
@@ -187,6 +192,7 @@ round-trip is exact and what happens to a symbol the table does not know.
|
|
|
187
192
|
| **Lexique ↔ IPA** | Exact except the `°`/`3` schwa pair (both → `ə`; reverse always → `°`) | Exact | Passed through unchanged |
|
|
188
193
|
| **Kirshenbaum ↔ IPA** | Exact | **Lossy** — restricted ASCII inventory; IPA outside it passes through | Passed through unchanged |
|
|
189
194
|
| **Cotovía ↔ IPA** | Exact except the three `L`/`Z`/`jj` symbols for `ʎ` normalise to `L` | **Lossy** — Galician/Spanish inventory; IPA outside it passes through | Passed through unchanged |
|
|
195
|
+
| **RFE ↔ IPA** | Exact except `ñ`/`n̮` for `ɲ` normalise to `ñ` | **Lossy** — core Spanish/Romance inventory; IPA outside it passes through | Passed through unchanged |
|
|
190
196
|
|
|
191
197
|
This table is also available programmatically via `NOTATION_INFO`
|
|
192
198
|
(`NotationInfo` records with `lossless_to_ipa`, `lossless_from_ipa`,
|
|
@@ -213,4 +219,5 @@ Derived tables used internally:
|
|
|
213
219
|
| Lexique phoneme codes | New, B. & Pallier, C. — *Manuel de Lexique 3* v3.11, Tableau 2; [chrplr/openlexicon](https://github.com/chrplr/openlexicon) | CC BY-SA 4.0 |
|
|
214
220
|
| Kirshenbaum ↔ IPA | Kirshenbaum 1993 ASCII-IPA standard (comp.speech), cross-checked against espeak-ng | — (factual symbol mapping) |
|
|
215
221
|
| Cotovía ↔ IPA | Universidade de Vigo GTM Cotovía TTS project (`fonemas.cpp`) | — (factual symbol mapping) |
|
|
222
|
+
| RFE ↔ IPA | RFE phonetic alphabet (Revista de Filología Española, 1915) | — (factual symbol mapping) |
|
|
216
223
|
| Hangul jamo tables | [stannam/hangul_to_ipa](https://github.com/stannam/hangul_to_ipa) | — |
|
|
@@ -111,3 +111,9 @@ def test_15_cotovia():
|
|
|
111
111
|
r = _run(EXAMPLES_DIR / "15_cotovia.py")
|
|
112
112
|
assert r.returncode == 0, r.stderr
|
|
113
113
|
assert r.stdout.strip()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_16_rfe():
|
|
117
|
+
r = _run(EXAMPLES_DIR / "16_rfe.py")
|
|
118
|
+
assert r.returncode == 0, r.stderr
|
|
119
|
+
assert r.stdout.strip()
|
|
@@ -947,7 +947,7 @@ def test_notation_enum_values():
|
|
|
947
947
|
|
|
948
948
|
|
|
949
949
|
def test_notation_enum_count():
|
|
950
|
-
assert len(Notation) ==
|
|
950
|
+
assert len(Notation) == 9
|
|
951
951
|
|
|
952
952
|
|
|
953
953
|
def test_notation_str():
|
|
@@ -1108,3 +1108,43 @@ def test_cotovia_pause_marker_not_a_phoneme():
|
|
|
1108
1108
|
assert cotovia_to_ipa("#") == "#"
|
|
1109
1109
|
# p/a/u are ordinary phonemes, converted independently.
|
|
1110
1110
|
assert cotovia_to_ipa("pau") == "pau"
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
# ---------------------------------------------------------------------------
|
|
1114
|
+
# RFE (Revista de Filología Española) ↔ IPA
|
|
1115
|
+
# ---------------------------------------------------------------------------
|
|
1116
|
+
|
|
1117
|
+
from scriptconv.notation import rfe_to_ipa, ipa_to_rfe # noqa: E402
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
@pytest.mark.parametrize("rfe, ipa", [
|
|
1121
|
+
("š", "ʃ"), ("ž", "ʒ"), ("ĉ", "tʃ"), ("y", "ʝ"), ("ŷ", "ɟʝ"),
|
|
1122
|
+
("ñ", "ɲ"), ("n̮", "ɲ"), ("l̮", "ʎ"),
|
|
1123
|
+
("ƀ", "β"), ("đ", "ð"), ("ǥ", "ɣ"), ("θ", "θ"), ("ł", "ɫ"),
|
|
1124
|
+
("r", "ɾ"), ("r̄", "r"),
|
|
1125
|
+
("g", "ɡ"),
|
|
1126
|
+
("kaša", "kaʃa"),
|
|
1127
|
+
])
|
|
1128
|
+
def test_rfe_to_ipa(rfe, ipa):
|
|
1129
|
+
assert rfe_to_ipa(rfe) == ipa
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
@pytest.mark.parametrize("ipa, rfe", [
|
|
1133
|
+
("ʃ", "š"), ("ʒ", "ž"), ("tʃ", "ĉ"), ("ʝ", "y"),
|
|
1134
|
+
("ɲ", "ñ"), # canonical, not the n̮ variant
|
|
1135
|
+
("ʎ", "l̮"),
|
|
1136
|
+
("β", "ƀ"), ("ð", "đ"), ("ɣ", "ǥ"),
|
|
1137
|
+
("ɾ", "r"), ("r", "r̄"),
|
|
1138
|
+
])
|
|
1139
|
+
def test_ipa_to_rfe(ipa, rfe):
|
|
1140
|
+
assert ipa_to_rfe(ipa) == rfe
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
def test_rfe_tap_trill_round_trip():
|
|
1144
|
+
assert ipa_to_rfe(rfe_to_ipa("far̄a")) == "far̄a" # trill
|
|
1145
|
+
assert ipa_to_rfe(rfe_to_ipa("kara")) == "kara" # tap
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
def test_convert_routes_through_rfe():
|
|
1149
|
+
assert convert("š", "rfe", "x-sampa") == "S"
|
|
1150
|
+
assert convert("ʃ", "ipa", "rfe") == "š"
|
|
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
|