euskaphone 0.1.0a2__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 (54) hide show
  1. euskaphone-0.1.0a2/LICENSE +204 -0
  2. euskaphone-0.1.0a2/PKG-INFO +220 -0
  3. euskaphone-0.1.0a2/README.md +187 -0
  4. euskaphone-0.1.0a2/euskaphone/__init__.py +122 -0
  5. euskaphone-0.1.0a2/euskaphone/abbreviations.py +87 -0
  6. euskaphone-0.1.0a2/euskaphone/accent.py +181 -0
  7. euskaphone-0.1.0a2/euskaphone/codeswitch.py +316 -0
  8. euskaphone-0.1.0a2/euskaphone/data/abbreviations.tsv +35 -0
  9. euskaphone-0.1.0a2/euskaphone/data/langdetect/en.json.gz +0 -0
  10. euskaphone-0.1.0a2/euskaphone/data/langdetect/es.json.gz +0 -0
  11. euskaphone-0.1.0a2/euskaphone/data/langdetect/eu.json.gz +0 -0
  12. euskaphone-0.1.0a2/euskaphone/data/langdetect/fr.json.gz +0 -0
  13. euskaphone-0.1.0a2/euskaphone/data/lexicons/eu_hitz_overlay.tsv +40 -0
  14. euskaphone-0.1.0a2/euskaphone/data/lexicons/eu_toponyms.tsv +129 -0
  15. euskaphone-0.1.0a2/euskaphone/data/pitch_accent/northern_bizkaian.tsv +15 -0
  16. euskaphone-0.1.0a2/euskaphone/data/units.tsv +25 -0
  17. euskaphone-0.1.0a2/euskaphone/dates.py +128 -0
  18. euskaphone-0.1.0a2/euskaphone/langdetect.py +183 -0
  19. euskaphone-0.1.0a2/euskaphone/lattice_core.py +128 -0
  20. euskaphone-0.1.0a2/euskaphone/lexicons.py +115 -0
  21. euskaphone-0.1.0a2/euskaphone/normalize.py +49 -0
  22. euskaphone-0.1.0a2/euskaphone/number_utils.py +290 -0
  23. euskaphone-0.1.0a2/euskaphone/numverbal.py +67 -0
  24. euskaphone-0.1.0a2/euskaphone/pitch_accent.py +210 -0
  25. euskaphone-0.1.0a2/euskaphone/plugin.py +44 -0
  26. euskaphone-0.1.0a2/euskaphone/registry.py +169 -0
  27. euskaphone-0.1.0a2/euskaphone/romans.py +158 -0
  28. euskaphone-0.1.0a2/euskaphone/units.py +144 -0
  29. euskaphone-0.1.0a2/euskaphone/version.py +10 -0
  30. euskaphone-0.1.0a2/euskaphone.egg-info/PKG-INFO +220 -0
  31. euskaphone-0.1.0a2/euskaphone.egg-info/SOURCES.txt +52 -0
  32. euskaphone-0.1.0a2/euskaphone.egg-info/dependency_links.txt +1 -0
  33. euskaphone-0.1.0a2/euskaphone.egg-info/entry_points.txt +2 -0
  34. euskaphone-0.1.0a2/euskaphone.egg-info/requires.txt +10 -0
  35. euskaphone-0.1.0a2/euskaphone.egg-info/top_level.txt +1 -0
  36. euskaphone-0.1.0a2/pyproject.toml +63 -0
  37. euskaphone-0.1.0a2/setup.cfg +4 -0
  38. euskaphone-0.1.0a2/tests/test_abbreviations.py +58 -0
  39. euskaphone-0.1.0a2/tests/test_accent.py +77 -0
  40. euskaphone-0.1.0a2/tests/test_codeswitch.py +141 -0
  41. euskaphone-0.1.0a2/tests/test_dates.py +62 -0
  42. euskaphone-0.1.0a2/tests/test_examples.py +15 -0
  43. euskaphone-0.1.0a2/tests/test_gold.py +61 -0
  44. euskaphone-0.1.0a2/tests/test_langdetect.py +119 -0
  45. euskaphone-0.1.0a2/tests/test_lexicons.py +87 -0
  46. euskaphone-0.1.0a2/tests/test_negation_sandhi.py +71 -0
  47. euskaphone-0.1.0a2/tests/test_normalize.py +67 -0
  48. euskaphone-0.1.0a2/tests/test_number_utils.py +155 -0
  49. euskaphone-0.1.0a2/tests/test_package.py +35 -0
  50. euskaphone-0.1.0a2/tests/test_pitch_accent.py +101 -0
  51. euskaphone-0.1.0a2/tests/test_plugin.py +35 -0
  52. euskaphone-0.1.0a2/tests/test_registry.py +59 -0
  53. euskaphone-0.1.0a2/tests/test_romans.py +85 -0
  54. euskaphone-0.1.0a2/tests/test_units.py +89 -0
@@ -0,0 +1,204 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2021 Casimiro Ferreira
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ =======================================================================
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: euskaphone
3
+ Version: 0.1.0a2
4
+ Summary: Dialect-aware Basque (Euskara) text-to-IPA phonemizer over the orthography2ipa lattice
5
+ Author-email: JarbasAi <jarbasai@mailfence.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/TigreGotico/euskaphone
8
+ Project-URL: Repository, https://github.com/TigreGotico/euskaphone
9
+ Keywords: basque,euskara,phonemizer,g2p,ipa,phonetics,tts,nlp
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Natural Language :: Basque
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Text Processing :: Linguistic
20
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: orthography2ipa>=7.28.0a1
25
+ Requires-Dist: ovos-number-parser>=0.6.0a1
26
+ Provides-Extra: langdetect
27
+ Requires-Dist: markovonnx>=1.0.1; extra == "langdetect"
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest; extra == "test"
30
+ Requires-Dist: pytest-cov; extra == "test"
31
+ Requires-Dist: markovonnx>=1.0.1; extra == "test"
32
+ Dynamic: license-file
33
+
34
+ # euskaphone
35
+
36
+ Dialect-aware Basque (Euskara) text-to-IPA phonemizer — a TTS frontend built on
37
+ the shared [orthography2ipa](https://github.com/TigreGotico/orthography2ipa)
38
+ pronunciation lattice. euskaphone is the Basque sibling of
39
+ [tugaphone](https://github.com/TigreGotico/tugaphone) (Portuguese) and
40
+ [mwl_phonemizer](https://github.com/TigreGotico/mwl_phonemizer) (Mirandese), and
41
+ is offered to the Basque research and speech-technology community as an open,
42
+ inspectable, source-cited pipeline.
43
+
44
+ A dialect *is* an orthography2ipa Basque lect spec: the spec's grapheme table,
45
+ allophony and cross-word sandhi produce the dialect's phonology directly — the
46
+ apical/laminal sibilant contrast, the affricates, Souletin aspiration and `/y/`.
47
+ euskaphone adds only the stages orthography2ipa leaves to the caller.
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install euskaphone
53
+ ```
54
+
55
+ ## Quickstart
56
+
57
+ ```python
58
+ from euskaphone import EuskaPhonemizer
59
+
60
+ ph = EuskaPhonemizer()
61
+ ph.phonemize_sentence("Zazpi katu zuri ikusi ditut.") # Batua (default)
62
+ # 's̻as̻pi katu s̻uɾi ikus̺i ditut'
63
+
64
+ ph.phonemize_sentence("Hotza egiten du gaur mendian.", "souletin")
65
+ # 'hots̻a eɡiten dy ɡauɾ mendian' (Souletin: aspiration, /y/)
66
+ ```
67
+
68
+ ## Dialects
69
+
70
+ Eight lects, selectable by BCP-47 code or by a human-readable alias:
71
+
72
+ | code | dialect | aliases |
73
+ |------|---------|---------|
74
+ | `eu` | Standard Basque | `batua`, `standard` |
75
+ | `eu-x-bizkaiera` | Biscayan | `biscayan`, `western` |
76
+ | `eu-x-gipuzkera` | Gipuzkoan | `guipuzcoan`, `central` |
77
+ | `eu-x-lapurtera` | Lapurdian | `labourdin` |
78
+ | `eu-x-nafarra-garaia` | High Navarrese | `high-navarrese` |
79
+ | `eu-x-nafarra-beherea` | Low Navarrese | `low-navarrese` |
80
+ | `eu-x-zuberera` | Souletin | `souletin`, `xiberotarra` |
81
+ | `eu-x-erronkariera` | Roncalese (†) | `roncalese` |
82
+
83
+ ## The three things euskaphone adds
84
+
85
+ ### 1. Vigesimal number normalization (the flagship)
86
+
87
+ Basque cardinals are **base-20**: `hogei` (20), `berrogei` (40 = 2×20),
88
+ `hirurogei` (60), `laurogei` (80); 30/50/70/90 are the preceding twenty *plus
89
+ ten*; and the copulative `eta` ("and") contracts to `-ta` on the twenties.
90
+
91
+ ```python
92
+ from euskaphone.number_utils import BasqueNumberParser, normalize_numbers
93
+
94
+ p = BasqueNumberParser("eu")
95
+ p.cardinal(31) # 'hogeita hamaika' (20-and-11)
96
+ p.cardinal(1936) # 'mila bederatziehun eta hogeita hamasei'
97
+ p.ordinal(16) # 'hamaseigarren'
98
+
99
+ # case-suffixed numerals and clock time in running text (declension on the
100
+ # last element of the numeral phrase)
101
+ normalize_numbers("1936ko gerra", "eu") # '… hogeita hamaseiko gerra'
102
+ normalize_numbers("20:00etan", "eu") # 'hogeietan'
103
+ ```
104
+
105
+ Every base form is cited to **Euskaltzaindia Araua 7** (cardinals) and
106
+ **Araua 18** (ordinals), and each is tagged attested-in-source vs derived-by-rule
107
+ in `euskaphone.number_utils` (the `ATTESTED` / `DERIVED` sets). One notable
108
+ correction the sources force: Araua 7 records `bost` (not `bortz`) for Zuberoa
109
+ and most of Low Navarre, so euskaphone keeps `bost` everywhere by default and
110
+ offers the `bortz` series only for Lapurdian — null beats a wrong dialect swap.
111
+ See [`docs/numbers.md`](docs/numbers.md).
112
+
113
+ ### 2. Code-switch handling
114
+
115
+ Real Basque text embeds Spanish (Hegoalde), French (Iparralde) and — in the
116
+ tech/music/media register — English. Word-level detection identifies the embedded
117
+ material, classifies each contact word **per word** among `es`/`fr`/`en`, routes
118
+ it through the orthography2ipa `es-ES`/`fr-FR`/`en-US` lattice, and **nativizes**
119
+ the result onto the Basque inventory (project every foreign phone onto its
120
+ nearest Basque phone — never drop, always project). The `contact` parameter is
121
+ `auto` (per-word detection), `es`, `fr`, `en`, or `none`.
122
+
123
+ Detection prefers a small bundled **char-Markov language detector** (Basque /
124
+ Spanish / French / English, ~180 KB total, scored by `markovonnx`; install with
125
+ `euskaphone[langdetect]`) and falls back to an orthographic heuristic when the
126
+ models are unavailable. Basque is the in-language default: a word is routed out
127
+ of Basque only when a foreign model beats the Basque model by a clear margin (and
128
+ short, plausibly-native words need orthographic corroboration), so a weak signal
129
+ never misroutes a native word.
130
+
131
+ ```python
132
+ ph.phonemize_sentence("Madrilen Plaza Mayor ikusi dut.", "eu")
133
+ # '… plas̻a majoɾ …' (Spanish routed + nativized: no θ, no stress)
134
+
135
+ ph.phonemize_sentence("Streaming plataforma berria erabili dugu.")
136
+ # 'strimin platafoɾma …' (English routed + nativized onto the 5-vowel system)
137
+
138
+ ph.phonemize_sentence("Maison Rouge etxean.", "souletin")
139
+ # continental dialect → French contact by default
140
+ ```
141
+
142
+ See [`docs/codeswitch.md`](docs/codeswitch.md).
143
+
144
+ ### 3. Lexicon hook + shipped lexicons
145
+
146
+ `register_lexicon(dialect, source)` registers a proper-name/loan pronunciation
147
+ table (the orthography2ipa lexicon contract: a `word<TAB>ipa` path, URL or
148
+ `hf://` id); a covered word bypasses the lattice.
149
+
150
+ Two lexicons ship built-in: a curated **Euskaltzaindia toponym seed** (on by
151
+ default, `EuskaPhonemizer(toponyms=False)` to opt out) and an opt-in **HiTZ
152
+ proper-noun overlay** (`EuskaPhonemizer(lexicon="hitz")`) that carries a
153
+ benchmark circularity caveat. A caller's own lexicon always wins.
154
+ See [`docs/lexicons.md`](docs/lexicons.md).
155
+
156
+ ### 4. Orthographic normalization
157
+
158
+ Before the lattice runs, everything written as a symbol, abbreviation, Roman
159
+ numeral or numeric date is spelled into Basque words
160
+ (`euskaphone.normalize.normalize_text`, wired in as the orthography2ipa
161
+ `normalize` stage):
162
+
163
+ ```python
164
+ from euskaphone.normalize import normalize_text
165
+
166
+ normalize_text("XX. mendean %20 igo da", "eu")
167
+ # 'hogeigarren mendean ehuneko hogei igo da'
168
+ normalize_text("Luis XIV.a errege zen", "eu") # '… hamalaugarrena …'
169
+ normalize_text("Sarrera €5eko da", "eu") # '… bost euroko …'
170
+ normalize_text("15/01/2024", "eu") # 'bi mila eta hogeita lauko urtarrilaren hamabostean'
171
+ ```
172
+
173
+ Roman-numeral ordinals (`XX.` → `hogeigarren`) and monarch numerals
174
+ (`Luis XIV.a` → `hamalaugarrena`), a cited abbreviation list
175
+ (`etab.` → `eta abar`), unit/currency/percent symbols with Basque word order and
176
+ declension (`%5` and `5%` both → `ehuneko bost`), and numeric dates — each cited
177
+ to Euskaltzaindia (Araua 18/37/196/197) and the EIMA *Ortotipografia* guide. The
178
+ abbreviation and unit tables are expandable data files
179
+ (`euskaphone/data/*.tsv`). See [`docs/normalization.md`](docs/normalization.md).
180
+
181
+ ### No homograph subsystem — by design
182
+
183
+ Basque orthography is near-phonemic: a grapheme's reading is essentially fixed
184
+ and sense-independent. Unlike tugaphone's Portuguese (which needs `bifonia` to
185
+ resolve heterophonic homographs), euskaphone deliberately ships **no** homograph
186
+ stage. This is a scope decision, documented so it is not mistaken for a gap.
187
+
188
+ ## OVOS plugin
189
+
190
+ ```python
191
+ from euskaphone.plugin import EuskaphoneG2PPlugin
192
+ EuskaphoneG2PPlugin("souletin").transcribe("kaixo mundua")
193
+ ```
194
+
195
+ Registered under the `opm.g2p` entry-point group as `euskaphone`.
196
+
197
+ ## How it measures up
198
+
199
+ euskaphone drives the shared orthography2ipa lattice, so it is only as accurate
200
+ as that lattice — these numbers measure the lattice, honestly labelled. Run them
201
+ with `python scripts/benchmark.py [--hitz]`.
202
+
203
+ | gold | kind | figure |
204
+ |------|------|--------|
205
+ | orthography2ipa eu gold (166 rows, 8 lects) | **regression fixture** (same lattice made it) | PER `0.0000` — proves the lattice is untouched, *not* accuracy |
206
+ | [WikiPron](https://github.com/CUNY-CL/wikipron) `eus_latn` broad | independent word gold | PER `0.0749`, word-acc `0.4563` (full set, 20,115 words) |
207
+ | [HiTZ/EHU](https://huggingface.co/datasets/HiTZ/wikipedia_basque_ipa) Wikipedia G2P | independent cross-engine (Univ. of the Basque Country) | PER `0.1384` folded (3k-sentence sample) |
208
+
209
+ The WikiPron and HiTZ figures are the honest ones: a pure lattice with no
210
+ lexicon, on proper-name-heavy and raw-Wikipedia text, where transcription
211
+ conventions and multiple valid pronunciations account for much of the gap. That
212
+ gap is exactly what the lexicon hook exists to close. Comparable open tools:
213
+ **AhoTTS** (the EHU TTS front end) covers Standard Batua only; **espeak-ng**'s
214
+ `eu` voice is single-dialect and rule-thin — euskaphone's contribution is the
215
+ eight-lect coverage, the sourced vigesimal numerals, and the code-switch
216
+ nativization, over a lattice shared across the whole Iberian family.
217
+
218
+ ## License
219
+
220
+ Apache-2.0.
@@ -0,0 +1,187 @@
1
+ # euskaphone
2
+
3
+ Dialect-aware Basque (Euskara) text-to-IPA phonemizer — a TTS frontend built on
4
+ the shared [orthography2ipa](https://github.com/TigreGotico/orthography2ipa)
5
+ pronunciation lattice. euskaphone is the Basque sibling of
6
+ [tugaphone](https://github.com/TigreGotico/tugaphone) (Portuguese) and
7
+ [mwl_phonemizer](https://github.com/TigreGotico/mwl_phonemizer) (Mirandese), and
8
+ is offered to the Basque research and speech-technology community as an open,
9
+ inspectable, source-cited pipeline.
10
+
11
+ A dialect *is* an orthography2ipa Basque lect spec: the spec's grapheme table,
12
+ allophony and cross-word sandhi produce the dialect's phonology directly — the
13
+ apical/laminal sibilant contrast, the affricates, Souletin aspiration and `/y/`.
14
+ euskaphone adds only the stages orthography2ipa leaves to the caller.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install euskaphone
20
+ ```
21
+
22
+ ## Quickstart
23
+
24
+ ```python
25
+ from euskaphone import EuskaPhonemizer
26
+
27
+ ph = EuskaPhonemizer()
28
+ ph.phonemize_sentence("Zazpi katu zuri ikusi ditut.") # Batua (default)
29
+ # 's̻as̻pi katu s̻uɾi ikus̺i ditut'
30
+
31
+ ph.phonemize_sentence("Hotza egiten du gaur mendian.", "souletin")
32
+ # 'hots̻a eɡiten dy ɡauɾ mendian' (Souletin: aspiration, /y/)
33
+ ```
34
+
35
+ ## Dialects
36
+
37
+ Eight lects, selectable by BCP-47 code or by a human-readable alias:
38
+
39
+ | code | dialect | aliases |
40
+ |------|---------|---------|
41
+ | `eu` | Standard Basque | `batua`, `standard` |
42
+ | `eu-x-bizkaiera` | Biscayan | `biscayan`, `western` |
43
+ | `eu-x-gipuzkera` | Gipuzkoan | `guipuzcoan`, `central` |
44
+ | `eu-x-lapurtera` | Lapurdian | `labourdin` |
45
+ | `eu-x-nafarra-garaia` | High Navarrese | `high-navarrese` |
46
+ | `eu-x-nafarra-beherea` | Low Navarrese | `low-navarrese` |
47
+ | `eu-x-zuberera` | Souletin | `souletin`, `xiberotarra` |
48
+ | `eu-x-erronkariera` | Roncalese (†) | `roncalese` |
49
+
50
+ ## The three things euskaphone adds
51
+
52
+ ### 1. Vigesimal number normalization (the flagship)
53
+
54
+ Basque cardinals are **base-20**: `hogei` (20), `berrogei` (40 = 2×20),
55
+ `hirurogei` (60), `laurogei` (80); 30/50/70/90 are the preceding twenty *plus
56
+ ten*; and the copulative `eta` ("and") contracts to `-ta` on the twenties.
57
+
58
+ ```python
59
+ from euskaphone.number_utils import BasqueNumberParser, normalize_numbers
60
+
61
+ p = BasqueNumberParser("eu")
62
+ p.cardinal(31) # 'hogeita hamaika' (20-and-11)
63
+ p.cardinal(1936) # 'mila bederatziehun eta hogeita hamasei'
64
+ p.ordinal(16) # 'hamaseigarren'
65
+
66
+ # case-suffixed numerals and clock time in running text (declension on the
67
+ # last element of the numeral phrase)
68
+ normalize_numbers("1936ko gerra", "eu") # '… hogeita hamaseiko gerra'
69
+ normalize_numbers("20:00etan", "eu") # 'hogeietan'
70
+ ```
71
+
72
+ Every base form is cited to **Euskaltzaindia Araua 7** (cardinals) and
73
+ **Araua 18** (ordinals), and each is tagged attested-in-source vs derived-by-rule
74
+ in `euskaphone.number_utils` (the `ATTESTED` / `DERIVED` sets). One notable
75
+ correction the sources force: Araua 7 records `bost` (not `bortz`) for Zuberoa
76
+ and most of Low Navarre, so euskaphone keeps `bost` everywhere by default and
77
+ offers the `bortz` series only for Lapurdian — null beats a wrong dialect swap.
78
+ See [`docs/numbers.md`](docs/numbers.md).
79
+
80
+ ### 2. Code-switch handling
81
+
82
+ Real Basque text embeds Spanish (Hegoalde), French (Iparralde) and — in the
83
+ tech/music/media register — English. Word-level detection identifies the embedded
84
+ material, classifies each contact word **per word** among `es`/`fr`/`en`, routes
85
+ it through the orthography2ipa `es-ES`/`fr-FR`/`en-US` lattice, and **nativizes**
86
+ the result onto the Basque inventory (project every foreign phone onto its
87
+ nearest Basque phone — never drop, always project). The `contact` parameter is
88
+ `auto` (per-word detection), `es`, `fr`, `en`, or `none`.
89
+
90
+ Detection prefers a small bundled **char-Markov language detector** (Basque /
91
+ Spanish / French / English, ~180 KB total, scored by `markovonnx`; install with
92
+ `euskaphone[langdetect]`) and falls back to an orthographic heuristic when the
93
+ models are unavailable. Basque is the in-language default: a word is routed out
94
+ of Basque only when a foreign model beats the Basque model by a clear margin (and
95
+ short, plausibly-native words need orthographic corroboration), so a weak signal
96
+ never misroutes a native word.
97
+
98
+ ```python
99
+ ph.phonemize_sentence("Madrilen Plaza Mayor ikusi dut.", "eu")
100
+ # '… plas̻a majoɾ …' (Spanish routed + nativized: no θ, no stress)
101
+
102
+ ph.phonemize_sentence("Streaming plataforma berria erabili dugu.")
103
+ # 'strimin platafoɾma …' (English routed + nativized onto the 5-vowel system)
104
+
105
+ ph.phonemize_sentence("Maison Rouge etxean.", "souletin")
106
+ # continental dialect → French contact by default
107
+ ```
108
+
109
+ See [`docs/codeswitch.md`](docs/codeswitch.md).
110
+
111
+ ### 3. Lexicon hook + shipped lexicons
112
+
113
+ `register_lexicon(dialect, source)` registers a proper-name/loan pronunciation
114
+ table (the orthography2ipa lexicon contract: a `word<TAB>ipa` path, URL or
115
+ `hf://` id); a covered word bypasses the lattice.
116
+
117
+ Two lexicons ship built-in: a curated **Euskaltzaindia toponym seed** (on by
118
+ default, `EuskaPhonemizer(toponyms=False)` to opt out) and an opt-in **HiTZ
119
+ proper-noun overlay** (`EuskaPhonemizer(lexicon="hitz")`) that carries a
120
+ benchmark circularity caveat. A caller's own lexicon always wins.
121
+ See [`docs/lexicons.md`](docs/lexicons.md).
122
+
123
+ ### 4. Orthographic normalization
124
+
125
+ Before the lattice runs, everything written as a symbol, abbreviation, Roman
126
+ numeral or numeric date is spelled into Basque words
127
+ (`euskaphone.normalize.normalize_text`, wired in as the orthography2ipa
128
+ `normalize` stage):
129
+
130
+ ```python
131
+ from euskaphone.normalize import normalize_text
132
+
133
+ normalize_text("XX. mendean %20 igo da", "eu")
134
+ # 'hogeigarren mendean ehuneko hogei igo da'
135
+ normalize_text("Luis XIV.a errege zen", "eu") # '… hamalaugarrena …'
136
+ normalize_text("Sarrera €5eko da", "eu") # '… bost euroko …'
137
+ normalize_text("15/01/2024", "eu") # 'bi mila eta hogeita lauko urtarrilaren hamabostean'
138
+ ```
139
+
140
+ Roman-numeral ordinals (`XX.` → `hogeigarren`) and monarch numerals
141
+ (`Luis XIV.a` → `hamalaugarrena`), a cited abbreviation list
142
+ (`etab.` → `eta abar`), unit/currency/percent symbols with Basque word order and
143
+ declension (`%5` and `5%` both → `ehuneko bost`), and numeric dates — each cited
144
+ to Euskaltzaindia (Araua 18/37/196/197) and the EIMA *Ortotipografia* guide. The
145
+ abbreviation and unit tables are expandable data files
146
+ (`euskaphone/data/*.tsv`). See [`docs/normalization.md`](docs/normalization.md).
147
+
148
+ ### No homograph subsystem — by design
149
+
150
+ Basque orthography is near-phonemic: a grapheme's reading is essentially fixed
151
+ and sense-independent. Unlike tugaphone's Portuguese (which needs `bifonia` to
152
+ resolve heterophonic homographs), euskaphone deliberately ships **no** homograph
153
+ stage. This is a scope decision, documented so it is not mistaken for a gap.
154
+
155
+ ## OVOS plugin
156
+
157
+ ```python
158
+ from euskaphone.plugin import EuskaphoneG2PPlugin
159
+ EuskaphoneG2PPlugin("souletin").transcribe("kaixo mundua")
160
+ ```
161
+
162
+ Registered under the `opm.g2p` entry-point group as `euskaphone`.
163
+
164
+ ## How it measures up
165
+
166
+ euskaphone drives the shared orthography2ipa lattice, so it is only as accurate
167
+ as that lattice — these numbers measure the lattice, honestly labelled. Run them
168
+ with `python scripts/benchmark.py [--hitz]`.
169
+
170
+ | gold | kind | figure |
171
+ |------|------|--------|
172
+ | orthography2ipa eu gold (166 rows, 8 lects) | **regression fixture** (same lattice made it) | PER `0.0000` — proves the lattice is untouched, *not* accuracy |
173
+ | [WikiPron](https://github.com/CUNY-CL/wikipron) `eus_latn` broad | independent word gold | PER `0.0749`, word-acc `0.4563` (full set, 20,115 words) |
174
+ | [HiTZ/EHU](https://huggingface.co/datasets/HiTZ/wikipedia_basque_ipa) Wikipedia G2P | independent cross-engine (Univ. of the Basque Country) | PER `0.1384` folded (3k-sentence sample) |
175
+
176
+ The WikiPron and HiTZ figures are the honest ones: a pure lattice with no
177
+ lexicon, on proper-name-heavy and raw-Wikipedia text, where transcription
178
+ conventions and multiple valid pronunciations account for much of the gap. That
179
+ gap is exactly what the lexicon hook exists to close. Comparable open tools:
180
+ **AhoTTS** (the EHU TTS front end) covers Standard Batua only; **espeak-ng**'s
181
+ `eu` voice is single-dialect and rule-thin — euskaphone's contribution is the
182
+ eight-lect coverage, the sourced vigesimal numerals, and the code-switch
183
+ nativization, over a lattice shared across the whole Iberian family.
184
+
185
+ ## License
186
+
187
+ Apache-2.0.