ipa-hangul 1.3.2 → 1.3.4

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
@@ -462,7 +468,10 @@ function convertSegment(tokens) {
462
468
  const nextCons = tokens[i + 2].ipa;
463
469
  const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
464
470
  const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
465
- if (jongMapping !== void 0 && !hasVowelAfter) {
471
+ const isLiquid = nextCons === "l" || nextCons === "r" || nextCons === "\u0279" || nextCons === "\u027E";
472
+ const nextVowelIsJW = hasVowelAfter && (tokens[i + 3].ipa.startsWith("j") || tokens[i + 3].ipa.startsWith("w"));
473
+ const preferJongseong = isLiquid && nextVowelIsJW;
474
+ if (jongMapping !== void 0 && (!hasVowelAfter || preferJongseong)) {
466
475
  jongIdx = jongMapping;
467
476
  consumed = 3;
468
477
  }
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
@@ -438,7 +444,10 @@ function convertSegment(tokens) {
438
444
  const nextCons = tokens[i + 2].ipa;
439
445
  const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
440
446
  const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
441
- if (jongMapping !== void 0 && !hasVowelAfter) {
447
+ const isLiquid = nextCons === "l" || nextCons === "r" || nextCons === "\u0279" || nextCons === "\u027E";
448
+ const nextVowelIsJW = hasVowelAfter && (tokens[i + 3].ipa.startsWith("j") || tokens[i + 3].ipa.startsWith("w"));
449
+ const preferJongseong = isLiquid && nextVowelIsJW;
450
+ if (jongMapping !== void 0 && (!hasVowelAfter || preferJongseong)) {
442
451
  jongIdx = jongMapping;
443
452
  consumed = 3;
444
453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipa-hangul",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Convert IPA (International Phonetic Alphabet) pronunciation to Korean Hangul",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",