ipa-hangul 1.3.1 → 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 +35 -2
- package/dist/index.mjs +35 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -190,9 +190,16 @@ var VOWEL_TO_JUNGSEONG = {
|
|
|
190
190
|
"w\u025B": [JUNGSEONG.WE],
|
|
191
191
|
"we": [JUNGSEONG.WE],
|
|
192
192
|
"w\xE6": [JUNGSEONG.WAE],
|
|
193
|
+
"wa\u026A": [JUNGSEONG.WA, JUNGSEONG.I],
|
|
194
|
+
"w\u028C": [JUNGSEONG.WO],
|
|
195
|
+
"w\u028A": [JUNGSEONG.U],
|
|
196
|
+
"w\u0252": [JUNGSEONG.WO],
|
|
193
197
|
"ju\u02D0": [JUNGSEONG.YU],
|
|
194
198
|
"ju": [JUNGSEONG.YU],
|
|
199
|
+
"j\u028A": [JUNGSEONG.YU],
|
|
195
200
|
"j\u0259": [JUNGSEONG.YEO],
|
|
201
|
+
"j\u025C": [JUNGSEONG.YEO],
|
|
202
|
+
"j\u025C\u02D0": [JUNGSEONG.YEO],
|
|
196
203
|
"j\u025B": [JUNGSEONG.YE],
|
|
197
204
|
"je": [JUNGSEONG.YE],
|
|
198
205
|
"j\u0251\u02D0": [JUNGSEONG.YA],
|
|
@@ -295,7 +302,30 @@ function getTrailingConsonants(text, preferOnset = false) {
|
|
|
295
302
|
}
|
|
296
303
|
}
|
|
297
304
|
const lastOne = allTrailing[allTrailing.length - 1];
|
|
298
|
-
if (
|
|
305
|
+
if ((lastOne === "j" || lastOne === "w") && allTrailing.length >= 2) {
|
|
306
|
+
const beforeSemiVowel = allTrailing.substring(0, allTrailing.length - 1);
|
|
307
|
+
if (beforeSemiVowel.length >= 2) {
|
|
308
|
+
const lastTwoBeforeSemi = beforeSemiVowel.substring(beforeSemiVowel.length - 2);
|
|
309
|
+
if (CONSONANT_TO_CHOSEONG[lastTwoBeforeSemi]) {
|
|
310
|
+
return {
|
|
311
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 2),
|
|
312
|
+
trailing: lastTwoBeforeSemi + lastOne
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (beforeSemiVowel.length >= 1) {
|
|
317
|
+
const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
|
|
318
|
+
const isLiquid = oneBeforeSemi === "l" || oneBeforeSemi === "r" || oneBeforeSemi === "\u0279" || oneBeforeSemi === "\u027E";
|
|
319
|
+
if (CONSONANT_TO_CHOSEONG[oneBeforeSemi] && !isLiquid) {
|
|
320
|
+
return {
|
|
321
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
|
|
322
|
+
trailing: oneBeforeSemi + lastOne
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const isLastLiquid = lastOne === "l" || lastOne === "r" || lastOne === "\u0279" || lastOne === "\u027E";
|
|
328
|
+
if ((CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) && !isLastLiquid) {
|
|
299
329
|
return {
|
|
300
330
|
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
|
|
301
331
|
trailing: lastOne
|
|
@@ -439,7 +469,10 @@ function convertSegment(tokens) {
|
|
|
439
469
|
const nextCons = tokens[i + 2].ipa;
|
|
440
470
|
const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
|
|
441
471
|
const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
|
|
442
|
-
|
|
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)) {
|
|
443
476
|
jongIdx = jongMapping;
|
|
444
477
|
consumed = 3;
|
|
445
478
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -166,9 +166,16 @@ var VOWEL_TO_JUNGSEONG = {
|
|
|
166
166
|
"w\u025B": [JUNGSEONG.WE],
|
|
167
167
|
"we": [JUNGSEONG.WE],
|
|
168
168
|
"w\xE6": [JUNGSEONG.WAE],
|
|
169
|
+
"wa\u026A": [JUNGSEONG.WA, JUNGSEONG.I],
|
|
170
|
+
"w\u028C": [JUNGSEONG.WO],
|
|
171
|
+
"w\u028A": [JUNGSEONG.U],
|
|
172
|
+
"w\u0252": [JUNGSEONG.WO],
|
|
169
173
|
"ju\u02D0": [JUNGSEONG.YU],
|
|
170
174
|
"ju": [JUNGSEONG.YU],
|
|
175
|
+
"j\u028A": [JUNGSEONG.YU],
|
|
171
176
|
"j\u0259": [JUNGSEONG.YEO],
|
|
177
|
+
"j\u025C": [JUNGSEONG.YEO],
|
|
178
|
+
"j\u025C\u02D0": [JUNGSEONG.YEO],
|
|
172
179
|
"j\u025B": [JUNGSEONG.YE],
|
|
173
180
|
"je": [JUNGSEONG.YE],
|
|
174
181
|
"j\u0251\u02D0": [JUNGSEONG.YA],
|
|
@@ -271,7 +278,30 @@ function getTrailingConsonants(text, preferOnset = false) {
|
|
|
271
278
|
}
|
|
272
279
|
}
|
|
273
280
|
const lastOne = allTrailing[allTrailing.length - 1];
|
|
274
|
-
if (
|
|
281
|
+
if ((lastOne === "j" || lastOne === "w") && allTrailing.length >= 2) {
|
|
282
|
+
const beforeSemiVowel = allTrailing.substring(0, allTrailing.length - 1);
|
|
283
|
+
if (beforeSemiVowel.length >= 2) {
|
|
284
|
+
const lastTwoBeforeSemi = beforeSemiVowel.substring(beforeSemiVowel.length - 2);
|
|
285
|
+
if (CONSONANT_TO_CHOSEONG[lastTwoBeforeSemi]) {
|
|
286
|
+
return {
|
|
287
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 2),
|
|
288
|
+
trailing: lastTwoBeforeSemi + lastOne
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (beforeSemiVowel.length >= 1) {
|
|
293
|
+
const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
|
|
294
|
+
const isLiquid = oneBeforeSemi === "l" || oneBeforeSemi === "r" || oneBeforeSemi === "\u0279" || oneBeforeSemi === "\u027E";
|
|
295
|
+
if (CONSONANT_TO_CHOSEONG[oneBeforeSemi] && !isLiquid) {
|
|
296
|
+
return {
|
|
297
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
|
|
298
|
+
trailing: oneBeforeSemi + lastOne
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const isLastLiquid = lastOne === "l" || lastOne === "r" || lastOne === "\u0279" || lastOne === "\u027E";
|
|
304
|
+
if ((CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) && !isLastLiquid) {
|
|
275
305
|
return {
|
|
276
306
|
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
|
|
277
307
|
trailing: lastOne
|
|
@@ -415,7 +445,10 @@ function convertSegment(tokens) {
|
|
|
415
445
|
const nextCons = tokens[i + 2].ipa;
|
|
416
446
|
const jongMapping = CONSONANT_TO_JONGSEONG[nextCons];
|
|
417
447
|
const hasVowelAfter = i + 3 < tokens.length && tokens[i + 3].type === "vowel";
|
|
418
|
-
|
|
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)) {
|
|
419
452
|
jongIdx = jongMapping;
|
|
420
453
|
consumed = 3;
|
|
421
454
|
}
|