ipa-hangul 1.3.0 → 1.3.2
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 +40 -4
- package/dist/index.mjs +40 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -190,8 +190,10 @@ 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],
|
|
193
194
|
"ju\u02D0": [JUNGSEONG.YU],
|
|
194
195
|
"ju": [JUNGSEONG.YU],
|
|
196
|
+
"j\u028A": [JUNGSEONG.YU],
|
|
195
197
|
"j\u0259": [JUNGSEONG.YEO],
|
|
196
198
|
"j\u025B": [JUNGSEONG.YE],
|
|
197
199
|
"je": [JUNGSEONG.YE],
|
|
@@ -285,10 +287,44 @@ function getTrailingConsonants(text, preferOnset = false) {
|
|
|
285
287
|
return { before: text, trailing: "" };
|
|
286
288
|
}
|
|
287
289
|
if (preferOnset) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
if (allTrailing.length >= 2) {
|
|
291
|
+
const lastTwo = allTrailing.substring(allTrailing.length - 2);
|
|
292
|
+
if (CONSONANT_TO_CHOSEONG[lastTwo] || CONSONANT_TO_JAMO[lastTwo]) {
|
|
293
|
+
return {
|
|
294
|
+
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 2),
|
|
295
|
+
trailing: lastTwo
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const lastOne = allTrailing[allTrailing.length - 1];
|
|
300
|
+
if ((lastOne === "j" || lastOne === "w") && allTrailing.length >= 2) {
|
|
301
|
+
const beforeSemiVowel = allTrailing.substring(0, allTrailing.length - 1);
|
|
302
|
+
if (beforeSemiVowel.length >= 2) {
|
|
303
|
+
const lastTwoBeforeSemi = beforeSemiVowel.substring(beforeSemiVowel.length - 2);
|
|
304
|
+
if (CONSONANT_TO_CHOSEONG[lastTwoBeforeSemi]) {
|
|
305
|
+
return {
|
|
306
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 2),
|
|
307
|
+
trailing: lastTwoBeforeSemi + lastOne
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (beforeSemiVowel.length >= 1) {
|
|
312
|
+
const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
|
|
313
|
+
if (CONSONANT_TO_CHOSEONG[oneBeforeSemi]) {
|
|
314
|
+
return {
|
|
315
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
|
|
316
|
+
trailing: oneBeforeSemi + lastOne
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) {
|
|
322
|
+
return {
|
|
323
|
+
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
|
|
324
|
+
trailing: lastOne
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return { before: text, trailing: "" };
|
|
292
328
|
}
|
|
293
329
|
let keepUntil = 0;
|
|
294
330
|
if (allTrailing.length >= 2) {
|
package/dist/index.mjs
CHANGED
|
@@ -166,8 +166,10 @@ 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],
|
|
169
170
|
"ju\u02D0": [JUNGSEONG.YU],
|
|
170
171
|
"ju": [JUNGSEONG.YU],
|
|
172
|
+
"j\u028A": [JUNGSEONG.YU],
|
|
171
173
|
"j\u0259": [JUNGSEONG.YEO],
|
|
172
174
|
"j\u025B": [JUNGSEONG.YE],
|
|
173
175
|
"je": [JUNGSEONG.YE],
|
|
@@ -261,10 +263,44 @@ function getTrailingConsonants(text, preferOnset = false) {
|
|
|
261
263
|
return { before: text, trailing: "" };
|
|
262
264
|
}
|
|
263
265
|
if (preferOnset) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
if (allTrailing.length >= 2) {
|
|
267
|
+
const lastTwo = allTrailing.substring(allTrailing.length - 2);
|
|
268
|
+
if (CONSONANT_TO_CHOSEONG[lastTwo] || CONSONANT_TO_JAMO[lastTwo]) {
|
|
269
|
+
return {
|
|
270
|
+
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 2),
|
|
271
|
+
trailing: lastTwo
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const lastOne = allTrailing[allTrailing.length - 1];
|
|
276
|
+
if ((lastOne === "j" || lastOne === "w") && allTrailing.length >= 2) {
|
|
277
|
+
const beforeSemiVowel = allTrailing.substring(0, allTrailing.length - 1);
|
|
278
|
+
if (beforeSemiVowel.length >= 2) {
|
|
279
|
+
const lastTwoBeforeSemi = beforeSemiVowel.substring(beforeSemiVowel.length - 2);
|
|
280
|
+
if (CONSONANT_TO_CHOSEONG[lastTwoBeforeSemi]) {
|
|
281
|
+
return {
|
|
282
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 2),
|
|
283
|
+
trailing: lastTwoBeforeSemi + lastOne
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (beforeSemiVowel.length >= 1) {
|
|
288
|
+
const oneBeforeSemi = beforeSemiVowel[beforeSemiVowel.length - 1];
|
|
289
|
+
if (CONSONANT_TO_CHOSEONG[oneBeforeSemi]) {
|
|
290
|
+
return {
|
|
291
|
+
before: beforeConsonants + beforeSemiVowel.substring(0, beforeSemiVowel.length - 1),
|
|
292
|
+
trailing: oneBeforeSemi + lastOne
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (CONSONANT_TO_CHOSEONG[lastOne] || CONSONANT_TO_JAMO[lastOne]) {
|
|
298
|
+
return {
|
|
299
|
+
before: beforeConsonants + allTrailing.substring(0, allTrailing.length - 1),
|
|
300
|
+
trailing: lastOne
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
return { before: text, trailing: "" };
|
|
268
304
|
}
|
|
269
305
|
let keepUntil = 0;
|
|
270
306
|
if (allTrailing.length >= 2) {
|