@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hakkacl/hakka",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Hakka phonology, multi-scheme romanization conversion, dialect metadata, and tone sandhi. Pure ESM, zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "客家话",
41
41
  "phonology",
42
42
  "romanization",
43
- "hps",
43
+ "hpp",
44
44
  "ipa",
45
45
  "sandhi",
46
46
  "tone"
package/src/dialects.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { readFileSync } from "node:fs";
9
9
 
10
10
  export const DEFAULT_DIALECT = "huiyang";
11
- export const DEFAULT_SCHEME = "hps_ext";
11
+ export const DEFAULT_SCHEME = "hpp";
12
12
 
13
13
  /** Error thrown when a dialect slug, name, or alias cannot be resolved. */
14
14
  export class UnknownDialectError extends Error {
@@ -5,7 +5,7 @@
5
5
  import { DEFAULT_DIALECT, getDialect } from "../dialects.js";
6
6
  import { parseSyllables } from "./parser.js";
7
7
  import {
8
- DEFAULT_HPS_DIACRITICS,
8
+ DEFAULT_HPP_DIACRITICS,
9
9
  DIGITS_TO_CHAO,
10
10
  SUPERSCRIPT_DIGITS,
11
11
  TONE_8_TO_6,
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  baseOf,
17
17
  createSyllable,
18
- hpsExtOf,
18
+ hppOf,
19
19
  isSyllabicConsonant,
20
20
  syllableFields,
21
21
  } from "./syllable.js";
@@ -213,7 +213,7 @@ function formatGd(syllable) {
213
213
  nucleus = "ê";
214
214
  }
215
215
 
216
- // Normalize HPS-Ext vowels outside the GD core gracefully.
216
+ // Normalize H++ vowels outside the GD core gracefully.
217
217
  if (nucleus === "ee") {
218
218
  nucleus = "ê";
219
219
  } else if (nucleus === "oo") {
@@ -253,7 +253,7 @@ function formatHkilang(syllable) {
253
253
 
254
254
  function formatHpsDiacritic(syllable, dialectSlug) {
255
255
  const phonProfile = getPhonProfile(dialectSlug);
256
- const diacriticMap = phonProfile.hps_diacritics ?? DEFAULT_HPS_DIACRITICS;
256
+ const diacriticMap = phonProfile.hpp_diacritics ?? DEFAULT_HPP_DIACRITICS;
257
257
  const diacritic = hasOwn(diacriticMap, syllable.tone) ? diacriticMap[syllable.tone] : "";
258
258
  return `${baseOf(syllable)}${diacritic}`;
259
259
  }
@@ -262,12 +262,12 @@ function resolveFormatArguments(schemeOrOptions, dialect) {
262
262
  if (schemeOrOptions !== null && typeof schemeOrOptions === "object") {
263
263
  const options = schemeOrOptions;
264
264
  return {
265
- scheme: options.scheme ?? "hps_ext",
265
+ scheme: options.scheme ?? "hpp",
266
266
  dialect: Object.hasOwn(options, "dialect") ? options.dialect : DEFAULT_DIALECT,
267
267
  };
268
268
  }
269
269
  return {
270
- scheme: schemeOrOptions ?? "hps_ext",
270
+ scheme: schemeOrOptions ?? "hpp",
271
271
  dialect: dialect === undefined ? DEFAULT_DIALECT : dialect,
272
272
  };
273
273
  }
@@ -276,11 +276,11 @@ function resolveFormatArguments(schemeOrOptions, dialect) {
276
276
  * Format a syllable into the requested transcription scheme.
277
277
  *
278
278
  * @param {object} syllable
279
- * @param {string} [scheme="hps_ext"]
279
+ * @param {string} [scheme="hpp"]
280
280
  * @param {string | null} [dialect="huiyang"]
281
281
  * @returns {string}
282
282
  */
283
- export function formatSyllable(syllable, scheme = "hps_ext", dialect = DEFAULT_DIALECT) {
283
+ export function formatSyllable(syllable, scheme = "hpp", dialect = DEFAULT_DIALECT) {
284
284
  const resolved = resolveFormatArguments(scheme, dialect);
285
285
  const canonicalScheme = normalizeScheme(resolved.scheme);
286
286
  const dialectInfo = resolved.dialect ? getDialect(resolved.dialect) : null;
@@ -288,10 +288,10 @@ export function formatSyllable(syllable, scheme = "hps_ext", dialect = DEFAULT_D
288
288
 
289
289
  const normalized = createSyllable(syllableFields(syllable));
290
290
 
291
- if (canonicalScheme === "hps_ext") {
292
- return hpsExtOf(normalized);
291
+ if (canonicalScheme === "hpp") {
292
+ return hppOf(normalized);
293
293
  }
294
- if (canonicalScheme === "hps_diacritic") {
294
+ if (canonicalScheme === "hpp_diacritic") {
295
295
  return formatHpsDiacritic(normalized, slug);
296
296
  }
297
297
  if (canonicalScheme === "gd") {
@@ -332,14 +332,14 @@ function resolveConvertArguments(srcOrOptions, dst, dialect, sep) {
332
332
  if (srcOrOptions !== null && typeof srcOrOptions === "object") {
333
333
  const options = srcOrOptions;
334
334
  return {
335
- src: options.src ?? options.from ?? "hps_ext",
335
+ src: options.src ?? options.from ?? "hpp",
336
336
  dst: options.dst ?? options.to ?? "ipa",
337
337
  dialect: Object.hasOwn(options, "dialect") ? options.dialect : DEFAULT_DIALECT,
338
338
  sep: options.sep ?? " ",
339
339
  };
340
340
  }
341
341
  return {
342
- src: srcOrOptions ?? "hps_ext",
342
+ src: srcOrOptions ?? "hpp",
343
343
  dst: dst ?? "ipa",
344
344
  dialect: dialect === undefined ? DEFAULT_DIALECT : dialect,
345
345
  sep: sep ?? " ",
@@ -350,13 +350,13 @@ function resolveConvertArguments(srcOrOptions, dst, dialect, sep) {
350
350
  * Convert a whitespace-separated Hakka transcription between schemes.
351
351
  *
352
352
  * @param {string} text
353
- * @param {string} [src="hps_ext"]
353
+ * @param {string} [src="hpp"]
354
354
  * @param {string} [dst="ipa"]
355
355
  * @param {string | null} [dialect="huiyang"]
356
356
  * @param {string} [sep=" "]
357
357
  * @returns {string}
358
358
  */
359
- export function convert(text, src = "hps_ext", dst = "ipa", dialect = DEFAULT_DIALECT, sep = " ") {
359
+ export function convert(text, src = "hpp", dst = "ipa", dialect = DEFAULT_DIALECT, sep = " ") {
360
360
  const resolved = resolveConvertArguments(src, dst, dialect, sep);
361
361
  const syllables = parseSyllables(text, resolved.src, resolved.dialect);
362
362
  return syllables
@@ -6,7 +6,7 @@
6
6
  import { DEFAULT_DIALECT, getDialect } from "../dialects.js";
7
7
  import {
8
8
  CHAO_TO_DIGITS,
9
- DEFAULT_HPS_DIACRITICS,
9
+ DEFAULT_HPP_DIACRITICS,
10
10
  FROM_SUPERSCRIPT_DIGITS,
11
11
  TONE_6_TO_8,
12
12
  getPhonProfile,
@@ -14,7 +14,7 @@ import {
14
14
  } from "./schemes.js";
15
15
  import {
16
16
  CHECKED_CODAS,
17
- HPS_EXT_ONSETS,
17
+ HPP_ONSETS,
18
18
  SYLLABIC_CONSONANTS,
19
19
  createSyllable,
20
20
  } from "./syllable.js";
@@ -22,9 +22,9 @@ import {
22
22
  export const READING_MARKS = new Set(["-", "=", "+", "*", "@", "?"]);
23
23
 
24
24
  const TRAILING_TONE_RE = /([0-9]+|[˩˨˧˦˥]+)$/u;
25
- const HPS_DIACRITIC_RE = /([ˊˇˋ+^])$/u;
25
+ const HPP_DIACRITIC_RE = /([ˊˇˋ+^])$/u;
26
26
 
27
- /** Ordered IPA onset table: [ipa_prefix, hps_ext_onset]. */
27
+ /** Ordered IPA onset table: [ipa_prefix, hpp_onset]. */
28
28
  const IPA_ONSETS = Object.freeze([
29
29
  ["tʃʰ", "ch"],
30
30
  ["tʂʰ", "ch"],
@@ -189,7 +189,7 @@ function stripTrailingReadingMarks(text) {
189
189
  }
190
190
 
191
191
  /**
192
- * Split an HPS-Ext vowel cluster into `[medial, nucleus, vowelCoda]`.
192
+ * Split an H++ vowel cluster into `[medial, nucleus, vowelCoda]`.
193
193
  * @param {string} vpart
194
194
  * @param {boolean} hasConsonantCoda
195
195
  * @returns {[string, string, string]}
@@ -243,7 +243,7 @@ export function splitVowelCluster(vpart, hasConsonantCoda) {
243
243
  }
244
244
 
245
245
  /**
246
- * Parse a tone-stripped HPS-Ext syllable.
246
+ * Parse a tone-stripped H++ syllable.
247
247
  * @param {string} base
248
248
  * @returns {{onset: string, medial: string, nucleus: string, coda: string, nasalized: boolean}}
249
249
  */
@@ -264,7 +264,7 @@ export function parseHpsExtBase(base) {
264
264
  let onset = "";
265
265
 
266
266
  // Strip onset greedily while leaving a non-empty rime.
267
- for (const candidate of HPS_EXT_ONSETS) {
267
+ for (const candidate of HPP_ONSETS) {
268
268
  if (work.startsWith(candidate) && work.length > candidate.length) {
269
269
  const remainder = work.slice(candidate.length);
270
270
  if (remainder === "h") continue;
@@ -432,7 +432,7 @@ function parseHpsDiacritic(token, dialectInfo) {
432
432
 
433
433
  let work = raw;
434
434
  let diacritic = "";
435
- const diacriticMatch = HPS_DIACRITIC_RE.exec(work);
435
+ const diacriticMatch = HPP_DIACRITIC_RE.exec(work);
436
436
  if (diacriticMatch) {
437
437
  diacritic = diacriticMatch[1];
438
438
  work = work.slice(0, diacriticMatch.index);
@@ -444,7 +444,7 @@ function parseHpsDiacritic(token, dialectInfo) {
444
444
 
445
445
  const slug = dialectInfo ? dialectInfo.slug : "meixian";
446
446
  const phonProfile = getPhonProfile(slug);
447
- const diacriticMap = phonProfile.hps_diacritics ?? DEFAULT_HPS_DIACRITICS;
447
+ const diacriticMap = phonProfile.hpp_diacritics ?? DEFAULT_HPP_DIACRITICS;
448
448
 
449
449
  const candidates = orderedToneClasses(diacriticMap).filter(
450
450
  (toneClass) => diacriticMap[toneClass] === diacritic,
@@ -622,7 +622,7 @@ function parseHkilang(token, dialectInfo) {
622
622
  }
623
623
 
624
624
  /**
625
- * Convert a cleaned IPA vowel sequence into an HPS-Ext vowel cluster.
625
+ * Convert a cleaned IPA vowel sequence into an H++ vowel cluster.
626
626
  * @param {string} vseq
627
627
  * @param {string} onset
628
628
  * @param {string} coda
@@ -762,7 +762,7 @@ function parseIpa(token, dialectInfo, forceToneValue = false) {
762
762
  }
763
763
 
764
764
  // Initial glottal stop: non-phonemic before syllabic nasals, but an
765
- // explicit HPS-Ext glottal onset before vowels.
765
+ // explicit H++ glottal onset before vowels.
766
766
  let explicitGlottal = false;
767
767
  if (work.startsWith("ʔ") && work.length > 1) {
768
768
  const afterGlottal = work.slice(1);
@@ -809,7 +809,7 @@ function parseIpa(token, dialectInfo, forceToneValue = false) {
809
809
  coda = "h";
810
810
  core = core.slice(0, -2);
811
811
  } else {
812
- for (const [ipaCoda, hpsCoda] of IPA_CODA_MAP) {
812
+ for (const [ipaCoda, hppCoda] of IPA_CODA_MAP) {
813
813
  if (core.endsWith(ipaCoda) && core.length > ipaCoda.length) {
814
814
  const remainder = core.slice(0, -ipaCoda.length);
815
815
  const remainderHasVowel = [...remainder].some((char) => IPA_VOWEL_ATOMS.has(char));
@@ -817,7 +817,7 @@ function parseIpa(token, dialectInfo, forceToneValue = false) {
817
817
  const remainderEndsNasal =
818
818
  remainder.length >= 2 && IPA_SYLLABIC_CODA_CHARS.has(remainder.at(-1));
819
819
  if (remainderHasVowel || remainderIsSyllabic || remainderEndsNasal) {
820
- coda = hpsCoda;
820
+ coda = hppCoda;
821
821
  core = remainder;
822
822
  break;
823
823
  }
@@ -852,7 +852,7 @@ function parseIpa(token, dialectInfo, forceToneValue = false) {
852
852
  let onset = explicitGlottal ? "'" : "";
853
853
  let rest = core;
854
854
  if (!explicitGlottal) {
855
- for (const [ipaPrefix, hpsOnset] of IPA_ONSETS) {
855
+ for (const [ipaPrefix, hppOnset] of IPA_ONSETS) {
856
856
  if (core.startsWith(ipaPrefix) && core.length > ipaPrefix.length) {
857
857
  const remainder = core.slice(ipaPrefix.length);
858
858
  const remainderHasVowel = [...remainder].some((char) => IPA_VOWEL_ATOMS.has(char));
@@ -864,7 +864,7 @@ function parseIpa(token, dialectInfo, forceToneValue = false) {
864
864
  remainder === "v" ||
865
865
  remainder === "ʋ"
866
866
  ) {
867
- onset = hpsOnset;
867
+ onset = hppOnset;
868
868
  rest = remainder;
869
869
  break;
870
870
  }
@@ -932,12 +932,12 @@ function resolveParseArguments(schemeOrOptions, dialect) {
932
932
  if (schemeOrOptions !== null && typeof schemeOrOptions === "object") {
933
933
  const options = schemeOrOptions;
934
934
  return {
935
- scheme: options.scheme ?? "hps_ext",
935
+ scheme: options.scheme ?? "hpp",
936
936
  dialect: Object.hasOwn(options, "dialect") ? options.dialect : DEFAULT_DIALECT,
937
937
  };
938
938
  }
939
939
  return {
940
- scheme: schemeOrOptions ?? "hps_ext",
940
+ scheme: schemeOrOptions ?? "hpp",
941
941
  dialect: dialect === undefined ? DEFAULT_DIALECT : dialect,
942
942
  };
943
943
  }
@@ -946,19 +946,19 @@ function resolveParseArguments(schemeOrOptions, dialect) {
946
946
  * Parse a single Hakka syllable from `scheme` into canonical IR.
947
947
  *
948
948
  * @param {string} text
949
- * @param {string} [scheme="hps_ext"]
949
+ * @param {string} [scheme="hpp"]
950
950
  * @param {string | null} [dialect="huiyang"]
951
951
  * @returns {object}
952
952
  */
953
- export function parseSyllable(text, scheme = "hps_ext", dialect = DEFAULT_DIALECT) {
953
+ export function parseSyllable(text, scheme = "hpp", dialect = DEFAULT_DIALECT) {
954
954
  const resolved = resolveParseArguments(scheme, dialect);
955
955
  const canonicalScheme = normalizeScheme(resolved.scheme);
956
956
  const dialectInfo = resolved.dialect ? getDialect(resolved.dialect) : null;
957
957
 
958
- if (canonicalScheme === "hps_ext") {
958
+ if (canonicalScheme === "hpp") {
959
959
  return parseHpsExt(text, dialectInfo);
960
960
  }
961
- if (canonicalScheme === "hps_diacritic") {
961
+ if (canonicalScheme === "hpp_diacritic") {
962
962
  return parseHpsDiacritic(text, dialectInfo);
963
963
  }
964
964
  if (canonicalScheme === "ipa" || canonicalScheme === "ipa_value" || canonicalScheme === "ipa_chao") {
@@ -977,11 +977,11 @@ export function parseSyllable(text, scheme = "hps_ext", dialect = DEFAULT_DIALEC
977
977
  * Parse a whitespace- or hyphen-separated sequence of syllables.
978
978
  *
979
979
  * @param {string} text
980
- * @param {string} [scheme="hps_ext"]
980
+ * @param {string} [scheme="hpp"]
981
981
  * @param {string | null} [dialect="huiyang"]
982
982
  * @returns {object[]}
983
983
  */
984
- export function parseSyllables(text, scheme = "hps_ext", dialect = DEFAULT_DIALECT) {
984
+ export function parseSyllables(text, scheme = "hpp", dialect = DEFAULT_DIALECT) {
985
985
  const resolved = resolveParseArguments(scheme, dialect);
986
986
  const tokens = String(text)
987
987
  .trim()
@@ -5,8 +5,8 @@
5
5
 
6
6
  /** Canonical scheme names understood by all conversion APIs. */
7
7
  export const CANONICAL_SCHEMES = Object.freeze([
8
- "hps_ext",
9
- "hps_diacritic",
8
+ "hpp",
9
+ "hpp_diacritic",
10
10
  "ipa",
11
11
  "ipa_value",
12
12
  "ipa_chao",
@@ -16,15 +16,11 @@ export const CANONICAL_SCHEMES = Object.freeze([
16
16
 
17
17
  /** Accepted aliases -> canonical scheme name. */
18
18
  export const SCHEME_ALIASES = Object.freeze({
19
- hps_ext: "hps_ext",
20
- "hps-ext": "hps_ext",
21
- hps: "hps_ext",
22
- hakka_pinyin: "hps_ext",
23
- pinyin: "hps_ext",
24
- hps_diacritic: "hps_diacritic",
25
- "hps-diacritic": "hps_diacritic",
26
- hps_mark: "hps_diacritic",
27
- diacritic: "hps_diacritic",
19
+ hpp: "hpp",
20
+ hakka_pinyin: "hpp",
21
+ pinyin: "hpp",
22
+ hpp_diacritic: "hpp_diacritic",
23
+ diacritic: "hpp_diacritic",
28
24
  ipa: "ipa",
29
25
  ipa_value: "ipa_value",
30
26
  "ipa-value": "ipa_value",
@@ -110,7 +106,7 @@ export const DIGITS_TO_CHAO = Object.freeze({
110
106
  5: "˥",
111
107
  });
112
108
 
113
- export const DEFAULT_HPS_DIACRITICS = Object.freeze({
109
+ export const DEFAULT_HPP_DIACRITICS = Object.freeze({
114
110
  1: "",
115
111
  2: "ˇ",
116
112
  3: "ˋ",
@@ -191,7 +187,7 @@ export const CHANGTING_DIACRITICS = Object.freeze({
191
187
  * @property {boolean} ung_as_ong
192
188
  * @property {string} a_ipa
193
189
  * @property {string} eu_ipa
194
- * @property {Readonly<Record<string, string>> | null} hps_diacritics
190
+ * @property {Readonly<Record<string, string>> | null} hpp_diacritics
195
191
  */
196
192
 
197
193
  const PROFILE_DEFAULTS = Object.freeze({
@@ -206,7 +202,7 @@ const PROFILE_DEFAULTS = Object.freeze({
206
202
  ung_as_ong: false,
207
203
  a_ipa: "a",
208
204
  eu_ipa: "eu",
209
- hps_diacritics: null,
205
+ hpp_diacritics: null,
210
206
  });
211
207
 
212
208
  function profile(slug, overrides = {}) {
@@ -218,13 +214,13 @@ export const DIALECT_PHON_PROFILES = Object.freeze({
218
214
  huiyang: profile("huiyang", {
219
215
  o_ipa: "o",
220
216
  e_ipa: "e",
221
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
217
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
222
218
  }),
223
219
  meixian: profile("meixian", {
224
220
  o_ipa: "ɔ",
225
221
  e_ipa: "e",
226
222
  ii_closed_as_schwa: true,
227
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
223
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
228
224
  }),
229
225
  changting: profile("changting", {
230
226
  sibilant_series: "postalveolar",
@@ -234,21 +230,21 @@ export const DIALECT_PHON_PROFILES = Object.freeze({
234
230
  ii_post_sibilant: "ɨ",
235
231
  a_ipa: "ɑ",
236
232
  eu_ipa: "əɯ",
237
- hps_diacritics: CHANGTING_DIACRITICS,
233
+ hpp_diacritics: CHANGTING_DIACRITICS,
238
234
  }),
239
235
  xingning: profile("xingning", {
240
236
  sibilant_series: "retroflex",
241
237
  o_ipa: "ɔ",
242
238
  e_ipa: "e",
243
239
  ii_post_sibilant: "ʅ",
244
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
240
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
245
241
  }),
246
242
  wuhua: profile("wuhua", {
247
243
  sibilant_series: "postalveolar",
248
244
  o_ipa: "o",
249
245
  e_ipa: "e",
250
246
  ii_post_sibilant: "ʅ",
251
- hps_diacritics: {
247
+ hpp_diacritics: {
252
248
  1: "",
253
249
  2: "ˊ",
254
250
  3: "ˋ",
@@ -265,7 +261,7 @@ export const DIALECT_PHON_PROFILES = Object.freeze({
265
261
  x_ipa: "ç",
266
262
  ung_as_ong: true,
267
263
  ii_post_sibilant: "ʅ",
268
- hps_diacritics: {
264
+ hpp_diacritics: {
269
265
  1: "ˊ",
270
266
  2: "ˇ",
271
267
  3: "ˋ",
@@ -277,57 +273,57 @@ export const DIALECT_PHON_PROFILES = Object.freeze({
277
273
  "huiyang-danshui": profile("huiyang-danshui", {
278
274
  o_ipa: "o",
279
275
  e_ipa: "e",
280
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
276
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
281
277
  }),
282
278
  "huiyang-1987": profile("huiyang-1987", {
283
279
  o_ipa: "o",
284
280
  e_ipa: "e",
285
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
281
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
286
282
  }),
287
283
  "huidong-daling": profile("huidong-daling", {
288
284
  o_ipa: "o",
289
285
  e_ipa: "e",
290
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
286
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
291
287
  }),
292
288
  "shenzhen-baoan": profile("shenzhen-baoan", {
293
289
  o_ipa: "o",
294
290
  e_ipa: "e",
295
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
291
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
296
292
  }),
297
293
  "hongkong-newterritories": profile("hongkong-newterritories", {
298
294
  o_ipa: "o",
299
295
  e_ipa: "e",
300
- hps_diacritics: DEFAULT_HPS_DIACRITICS,
296
+ hpp_diacritics: DEFAULT_HPP_DIACRITICS,
301
297
  }),
302
298
  "mcp:臺灣四縣腔": profile("mcp:臺灣四縣腔", {
303
299
  o_ipa: "o",
304
300
  e_ipa: "e",
305
301
  ii_closed_as_schwa: true,
306
- hps_diacritics: SIXIAN_DIACRITICS,
302
+ hpp_diacritics: SIXIAN_DIACRITICS,
307
303
  }),
308
304
  "mcp:臺灣南四縣腔": profile("mcp:臺灣南四縣腔", {
309
305
  o_ipa: "o",
310
306
  e_ipa: "e",
311
307
  ii_closed_as_schwa: true,
312
- hps_diacritics: SIXIAN_DIACRITICS,
308
+ hpp_diacritics: SIXIAN_DIACRITICS,
313
309
  }),
314
310
  "mcp:臺灣海陸腔": profile("mcp:臺灣海陸腔", {
315
311
  sibilant_series: "postalveolar",
316
312
  o_ipa: "o",
317
313
  e_ipa: "e",
318
- hps_diacritics: HAILU_DIACRITICS,
314
+ hpp_diacritics: HAILU_DIACRITICS,
319
315
  }),
320
316
  "mcp:臺灣饒平腔": profile("mcp:臺灣饒平腔", {
321
317
  o_ipa: "o",
322
318
  e_ipa: "e",
323
- hps_diacritics: RAOPING_DIACRITICS,
319
+ hpp_diacritics: RAOPING_DIACRITICS,
324
320
  }),
325
321
  "mcp:臺灣詔安腔": profile("mcp:臺灣詔安腔", {
326
322
  o_ipa: "o",
327
323
  e_ipa: "e",
328
324
  ee_ipa: "ɛ",
329
325
  o_oo_contrast: true,
330
- hps_diacritics: ZHAOAN_DIACRITICS,
326
+ hpp_diacritics: ZHAOAN_DIACRITICS,
331
327
  }),
332
328
  });
333
329
 
@@ -17,7 +17,7 @@ export const NASAL_CODAS = new Set(["m", "n", "ng"]);
17
17
  export const SYLLABIC_CONSONANTS = new Set(["m", "n", "ng", "v"]);
18
18
 
19
19
  /** Canonical ordered onsets (longest first for greedy matching). */
20
- export const HPS_EXT_ONSETS = Object.freeze([
20
+ export const HPP_ONSETS = Object.freeze([
21
21
  "zh",
22
22
  "ch",
23
23
  "sh",
@@ -55,11 +55,11 @@ export const HPS_EXT_ONSETS = Object.freeze([
55
55
  "'",
56
56
  ]);
57
57
 
58
- /** Set form of {@link HPS_EXT_ONSETS}. */
59
- export const HPS_EXT_ONSET_SET = new Set(HPS_EXT_ONSETS);
58
+ /** Set form of {@link HPP_ONSETS}. */
59
+ export const HPP_ONSET_SET = new Set(HPP_ONSETS);
60
60
 
61
61
  /** Canonical ordered nuclei (longest first). */
62
- export const HPS_EXT_NUCLEI = Object.freeze([
62
+ export const HPP_NUCLEI = Object.freeze([
63
63
  "ii",
64
64
  "ee",
65
65
  "ae",
@@ -75,7 +75,7 @@ export const HPS_EXT_NUCLEI = Object.freeze([
75
75
  ]);
76
76
 
77
77
  /** Canonical codas, ordered longest first. */
78
- export const HPS_EXT_CODAS = Object.freeze([
78
+ export const HPP_CODAS = Object.freeze([
79
79
  "ng",
80
80
  "m",
81
81
  "n",
@@ -130,11 +130,12 @@ export function baseOf(syllable) {
130
130
  return `${syllable.onset ?? ""}${finalOf(syllable)}`;
131
131
  }
132
132
 
133
- /** Return the canonical HPS-Ext spelling (base + tone class). */
134
- export function hpsExtOf(syllable) {
133
+ /** Return the canonical H++ spelling (base + tone class). */
134
+ export function hppOf(syllable) {
135
135
  return `${baseOf(syllable)}${syllable.tone ?? ""}`;
136
136
  }
137
137
 
138
+
138
139
  /** True if the syllable ends in a stop coda (-b/-d/-g/-h). */
139
140
  export function isChecked(syllable) {
140
141
  return CHECKED_CODAS.has(syllable.coda ?? "");
@@ -209,8 +210,7 @@ export function createSyllable(fields = {}) {
209
210
 
210
211
  define("final", { get: () => finalOf(syllable) });
211
212
  define("base", { get: () => baseOf(syllable) });
212
- define("hps_ext", { get: () => hpsExtOf(syllable) });
213
- define("hpsExt", { get: () => hpsExtOf(syllable) });
213
+ define("hpp", { get: () => hppOf(syllable) });
214
214
  define("is_checked", { get: () => isChecked(syllable) });
215
215
  define("isChecked", { get: () => isChecked(syllable) });
216
216
  define("is_nasal_coda", { get: () => isNasalCoda(syllable) });
@@ -249,9 +249,9 @@ export function createSyllable(fields = {}) {
249
249
  });
250
250
  define("with_onset", { value: (onset) => syllable.withOnset(onset) });
251
251
 
252
- define("toString", { value: () => hpsExtOf(syllable) });
252
+ define("toString", { value: () => hppOf(syllable) });
253
253
  define("toJSON", {
254
- value: () => ({ ...syllableFields(syllable), hps_ext: hpsExtOf(syllable) }),
254
+ value: () => ({ ...syllableFields(syllable), hpp: hppOf(syllable) }),
255
255
  });
256
256
 
257
257
  return Object.freeze(syllable);
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { DEFAULT_DIALECT, UnknownDialectError, getDialect } from "../dialects.js";
6
6
  import { parseSyllable } from "./parser.js";
7
- import { HPS_EXT_ONSET_SET, SYLLABIC_CONSONANTS } from "./syllable.js";
7
+ import { HPP_ONSET_SET, SYLLABIC_CONSONANTS } from "./syllable.js";
8
8
 
9
9
  const CANONICAL_NUCLEI = new Set([
10
10
  "a",
@@ -25,12 +25,12 @@ function resolveArguments(schemeOrOptions, dialect) {
25
25
  if (schemeOrOptions !== null && typeof schemeOrOptions === "object") {
26
26
  const options = schemeOrOptions;
27
27
  return {
28
- scheme: options.scheme ?? "hps_ext",
28
+ scheme: options.scheme ?? "hpp",
29
29
  dialect: Object.hasOwn(options, "dialect") ? options.dialect : DEFAULT_DIALECT,
30
30
  };
31
31
  }
32
32
  return {
33
- scheme: schemeOrOptions ?? "hps_ext",
33
+ scheme: schemeOrOptions ?? "hpp",
34
34
  dialect: dialect === undefined ? DEFAULT_DIALECT : dialect,
35
35
  };
36
36
  }
@@ -39,11 +39,11 @@ function resolveArguments(schemeOrOptions, dialect) {
39
39
  * Validate whether `text` is a well-formed Hakka syllable.
40
40
  *
41
41
  * @param {string} text
42
- * @param {string} [scheme="hps_ext"]
42
+ * @param {string} [scheme="hpp"]
43
43
  * @param {string | null} [dialect="huiyang"]
44
44
  * @returns {{valid: boolean, syllable: object | null, errors: string[], warnings: string[]}}
45
45
  */
46
- export function validateSyllable(text, scheme = "hps_ext", dialect = DEFAULT_DIALECT) {
46
+ export function validateSyllable(text, scheme = "hpp", dialect = DEFAULT_DIALECT) {
47
47
  const resolved = resolveArguments(scheme, dialect);
48
48
  const effectiveDialect = resolved.dialect || DEFAULT_DIALECT;
49
49
 
@@ -65,7 +65,7 @@ export function validateSyllable(text, scheme = "hps_ext", dialect = DEFAULT_DIA
65
65
  const errors = [];
66
66
  const warnings = [];
67
67
 
68
- if (syllable.onset && !HPS_EXT_ONSET_SET.has(syllable.onset)) {
68
+ if (syllable.onset && !HPP_ONSET_SET.has(syllable.onset)) {
69
69
  errors.push(`Unknown onset '${syllable.onset}'`);
70
70
  }
71
71