ipa-hangul 1.3.2 → 1.3.3

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/dist/index.js CHANGED
@@ -191,10 +191,15 @@ var VOWEL_TO_JUNGSEONG = {
191
191
  "we": [JUNGSEONG.WE],
192
192
  "w\xE6": [JUNGSEONG.WAE],
193
193
  "wa\u026A": [JUNGSEONG.WA, JUNGSEONG.I],
194
+ "w\u028C": [JUNGSEONG.WO],
195
+ "w\u028A": [JUNGSEONG.U],
196
+ "w\u0252": [JUNGSEONG.WO],
194
197
  "ju\u02D0": [JUNGSEONG.YU],
195
198
  "ju": [JUNGSEONG.YU],
196
199
  "j\u028A": [JUNGSEONG.YU],
197
200
  "j\u0259": [JUNGSEONG.YEO],
201
+ "j\u025C": [JUNGSEONG.YEO],
202
+ "j\u025C\u02D0": [JUNGSEONG.YEO],
198
203
  "j\u025B": [JUNGSEONG.YE],
199
204
  "je": [JUNGSEONG.YE],
200
205
  "j\u0251\u02D0": [JUNGSEONG.YA],
@@ -310,7 +315,8 @@ function getTrailingConsonants(text, preferOnset = false) {
310
315
  }
311
316
  if (beforeSemiVowel.length >= 1) {
312
317
  const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
313
- if (CONSONANT_TO_CHOSEONG[oneBeforeSemi]) {
318
+ const isLiquid = oneBeforeSemi === "l" || oneBeforeSemi === "r" || oneBeforeSemi === "\u0279" || oneBeforeSemi === "\u027E";
319
+ if (CONSONANT_TO_CHOSEONG[oneBeforeSemi] && !isLiquid) {
314
320
  return {
315
321
  before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
316
322
  trailing: oneBeforeSemi + lastOne
@@ -318,7 +324,8 @@ function getTrailingConsonants(text, preferOnset = false) {
318
324
  }
319
325
  }
320
326
  }
321
- if (CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) {
327
+ const isLastLiquid = lastOne === "l" || lastOne === "r" || lastOne === "\u0279" || lastOne === "\u027E";
328
+ if ((CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) && !isLastLiquid) {
322
329
  return {
323
330
  before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
324
331
  trailing: lastOne
@@ -462,7 +469,10 @@ function convertSegment(tokens) {
462
469
  const nextCons = tokens[i + 2].ipa;
463
470
  const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
464
471
  const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
465
- if (jongMapping !== void 0 && !hasVowelAfter) {
472
+ const isLiquid = nextCons === "l" || nextCons === "r" || nextCons === "\u0279" || nextCons === "\u027E";
473
+ const nextVowelIsJW = hasVowelAfter && (tokens[i + 3].ipa.startsWith("j") || tokens[i + 3].ipa.startsWith("w"));
474
+ const preferJongseong = isLiquid && nextVowelIsJW;
475
+ if (jongMapping !== void 0 && (!hasVowelAfter || preferJongseong)) {
466
476
  jongIdx = jongMapping;
467
477
  consumed = 3;
468
478
  }
package/dist/index.mjs CHANGED
@@ -167,10 +167,15 @@ var VOWEL_TO_JUNGSEONG = {
167
167
  "we": [JUNGSEONG.WE],
168
168
  "w\xE6": [JUNGSEONG.WAE],
169
169
  "wa\u026A": [JUNGSEONG.WA, JUNGSEONG.I],
170
+ "w\u028C": [JUNGSEONG.WO],
171
+ "w\u028A": [JUNGSEONG.U],
172
+ "w\u0252": [JUNGSEONG.WO],
170
173
  "ju\u02D0": [JUNGSEONG.YU],
171
174
  "ju": [JUNGSEONG.YU],
172
175
  "j\u028A": [JUNGSEONG.YU],
173
176
  "j\u0259": [JUNGSEONG.YEO],
177
+ "j\u025C": [JUNGSEONG.YEO],
178
+ "j\u025C\u02D0": [JUNGSEONG.YEO],
174
179
  "j\u025B": [JUNGSEONG.YE],
175
180
  "je": [JUNGSEONG.YE],
176
181
  "j\u0251\u02D0": [JUNGSEONG.YA],
@@ -286,7 +291,8 @@ function getTrailingConsonants(text, preferOnset = false) {
286
291
  }
287
292
  if (beforeSemiVowel.length >= 1) {
288
293
  const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
289
- if (CONSONANT_TO_CHOSEONG[oneBeforeSemi]) {
294
+ const isLiquid = oneBeforeSemi === "l" || oneBeforeSemi === "r" || oneBeforeSemi === "\u0279" || oneBeforeSemi === "\u027E";
295
+ if (CONSONANT_TO_CHOSEONG[oneBeforeSemi] && !isLiquid) {
290
296
  return {
291
297
  before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
292
298
  trailing: oneBeforeSemi + lastOne
@@ -294,7 +300,8 @@ function getTrailingConsonants(text, preferOnset = false) {
294
300
  }
295
301
  }
296
302
  }
297
- if (CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) {
303
+ const isLastLiquid = lastOne === "l" || lastOne === "r" || lastOne === "\u0279" || lastOne === "\u027E";
304
+ if ((CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) && !isLastLiquid) {
298
305
  return {
299
306
  before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
300
307
  trailing: lastOne
@@ -438,7 +445,10 @@ function convertSegment(tokens) {
438
445
  const nextCons = tokens[i + 2].ipa;
439
446
  const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
440
447
  const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
441
- if (jongMapping !== void 0 && !hasVowelAfter) {
448
+ const isLiquid = nextCons === "l" || nextCons === "r" || nextCons === "\u0279" || nextCons === "\u027E";
449
+ const nextVowelIsJW = hasVowelAfter && (tokens[i + 3].ipa.startsWith("j") || tokens[i + 3].ipa.startsWith("w"));
450
+ const preferJongseong = isLiquid && nextVowelIsJW;
451
+ if (jongMapping !== void 0 && (!hasVowelAfter || preferJongseong)) {
442
452
  jongIdx = jongMapping;
443
453
  consumed = 3;
444
454
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipa-hangul",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Convert IPA (International Phonetic Alphabet) pronunciation to Korean Hangul",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",