ipa-hangul 1.1.1 → 1.2.0

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
@@ -258,6 +258,9 @@ function matchConsonant(text, pos) {
258
258
  function preprocessIPA(ipa) {
259
259
  return ipa.replace(/\([^)]*\)/g, "").replace(/[\/\[\]]/g, "").replace(/ˈ/g, ".[P]").replace(/ˌ/g, ".[S]").replace(/[′']/g, ".").replace(/\.+/g, ".").replace(/^\./g, "").trim();
260
260
  }
261
+ function hasIPAVowel(text) {
262
+ return /[iɪeɛæɑɒɔʌəɜɝʊuoa]/.test(text);
263
+ }
261
264
  function parseSyllables(text) {
262
265
  const syllables = [];
263
266
  const parts = text.split(".");
@@ -271,7 +274,17 @@ function parseSyllables(text) {
271
274
  syllables.push({ text: part, stress: "none" });
272
275
  }
273
276
  }
274
- return syllables;
277
+ const merged = [];
278
+ for (let i = 0; i < syllables.length; i++) {
279
+ const curr = syllables[i];
280
+ const next = syllables[i + 1];
281
+ if (next && next.stress !== "none" && curr.stress === "none" && !hasIPAVowel(curr.text)) {
282
+ next.text = curr.text + next.text;
283
+ continue;
284
+ }
285
+ merged.push(curr);
286
+ }
287
+ return merged;
275
288
  }
276
289
  function splitByLongVowel(text) {
277
290
  const segments = [];
package/dist/index.mjs CHANGED
@@ -234,6 +234,9 @@ function matchConsonant(text, pos) {
234
234
  function preprocessIPA(ipa) {
235
235
  return ipa.replace(/\([^)]*\)/g, "").replace(/[\/\[\]]/g, "").replace(/ˈ/g, ".[P]").replace(/ˌ/g, ".[S]").replace(/[′']/g, ".").replace(/\.+/g, ".").replace(/^\./g, "").trim();
236
236
  }
237
+ function hasIPAVowel(text) {
238
+ return /[iɪeɛæɑɒɔʌəɜɝʊuoa]/.test(text);
239
+ }
237
240
  function parseSyllables(text) {
238
241
  const syllables = [];
239
242
  const parts = text.split(".");
@@ -247,7 +250,17 @@ function parseSyllables(text) {
247
250
  syllables.push({ text: part, stress: "none" });
248
251
  }
249
252
  }
250
- return syllables;
253
+ const merged = [];
254
+ for (let i = 0; i < syllables.length; i++) {
255
+ const curr = syllables[i];
256
+ const next = syllables[i + 1];
257
+ if (next && next.stress !== "none" && curr.stress === "none" && !hasIPAVowel(curr.text)) {
258
+ next.text = curr.text + next.text;
259
+ continue;
260
+ }
261
+ merged.push(curr);
262
+ }
263
+ return merged;
251
264
  }
252
265
  function splitByLongVowel(text) {
253
266
  const segments = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipa-hangul",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Convert IPA (International Phonetic Alphabet) pronunciation to Korean Hangul",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",