@hakkacl/hakka 0.1.0 → 0.1.1
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.
- package/README.md +25 -25
- package/data/dialects.json +1 -1
- package/package.json +2 -2
- package/src/dialects.js +1 -1
- package/src/phon/converter.js +15 -15
- package/src/phon/parser.js +23 -23
- package/src/phon/schemes.js +26 -30
- package/src/phon/syllable.js +11 -11
- package/src/phon/validate.js +6 -6
- package/src/sandhi.js +24 -28
- package/types/index.d.ts +14 -22
package/README.md
CHANGED
|
@@ -31,29 +31,29 @@ import {
|
|
|
31
31
|
applySandhi,
|
|
32
32
|
} from "@hakkacl/hakka";
|
|
33
33
|
|
|
34
|
-
const syllable = parseSyllable("ziim1", "
|
|
34
|
+
const syllable = parseSyllable("ziim1", "hpp", "meixian");
|
|
35
35
|
syllable.onset; // "z"
|
|
36
36
|
syllable.nucleus; // "ii"
|
|
37
37
|
syllable.coda; // "m"
|
|
38
38
|
syllable.tone; // "1"
|
|
39
39
|
syllable.tone_value; // "44"
|
|
40
|
-
syllable.
|
|
40
|
+
syllable.hpp; // "ziim1"
|
|
41
41
|
|
|
42
|
-
convert("ziim1 ngin2", "
|
|
42
|
+
convert("ziim1 ngin2", "hpp", "ipa", "meixian");
|
|
43
43
|
// "tsəm1 ŋin2"
|
|
44
44
|
|
|
45
|
-
convert("ziim1 ngin2", "
|
|
45
|
+
convert("ziim1 ngin2", "hpp", "ipa_value", "meixian");
|
|
46
46
|
// "tsəm⁴⁴ ŋin¹¹"
|
|
47
47
|
|
|
48
|
-
formatSyllable(parseSyllable("tien1", "
|
|
48
|
+
formatSyllable(parseSyllable("tien1", "hpp", "huiyang"), "ipa", "huiyang");
|
|
49
49
|
// "tʰien1"
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Every parsing/formatting function also accepts an options object:
|
|
53
53
|
|
|
54
54
|
```js
|
|
55
|
-
parseSyllable("ngin2", { scheme: "
|
|
56
|
-
convert("ngin2", { src: "
|
|
55
|
+
parseSyllable("ngin2", { scheme: "hpp", dialect: "huiyang" });
|
|
56
|
+
convert("ngin2", { src: "hpp", dst: "ipa", dialect: "huiyang" });
|
|
57
57
|
validateSyllable("ngin2", { dialect: "meixian" });
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -85,8 +85,8 @@ Tone values are available through `toneValueFor(toneClass)` and
|
|
|
85
85
|
|
|
86
86
|
| Canonical name | Aliases | Description |
|
|
87
87
|
| --- | --- | --- |
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
88
|
+
| `hpp` | `hakka_pinyin`, `pinyin` | Canonical Hakka Pinyin System Extended (H++) with tone classes 1–8 |
|
|
89
|
+
| `hpp_diacritic` | `diacritic` | H++ with tone diacritics |
|
|
90
90
|
| `ipa` | — | IPA segments with tone class |
|
|
91
91
|
| `ipa_value` | `ipa-value`, `ipa_numeric` | IPA with superscript Chao tone values |
|
|
92
92
|
| `ipa_chao` | `ipa-chao`, `chao` | IPA with Chao tone letters |
|
|
@@ -94,13 +94,13 @@ Tone values are available through `toneValueFor(toneClass)` and
|
|
|
94
94
|
| `hkilang` | `hk`, `hk_assoc` | Hong Kong Indigenous Language Association romanization |
|
|
95
95
|
|
|
96
96
|
```js
|
|
97
|
-
convert("ngit5 teu2 ngiet6 gong1 sia4", "hkilang", "
|
|
97
|
+
convert("ngit5 teu2 ngiet6 gong1 sia4", "hkilang", "hpp", "hk");
|
|
98
98
|
// "ngid7 teu2 ngied8 gong1 sia5"
|
|
99
99
|
|
|
100
|
-
convert("id7 iu1 ia2 ien1 iung5 'iu1", "
|
|
100
|
+
convert("id7 iu1 ia2 ien1 iung5 'iu1", "hpp", "hkilang", "hk");
|
|
101
101
|
// "yit5 yiu1 ya2 yen1 yung4 iu1"
|
|
102
102
|
|
|
103
|
-
convert("tʃæn1 kœŋ3", "ipa", "
|
|
103
|
+
convert("tʃæn1 kœŋ3", "ipa", "hpp", "huiyang");
|
|
104
104
|
// "zhaen1 goeng3"
|
|
105
105
|
```
|
|
106
106
|
|
|
@@ -111,14 +111,14 @@ convert("tʃæn1 kœŋ3", "ipa", "hps_ext", "huiyang");
|
|
|
111
111
|
`reading_mark`, and `raw`, plus computed accessors:
|
|
112
112
|
|
|
113
113
|
```js
|
|
114
|
-
const s = parseSyllable("hiunnh7", "
|
|
114
|
+
const s = parseSyllable("hiunnh7", "hpp", "huiyang");
|
|
115
115
|
s.final; // "iunnh"
|
|
116
116
|
s.base; // "hiunnh"
|
|
117
|
-
s.
|
|
117
|
+
s.hpp; // "hiunnh7"
|
|
118
118
|
s.is_checked; // true
|
|
119
119
|
s.is_syllabic_consonant; // false
|
|
120
120
|
|
|
121
|
-
s.withTone("8", "5").
|
|
121
|
+
s.withTone("8", "5").hpp; // "hiunnh8"
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
`parseSyllables("id7 ha5 siid8 fan5")` parses a whitespace- or hyphen-separated
|
|
@@ -127,18 +127,18 @@ sequence.
|
|
|
127
127
|
## Validation
|
|
128
128
|
|
|
129
129
|
```js
|
|
130
|
-
const result = validateSyllable("ngin2", "
|
|
130
|
+
const result = validateSyllable("ngin2", "hpp", "meixian");
|
|
131
131
|
result.valid; // true
|
|
132
132
|
result.errors; // []
|
|
133
133
|
result.warnings; // []
|
|
134
134
|
|
|
135
|
-
validateSyllable("ged3", "
|
|
135
|
+
validateSyllable("ged3", "hpp", "hk").warnings;
|
|
136
136
|
// ["Checked coda -d paired with non-checked tone class 3"]
|
|
137
137
|
|
|
138
|
-
validateSyllable("ngin6", "
|
|
138
|
+
validateSyllable("ngin6", "hpp", "meixian").warnings;
|
|
139
139
|
// ["Tone class '6' is not in meixian's tone inventory (['1', '2', '3', '5', '7', '8'])"]
|
|
140
140
|
|
|
141
|
-
validateSyllable("", "
|
|
141
|
+
validateSyllable("", "hpp", "meixian").valid;
|
|
142
142
|
// false
|
|
143
143
|
```
|
|
144
144
|
|
|
@@ -151,16 +151,16 @@ inventory mismatches and checked/open tone inconsistencies produce warnings.
|
|
|
151
151
|
applySandhi("tian1 tan2", { dialect: "meixian", chars: "天壇" });
|
|
152
152
|
// syllables[0].tone_value === "45"
|
|
153
153
|
|
|
154
|
-
applySandhi("pag8 sied7 sied7 li3", { dialect: "wuhua", chars: "白雪雪哩" }).
|
|
154
|
+
applySandhi("pag8 sied7 sied7 li3", { dialect: "wuhua", chars: "白雪雪哩" }).hpp;
|
|
155
155
|
// "pag8 sied7 sied7 di1"
|
|
156
156
|
|
|
157
|
-
applySandhi("hau3 shii3", "changting").
|
|
157
|
+
applySandhi("hau3 shii3", "changting").hpp;
|
|
158
158
|
// "hau2 shii3"
|
|
159
159
|
|
|
160
|
-
applySandhi("san1 go1", "mcp:臺灣四縣腔").
|
|
160
|
+
applySandhi("san1 go1", "mcp:臺灣四縣腔").hpp;
|
|
161
161
|
// "san2 go1"
|
|
162
162
|
|
|
163
|
-
applySandhi("hau3 siid8 fan5", "mcp:臺灣海陸腔").
|
|
163
|
+
applySandhi("hau3 siid8 fan5", "mcp:臺灣海陸腔").hpp;
|
|
164
164
|
// "hau6 siid7 fan5"
|
|
165
165
|
```
|
|
166
166
|
|
|
@@ -181,14 +181,14 @@ All other dialects, including the default `huiyang`, pass through unchanged.
|
|
|
181
181
|
|
|
182
182
|
A `SandhiResult` contains `syllables`, `changes` (each with `index`, `char`,
|
|
183
183
|
`before`, `after`, and `rule`), `dialect`, `profile`, and the space-joined
|
|
184
|
-
`
|
|
184
|
+
`hpp` transcription.
|
|
185
185
|
|
|
186
186
|
## API
|
|
187
187
|
|
|
188
188
|
| Export | Description |
|
|
189
189
|
| --- | --- |
|
|
190
190
|
| `DEFAULT_DIALECT` | `"huiyang"` |
|
|
191
|
-
| `DEFAULT_SCHEME` | `"
|
|
191
|
+
| `DEFAULT_SCHEME` | `"hpp"` |
|
|
192
192
|
| `CANONICAL_SCHEMES` | Canonical scheme names |
|
|
193
193
|
| `getDialect(name?)` | Resolve a dialect record |
|
|
194
194
|
| `listDialects(options?)` | List/filter dialect records |
|