PyHakka 0.1.0__py3-none-any.whl
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.
- pyhakka/__init__.py +72 -0
- pyhakka/_db.py +80 -0
- pyhakka/cli.py +293 -0
- pyhakka/data/hakka.sqlite3 +4 -0
- pyhakka/data/manifest.json +106 -0
- pyhakka/dialects.py +163 -0
- pyhakka/lexicon/__init__.py +22 -0
- pyhakka/lexicon/db.py +25 -0
- pyhakka/lexicon/query.py +385 -0
- pyhakka/phon/__init__.py +26 -0
- pyhakka/phon/converter.py +256 -0
- pyhakka/phon/parser.py +748 -0
- pyhakka/phon/schemes.py +319 -0
- pyhakka/phon/syllable.py +164 -0
- pyhakka/phon/validate.py +79 -0
- pyhakka/py.typed +0 -0
- pyhakka/sandhi/__init__.py +17 -0
- pyhakka/sandhi/rules.py +369 -0
- pyhakka-0.1.0.dist-info/METADATA +40 -0
- pyhakka-0.1.0.dist-info/RECORD +24 -0
- pyhakka-0.1.0.dist-info/WHEEL +5 -0
- pyhakka-0.1.0.dist-info/entry_points.txt +2 -0
- pyhakka-0.1.0.dist-info/licenses/LICENSE +29 -0
- pyhakka-0.1.0.dist-info/top_level.txt +1 -0
pyhakka/sandhi/rules.py
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"""Tone sandhi and progressive segmental assimilation rules for Hakka varieties.
|
|
2
|
+
|
|
3
|
+
Each rule set is grounded in published dialectological descriptions (see
|
|
4
|
+
`docs/sandhi-rules.md` for full academic references).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from collections.abc import Sequence
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
from pyhakka.dialects import DEFAULT_DIALECT, get_dialect
|
|
13
|
+
from pyhakka.phon.parser import parse_syllables
|
|
14
|
+
from pyhakka.phon.syllable import Syllable
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class SandhiChange:
|
|
19
|
+
"""Audit record of a single sandhi/assimilation mutation."""
|
|
20
|
+
|
|
21
|
+
index: int
|
|
22
|
+
char: str
|
|
23
|
+
before: str
|
|
24
|
+
after: str
|
|
25
|
+
rule: str
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class SandhiResult:
|
|
30
|
+
"""Result of applying tone sandhi / assimilation to a sequence of syllables."""
|
|
31
|
+
|
|
32
|
+
syllables: tuple[Syllable, ...]
|
|
33
|
+
changes: tuple[SandhiChange, ...]
|
|
34
|
+
dialect: str
|
|
35
|
+
profile: str
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def hps_ext(self) -> str:
|
|
39
|
+
return " ".join(s.hps_ext for s in self.syllables)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Progressive coda-to-onset assimilation map for Wuhua suffix 哩 (朱炳玉 2010:35-36)
|
|
43
|
+
_WUHUA_LI_ASSIM: dict[str, str] = {
|
|
44
|
+
"m": "m",
|
|
45
|
+
"n": "n",
|
|
46
|
+
"ng": "ng",
|
|
47
|
+
"b": "b",
|
|
48
|
+
"d": "d",
|
|
49
|
+
"g": "g",
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_WUHUA_PRONOUN_PREFIXES = frozenset({"樣", "样", "咹", "咁", "般"})
|
|
53
|
+
|
|
54
|
+
SUPPORTED_SANDHI: dict[str, tuple[str, ...]] = {
|
|
55
|
+
"meixian": ("standard", "traditional"),
|
|
56
|
+
"wuhua": ("standard",),
|
|
57
|
+
"changting": ("standard", "rao"),
|
|
58
|
+
"mcp:臺灣四縣腔": ("standard",),
|
|
59
|
+
"mcp:臺灣南四縣腔": ("standard",),
|
|
60
|
+
"mcp:臺灣海陸腔": ("standard",),
|
|
61
|
+
"dabu-baihou": ("standard",),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def list_sandhi_dialects() -> dict[str, tuple[str, ...]]:
|
|
66
|
+
"""Return mapping of canonical dialect slug -> supported sandhi profile names."""
|
|
67
|
+
return dict(SUPPORTED_SANDHI)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _apply_meixian(
|
|
71
|
+
syls: list[Syllable],
|
|
72
|
+
chars: list[str],
|
|
73
|
+
profile: str,
|
|
74
|
+
) -> tuple[list[Syllable], list[SandhiChange]]:
|
|
75
|
+
out = list(syls)
|
|
76
|
+
changes: list[SandhiChange] = []
|
|
77
|
+
n = len(out)
|
|
78
|
+
for i in range(n - 1):
|
|
79
|
+
cur = out[i]
|
|
80
|
+
nxt = out[i + 1]
|
|
81
|
+
# 張維耿 (2020): 陰平(44) + 陽平(11)/上聲(31)/陰入(1) -> 陰平尾音微升 45
|
|
82
|
+
if cur.tone == "1" and nxt.tone in ("2", "3", "7"):
|
|
83
|
+
updated = cur.with_tone_value("45", tone="1")
|
|
84
|
+
out[i] = updated
|
|
85
|
+
changes.append(
|
|
86
|
+
SandhiChange(
|
|
87
|
+
index=i,
|
|
88
|
+
char=chars[i] if i < len(chars) else "",
|
|
89
|
+
before=f"{cur.hps_ext}[{cur.tone_value or '44'}]",
|
|
90
|
+
after=f"{updated.hps_ext}[45]",
|
|
91
|
+
rule="meixian:yinping_44_to_45_before_low_onset",
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
# 傳統梅縣變調 (黃雪貞 1995): 去聲(52) + 陰平(44)/去聲(52)/陽入(5) -> 55
|
|
95
|
+
elif profile == "traditional" and cur.tone == "5" and nxt.tone in ("1", "5", "8"):
|
|
96
|
+
updated = cur.with_tone_value("55", tone="5")
|
|
97
|
+
out[i] = updated
|
|
98
|
+
changes.append(
|
|
99
|
+
SandhiChange(
|
|
100
|
+
index=i,
|
|
101
|
+
char=chars[i] if i < len(chars) else "",
|
|
102
|
+
before=f"{cur.hps_ext}[{cur.tone_value or '52'}]",
|
|
103
|
+
after=f"{updated.hps_ext}[55]",
|
|
104
|
+
rule="meixian:qusheng_52_to_55_before_high_onset",
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
return out, changes
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _apply_wuhua(
|
|
111
|
+
syls: list[Syllable],
|
|
112
|
+
chars: list[str],
|
|
113
|
+
profile: str,
|
|
114
|
+
) -> tuple[list[Syllable], list[SandhiChange]]:
|
|
115
|
+
"""朱炳玉《五華客家話研究》(2010) 頁 35–36:詞綴「哩」順同化與變調。"""
|
|
116
|
+
del profile
|
|
117
|
+
out = list(syls)
|
|
118
|
+
changes: list[SandhiChange] = []
|
|
119
|
+
n = len(out)
|
|
120
|
+
for i in range(1, n):
|
|
121
|
+
cur = out[i]
|
|
122
|
+
ch = chars[i] if i < len(chars) else ""
|
|
123
|
+
prev = out[i - 1]
|
|
124
|
+
prev_ch = chars[i - 1] if (i - 1) < len(chars) else ""
|
|
125
|
+
|
|
126
|
+
# Match suffix 哩 (either by character `哩` or by phonological form `li3` when chars omitted)
|
|
127
|
+
is_li_suffix = (ch == "哩") or (not chars and cur.onset == "l" and cur.final == "i" and cur.tone == "3")
|
|
128
|
+
if not is_li_suffix:
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
updated = cur
|
|
132
|
+
applied: list[str] = []
|
|
133
|
+
|
|
134
|
+
# 1. Progressive coda-to-onset assimilation: -m/-n/-ng/-b/-d/-g -> m/n/ng/b/d/g
|
|
135
|
+
new_onset = _WUHUA_LI_ASSIM.get(prev.coda)
|
|
136
|
+
if new_onset and updated.onset == "l":
|
|
137
|
+
updated = updated.with_onset(new_onset)
|
|
138
|
+
applied.append(f"wuhua:li_assim_{prev.coda}_to_{new_onset}")
|
|
139
|
+
elif prev.is_syllabic_consonant and prev.nucleus in _WUHUA_LI_ASSIM and updated.onset == "l":
|
|
140
|
+
# e.g. 魚哩 [ŋ³⁵ ŋi⁵⁵]
|
|
141
|
+
assim_sc = _WUHUA_LI_ASSIM[prev.nucleus]
|
|
142
|
+
updated = updated.with_onset(assim_sc)
|
|
143
|
+
applied.append(f"wuhua:li_assim_syllabic_{prev.nucleus}_to_{assim_sc}")
|
|
144
|
+
|
|
145
|
+
# 2. Tone sandhi (3 -> 1 / 55):
|
|
146
|
+
# (a) after Yangping (tone 2)
|
|
147
|
+
# (b) after reduplication XX哩 (i >= 2 and prev == prev2)
|
|
148
|
+
# (c) after V啊V哩 (i >= 3 and chars[i-2] == '啊' and prev_ch == chars[i-3])
|
|
149
|
+
# (d) after demonstrative / interrogative pronoun prefix (樣哩/樣般哩/咹哩/咁哩)
|
|
150
|
+
is_redup = (
|
|
151
|
+
i >= 2
|
|
152
|
+
and (
|
|
153
|
+
(chars and prev_ch and prev_ch == chars[i - 2])
|
|
154
|
+
or (not chars and prev.base == out[i - 2].base and prev.tone == out[i - 2].tone)
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
is_vaav = (
|
|
158
|
+
i >= 3
|
|
159
|
+
and bool(chars)
|
|
160
|
+
and chars[i - 2] in ("啊", "阿")
|
|
161
|
+
and prev_ch == chars[i - 3]
|
|
162
|
+
)
|
|
163
|
+
is_pronoun = bool(prev_ch) and prev_ch in _WUHUA_PRONOUN_PREFIXES
|
|
164
|
+
|
|
165
|
+
if updated.tone == "3" and (prev.tone == "2" or is_redup or is_vaav or is_pronoun):
|
|
166
|
+
updated = updated.with_tone("1", tone_value="55")
|
|
167
|
+
reason = (
|
|
168
|
+
"redup"
|
|
169
|
+
if (is_redup or is_vaav)
|
|
170
|
+
else ("pronoun" if is_pronoun else "after_yangping")
|
|
171
|
+
)
|
|
172
|
+
applied.append(f"wuhua:li_tone_3_to_1_{reason}")
|
|
173
|
+
|
|
174
|
+
if updated != cur:
|
|
175
|
+
out[i] = updated
|
|
176
|
+
changes.append(
|
|
177
|
+
SandhiChange(
|
|
178
|
+
index=i,
|
|
179
|
+
char=ch,
|
|
180
|
+
before=cur.hps_ext,
|
|
181
|
+
after=updated.hps_ext,
|
|
182
|
+
rule="+".join(applied),
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
return out, changes
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _apply_changting(
|
|
189
|
+
syls: list[Syllable],
|
|
190
|
+
chars: list[str],
|
|
191
|
+
profile: str,
|
|
192
|
+
) -> tuple[list[Syllable], list[SandhiChange]]:
|
|
193
|
+
"""長汀話連讀變調:穩定上聲連讀 (3+3 -> 2+3) 與可選饒長溶兩字組體系。"""
|
|
194
|
+
out = list(syls)
|
|
195
|
+
changes: list[SandhiChange] = []
|
|
196
|
+
n = len(out)
|
|
197
|
+
for i in range(n - 1):
|
|
198
|
+
cur = out[i]
|
|
199
|
+
nxt = out[i + 1]
|
|
200
|
+
if cur.tone == "3" and nxt.tone == "3":
|
|
201
|
+
updated = cur.with_tone("2", tone_value="24")
|
|
202
|
+
out[i] = updated
|
|
203
|
+
changes.append(
|
|
204
|
+
SandhiChange(
|
|
205
|
+
index=i,
|
|
206
|
+
char=chars[i] if i < len(chars) else "",
|
|
207
|
+
before=cur.hps_ext,
|
|
208
|
+
after=updated.hps_ext,
|
|
209
|
+
rule="changting:shang_3_to_2_before_shang",
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
elif profile == "rao":
|
|
213
|
+
if cur.tone in ("1", "2") and nxt.tone == "3":
|
|
214
|
+
updated = cur.with_tone_value("11", tone=cur.tone)
|
|
215
|
+
out[i] = updated
|
|
216
|
+
changes.append(
|
|
217
|
+
SandhiChange(
|
|
218
|
+
index=i,
|
|
219
|
+
char=chars[i] if i < len(chars) else "",
|
|
220
|
+
before=f"{cur.hps_ext}[{cur.tone_value}]",
|
|
221
|
+
after=f"{updated.hps_ext}[11]",
|
|
222
|
+
rule="changting:ping_to_11_before_shang",
|
|
223
|
+
)
|
|
224
|
+
)
|
|
225
|
+
elif cur.tone == "6" and nxt.tone == "5":
|
|
226
|
+
updated = cur.with_tone("2", tone_value="24")
|
|
227
|
+
out[i] = updated
|
|
228
|
+
changes.append(
|
|
229
|
+
SandhiChange(
|
|
230
|
+
index=i,
|
|
231
|
+
char=chars[i] if i < len(chars) else "",
|
|
232
|
+
before=cur.hps_ext,
|
|
233
|
+
after=updated.hps_ext,
|
|
234
|
+
rule="changting:yangqu_6_to_2_before_yinqu",
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
elif cur.tone == "5" and nxt.tone in ("1", "2", "5"):
|
|
238
|
+
updated = cur.with_tone_value("55", tone="5")
|
|
239
|
+
out[i] = updated
|
|
240
|
+
changes.append(
|
|
241
|
+
SandhiChange(
|
|
242
|
+
index=i,
|
|
243
|
+
char=chars[i] if i < len(chars) else "",
|
|
244
|
+
before=f"{cur.hps_ext}[{cur.tone_value or '54'}]",
|
|
245
|
+
after=f"{updated.hps_ext}[55]",
|
|
246
|
+
rule="changting:yinqu_54_to_55",
|
|
247
|
+
)
|
|
248
|
+
)
|
|
249
|
+
return out, changes
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _apply_sixian(
|
|
253
|
+
syls: list[Syllable],
|
|
254
|
+
chars: list[str],
|
|
255
|
+
profile: str,
|
|
256
|
+
) -> tuple[list[Syllable], list[SandhiChange]]:
|
|
257
|
+
"""臺灣北四縣腔:陰平(1, 24) + {陰平(1), 陽平(2), 陰入(7)} -> 陽平(2, 11)。"""
|
|
258
|
+
del profile
|
|
259
|
+
out = list(syls)
|
|
260
|
+
changes: list[SandhiChange] = []
|
|
261
|
+
for i in range(len(out) - 1):
|
|
262
|
+
cur = out[i]
|
|
263
|
+
nxt = out[i + 1]
|
|
264
|
+
if cur.tone == "1" and nxt.tone in ("1", "2", "7"):
|
|
265
|
+
updated = cur.with_tone("2", tone_value="11")
|
|
266
|
+
out[i] = updated
|
|
267
|
+
changes.append(
|
|
268
|
+
SandhiChange(
|
|
269
|
+
index=i,
|
|
270
|
+
char=chars[i] if i < len(chars) else "",
|
|
271
|
+
before=cur.hps_ext,
|
|
272
|
+
after=updated.hps_ext,
|
|
273
|
+
rule="sixian:yinping_1_to_2_before_1_2_7",
|
|
274
|
+
)
|
|
275
|
+
)
|
|
276
|
+
return out, changes
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _apply_hailu(
|
|
280
|
+
syls: list[Syllable],
|
|
281
|
+
chars: list[str],
|
|
282
|
+
profile: str,
|
|
283
|
+
) -> tuple[list[Syllable], list[SandhiChange]]:
|
|
284
|
+
"""臺灣海陸腔:上聲(3, 24) 非句末 -> 中平(6, 33);陽入(8, 2) 非句末 -> 陰入(7, 5)。"""
|
|
285
|
+
del profile
|
|
286
|
+
out = list(syls)
|
|
287
|
+
changes: list[SandhiChange] = []
|
|
288
|
+
for i in range(len(out) - 1):
|
|
289
|
+
cur = out[i]
|
|
290
|
+
if cur.tone == "3":
|
|
291
|
+
updated = cur.with_tone("6", tone_value="33")
|
|
292
|
+
out[i] = updated
|
|
293
|
+
changes.append(
|
|
294
|
+
SandhiChange(
|
|
295
|
+
index=i,
|
|
296
|
+
char=chars[i] if i < len(chars) else "",
|
|
297
|
+
before=cur.hps_ext,
|
|
298
|
+
after=updated.hps_ext,
|
|
299
|
+
rule="hailu:shang_3_to_6_nonfinal",
|
|
300
|
+
)
|
|
301
|
+
)
|
|
302
|
+
elif cur.tone == "8":
|
|
303
|
+
updated = cur.with_tone("7", tone_value="5")
|
|
304
|
+
out[i] = updated
|
|
305
|
+
changes.append(
|
|
306
|
+
SandhiChange(
|
|
307
|
+
index=i,
|
|
308
|
+
char=chars[i] if i < len(chars) else "",
|
|
309
|
+
before=cur.hps_ext,
|
|
310
|
+
after=updated.hps_ext,
|
|
311
|
+
rule="hailu:yangru_8_to_7_nonfinal",
|
|
312
|
+
)
|
|
313
|
+
)
|
|
314
|
+
return out, changes
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def apply_sandhi(
|
|
318
|
+
syllables: str | Sequence[Syllable],
|
|
319
|
+
dialect: str = DEFAULT_DIALECT,
|
|
320
|
+
*,
|
|
321
|
+
chars: str | Sequence[str] | None = None,
|
|
322
|
+
profile: str = "standard",
|
|
323
|
+
scheme: str = "hps_ext",
|
|
324
|
+
) -> SandhiResult:
|
|
325
|
+
"""Apply tone sandhi and segmental assimilation rules for `dialect`.
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
syllables: Space-separated transcription string or sequence of `Syllable`.
|
|
329
|
+
dialect: Dialect slug or alias (default: ``"meixian"``).
|
|
330
|
+
chars: Optional aligned Chinese characters (enables morpheme-specific rules
|
|
331
|
+
such as Wuhua suffix ``哩`` and reduplication detection).
|
|
332
|
+
profile: Rule profile name (e.g. ``"standard"``, ``"traditional"``, ``"rao"``).
|
|
333
|
+
scheme: Input scheme if `syllables` is passed as a string.
|
|
334
|
+
"""
|
|
335
|
+
dinfo = get_dialect(dialect)
|
|
336
|
+
slug = dinfo.slug
|
|
337
|
+
syl_list = (
|
|
338
|
+
parse_syllables(syllables, scheme=scheme, dialect=slug)
|
|
339
|
+
if isinstance(syllables, str)
|
|
340
|
+
else list(syllables)
|
|
341
|
+
)
|
|
342
|
+
char_list = list(chars) if isinstance(chars, str) else (list(chars) if chars else [])
|
|
343
|
+
|
|
344
|
+
if slug in SUPPORTED_SANDHI and profile not in SUPPORTED_SANDHI[slug]:
|
|
345
|
+
valid = ", ".join(SUPPORTED_SANDHI[slug])
|
|
346
|
+
raise ValueError(f"Unknown sandhi profile {profile!r} for {slug!r}. Supported: {valid}")
|
|
347
|
+
|
|
348
|
+
if slug == "meixian":
|
|
349
|
+
out, changes = _apply_meixian(syl_list, char_list, profile)
|
|
350
|
+
elif slug == "wuhua":
|
|
351
|
+
out, changes = _apply_wuhua(syl_list, char_list, profile)
|
|
352
|
+
elif slug == "changting":
|
|
353
|
+
out, changes = _apply_changting(syl_list, char_list, profile)
|
|
354
|
+
elif slug in ("mcp:臺灣四縣腔", "mcp:臺灣南四縣腔"):
|
|
355
|
+
out, changes = _apply_sixian(syl_list, char_list, profile)
|
|
356
|
+
elif slug == "mcp:臺灣海陸腔":
|
|
357
|
+
out, changes = _apply_hailu(syl_list, char_list, profile)
|
|
358
|
+
elif slug == "dabu-baihou":
|
|
359
|
+
out, changes = syl_list, []
|
|
360
|
+
else:
|
|
361
|
+
# Dialect has no encoded sandhi rules yet: return identity cleanly
|
|
362
|
+
out, changes = syl_list, []
|
|
363
|
+
|
|
364
|
+
return SandhiResult(
|
|
365
|
+
syllables=tuple(out),
|
|
366
|
+
changes=tuple(changes),
|
|
367
|
+
dialect=slug,
|
|
368
|
+
profile=profile,
|
|
369
|
+
)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyHakka
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Computational linguistics and dialectology toolkit for Hakka Chinese: phonetic conversion (HPS-Ext / IPA / Guangdong / HKILANG), lexicon lookup across 229 varieties, and tone sandhi.
|
|
5
|
+
Author: HakkaCL Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HakkaCL/hakka
|
|
8
|
+
Project-URL: Repository, https://github.com/HakkaCL/hakka
|
|
9
|
+
Project-URL: Issues, https://github.com/HakkaCL/hakka/issues
|
|
10
|
+
Keywords: hakka,linguistics,phonology,ipa,dialectology,tone-sandhi,chinese,nlp
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
28
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
29
|
+
Provides-Extra: build
|
|
30
|
+
Requires-Dist: opencc-python-reimplemented>=0.1.7; extra == "build"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# PyHakka
|
|
34
|
+
|
|
35
|
+
客家話計算語言學與方言學 Python 工具庫([`HakkaCL/hakka`](https://github.com/HakkaCL/hakka) Monorepo 之 Python 套件)。
|
|
36
|
+
|
|
37
|
+
- **預設腔調**:標準惠陽腔(`huiyang`,六調 `44/11/31/53/1/5`)
|
|
38
|
+
- **預設記音**:客家語拼音擴展方案(`hps_ext`,HPS-Ext)
|
|
39
|
+
- **核心模組**:`pyhakka.phon`(音節解析、校驗、多方案無損互轉)、`pyhakka.dialects`(229 點音系元數據)、`pyhakka.lexicon`(查字、查詞、同音反查、跨點比較)、`pyhakka.sandhi`(連讀變調與音段同化)。
|
|
40
|
+
- 若需標準惠陽腔句子級漢字轉拼音,請使用姊妹庫 [`to-hakka`](https://github.com/HakkaCL/to-hakka)。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
pyhakka/__init__.py,sha256=gjFc0uRsyt0cY836JAxnsVntL5Ku64hG4Q5KnmXKdUA,1435
|
|
2
|
+
pyhakka/_db.py,sha256=ssurJjlEkFj5eta2GEUYfuNxHDqKRI77hcpkQH7q_UU,2207
|
|
3
|
+
pyhakka/cli.py,sha256=HfhZG1QYrT1BEgfJb7gqMYB0xXPXSaUbpxJBnfahhwI,11366
|
|
4
|
+
pyhakka/dialects.py,sha256=7ZOjaCUODH9Gc8l_DChtYW09Pzlpawbm38q8zIVadWY,4950
|
|
5
|
+
pyhakka/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
pyhakka/data/hakka.sqlite3,sha256=-nlc61hSKDWxjzvWMc6hhADGKwQT88mzOE8RBEuQYuM,41414656
|
|
7
|
+
pyhakka/data/manifest.json,sha256=aGi0MA99SdWoSSuX4g9H5KDv3krrQHrEFXDBRm4A7SQ,2179
|
|
8
|
+
pyhakka/lexicon/__init__.py,sha256=G6Svks6lRH4XVvl77PmFn1xg2gUruYpqg1KuaMj9tJw,461
|
|
9
|
+
pyhakka/lexicon/db.py,sha256=G4Dx6vK0U9ze3UhtAKFawmz3yNVwxJtRymZGfZFEpLY,499
|
|
10
|
+
pyhakka/lexicon/query.py,sha256=VEOwJwZ6LdwiW9wCRYzz5KKHcCdxVhxCfl206XlJE7Y,11720
|
|
11
|
+
pyhakka/phon/__init__.py,sha256=DT0dT3TCJvwFJsovAcCXN-1oDMHxO7B7RXde_tJBgts,725
|
|
12
|
+
pyhakka/phon/converter.py,sha256=mbRK9aKkiB3lT5b2P90P1m82wZJv_uSJbtkTbDYTlsE,7974
|
|
13
|
+
pyhakka/phon/parser.py,sha256=Xg6SnUD49cnKPAz30XiUde0kbeGJnUWw-ecLNuSI78c,24681
|
|
14
|
+
pyhakka/phon/schemes.py,sha256=uzI8toLAroDKqtAuwhGt3ECItzUWmY-4sc081F0T0D8,7838
|
|
15
|
+
pyhakka/phon/syllable.py,sha256=es203W9diH2b0DThrhToR9N5w4TMXuMk6ChV8uYitgc,4166
|
|
16
|
+
pyhakka/phon/validate.py,sha256=1NqEdZVxzcgzTriXnf_nyvOOUQSBtuBtBMG86h7vhEE,2520
|
|
17
|
+
pyhakka/sandhi/__init__.py,sha256=sf-fZcsBOyk4I96IbTcQ96_GSguS1h3pA3SR8kXtr9E,322
|
|
18
|
+
pyhakka/sandhi/rules.py,sha256=rAXotYUvToIa29Cbl5KP-yA6pfdZB4dIDlLGd2NX4fE,13263
|
|
19
|
+
pyhakka-0.1.0.dist-info/licenses/LICENSE,sha256=wkkBIe3CwfNQnQO1BV7TuAcYqwK2xEyhskX62Lh9q6M,1394
|
|
20
|
+
pyhakka-0.1.0.dist-info/METADATA,sha256=6hSmGL3uiPFw-eyNoBbnVxRb5zBQRkBOzKeBqeoKvQg,2095
|
|
21
|
+
pyhakka-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
22
|
+
pyhakka-0.1.0.dist-info/entry_points.txt,sha256=WZeEEv0Nm-cZuLzgkKtPKIXtLVzK09m0aNzmqEfIg9Q,45
|
|
23
|
+
pyhakka-0.1.0.dist-info/top_level.txt,sha256=6yH2fUENO4Z7Iwq_MCjGSK1TJeLe30SbTGaCCyiLV-I,8
|
|
24
|
+
pyhakka-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HakkaCL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Note on Bundled Linguistic Data:
|
|
26
|
+
Code in this repository is licensed under the MIT License above.
|
|
27
|
+
Bundled lexical and phonological tables compiled from Hakka-Char-Tables,
|
|
28
|
+
Hakka-Word-Tables, HKILANG, and MCPDict remain subject to their respective
|
|
29
|
+
CC BY 4.0 and MIT licenses. See NOTICE.md for full attribution and licensing.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyhakka
|