UNPKG

hebrew-transliteration

Version:
501 lines (500 loc) 19.8 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var tiberian_exports = {}; __export(tiberian_exports, { tiberian: () => tiberian }); module.exports = __toCommonJS(tiberian_exports); const tiberian = { VOCAL_SHEVA: "a", HATAF_SEGOL: "\u025B", HATAF_PATAH: "a", HATAF_QAMATS: "\u0254", HIRIQ: "i", TSERE: "e", SEGOL: "\u025B", PATAH: "a", QAMATS: "\u0254", HOLAM: "o", HOLAM_HASER: "o", QUBUTS: "u", DAGESH: "", DAGESH_CHAZAQ: true, MAQAF: "-", PASEQ: "", SOF_PASUQ: "", QAMATS_QATAN: "\u0254", FURTIVE_PATAH: "a", HIRIQ_YOD: "i\u02D0", TSERE_YOD: "e\u02D0", SEGOL_YOD: "\u025B\u02D0", SHUREQ: "u\u02D0", HOLAM_VAV: "o\u02D0", QAMATS_HE: "\u0254\u02D0", SEGOL_HE: "\u025B\u02D0", TSERE_HE: "e\u02D0", MS_SUFX: "\u0254w", ALEF: "\u0294", BET: "v", BET_DAGESH: "b", GIMEL: "\u0281", GIMEL_DAGESH: "g", DALET: "\xF0", DALET_DAGESH: "d", HE: "h", VAV: "v", ZAYIN: "z", HET: "\u0127", TET: "t\u02C1", YOD: "j", FINAL_KAF: "\u03C7", KAF: "\u03C7", KAF_DAGESH: "k\u02B0", LAMED: "l", FINAL_MEM: "m", MEM: "m", FINAL_NUN: "n", NUN: "n", SAMEKH: "s", AYIN: "\u0295", FINAL_PE: "f", PE: "f", PE_DAGESH: "p\u02B0", FINAL_TSADI: "s\u02C1", TSADI: "s\u02C1", QOF: "q\u031F", RESH: "\u0280\u031F", SHIN: "\u0283", SIN: "s", TAV: "\u03B8", TAV_DAGESH: "t\u02B0", DIVINE_NAME: "\u0294a\xF0o\u02D0\u02C8n\u0254\u02D0\u0254j", DIVINE_NAME_ELOHIM: "\u0294\u025Blo\u02D0\u02C8hi\u02D0im", STRESS_MARKER: { location: "before-syllable", mark: "\u02C8" }, ADDITIONAL_FEATURES: [ { FEATURE: "cluster", HEBREW: "\u05D9\u05BC", TRANSLITERATION: (cluster, hebrew) => { return cluster.text.replace(hebrew, "\u025F\u025F"); } }, { FEATURE: "cluster", HEBREW: /תּ(?!\u{05B0})/u, TRANSLITERATION: (cluster, _, schema) => { var _a, _b, _c, _d, _e, _f; if (!cluster.prev || ((_a = cluster.prev.value) == null ? void 0 : _a.isNotHebrew)) { return cluster.text; } const prevCoda = (_d = (_c = (_b = cluster.syllable) == null ? void 0 : _b.prev) == null ? void 0 : _c.value) == null ? void 0 : _d.codaWithGemination; if (!(prevCoda == null ? void 0 : prevCoda.includes("\u05EA"))) { return cluster.text; } const noAspiration = (_f = (_e = schema["TAV_DAGESH"]) == null ? void 0 : _e.replace("\u02B0", "")) != null ? _f : ""; return cluster.text.replace("\u05EA\u05BC", `${noAspiration + schema["TAV_DAGESH"]}`); } }, { FEATURE: "cluster", HEBREW: /פ(?!\u{05b0})/u, TRANSLITERATION: (cluster, _, schema) => { var _a, _b, _c, _d, _e, _f; if (!cluster.prev || ((_a = cluster.prev.value) == null ? void 0 : _a.isNotHebrew)) { return cluster.text; } const prevCoda = (_d = (_c = (_b = cluster.syllable) == null ? void 0 : _b.prev) == null ? void 0 : _c.value) == null ? void 0 : _d.codaWithGemination; if (!(prevCoda == null ? void 0 : prevCoda.includes("\u05E4"))) { return cluster.text; } const noAspiration = (_f = (_e = schema["PE_DAGESH"]) == null ? void 0 : _e.replace("\u02B0", "")) != null ? _f : ""; return cluster.text.replace("\u05E4\u05BC", `${noAspiration + schema["PE_DAGESH"]}`); } }, { FEATURE: "cluster", HEBREW: /טּ(?!\u{05b0})/u, TRANSLITERATION: (cluster, _, schema) => { var _a, _b, _c, _d, _e, _f; if (!cluster.prev || ((_a = cluster.prev.value) == null ? void 0 : _a.isNotHebrew)) { return cluster.text; } const prevCoda = (_d = (_c = (_b = cluster.syllable) == null ? void 0 : _b.prev) == null ? void 0 : _c.value) == null ? void 0 : _d.codaWithGemination; if (!(prevCoda == null ? void 0 : prevCoda.includes("\u05D8"))) { return cluster.text; } const noPharyngealization = (_f = (_e = schema["TET"]) == null ? void 0 : _e.replace("\u02C1", "")) != null ? _f : ""; return cluster.text.replace("\u05D8", `${noPharyngealization + schema["TET"]}`); } }, { FEATURE: "cluster", HEBREW: /צּ(?!\u{05b0})/u, TRANSLITERATION: (cluster, _, schema) => { var _a, _b, _c, _d, _e, _f; if (!cluster.prev || ((_a = cluster.prev.value) == null ? void 0 : _a.isNotHebrew)) { return cluster.text; } const prevCoda = (_d = (_c = (_b = cluster.syllable) == null ? void 0 : _b.prev) == null ? void 0 : _c.value) == null ? void 0 : _d.codaWithGemination; if (!(prevCoda == null ? void 0 : prevCoda.includes("\u05E6"))) { return cluster.text; } const noPharyngealization = (_f = (_e = schema["TSADI"]) == null ? void 0 : _e.replace("\u02C1", "")) != null ? _f : ""; return cluster.text.replace("\u05E6", `${noPharyngealization + schema["TSADI"]}`); } }, { FEATURE: "cluster", HEBREW: /(כּ|ךּ)(?!\u{05b0})/u, TRANSLITERATION: (cluster, _, schema) => { var _a, _b, _c, _d, _e, _f; if (!cluster.prev || ((_a = cluster.prev.value) == null ? void 0 : _a.isNotHebrew)) { return cluster.text; } const prevCoda = (_d = (_c = (_b = cluster.syllable) == null ? void 0 : _b.prev) == null ? void 0 : _c.value) == null ? void 0 : _d.codaWithGemination; if (!(prevCoda == null ? void 0 : prevCoda.includes("\u05DB")) && !(prevCoda == null ? void 0 : prevCoda.includes("\u05DA"))) { return cluster.text; } const noAspiration = (_f = (_e = schema["KAF_DAGESH"]) == null ? void 0 : _e.replace("\u02B0", "")) != null ? _f : ""; return cluster.text.replace(/כּ|ךּ/u, `${noAspiration + schema["KAF_DAGESH"]}`); } }, { FEATURE: "cluster", HEBREW: "\u05D0(?![\u05B1-\u05BB\u05C7])", TRANSLITERATION: (cluster) => { var _a; const next = (_a = cluster.next) == null ? void 0 : _a.value; if (next && next.isShureq) { return cluster.text; } return ""; } }, { FEATURE: "cluster", HEBREW: "\u05D0\u05BC", TRANSLITERATION: (cluster) => { return cluster.text.replace("\u05BC", ""); } }, { FEATURE: "syllable", HEBREW: /ר/u, TRANSLITERATION: (syllable) => { var _a, _b; const alveolars = /[דזצתטסלנ]|שׂ/; const cluster = syllable.clusters.filter((c) => c.text.includes("\u05E8"))[0]; const prevCluster = (_a = cluster.prev) == null ? void 0 : _a.value; const currentSyllable = cluster == null ? void 0 : cluster.syllable; const [onset, _, coda] = currentSyllable ? currentSyllable.structure(true) : ["", "", ""]; if (prevCluster && alveolars.test(prevCluster.text)) { if (onset.includes("\u05E8") && !prevCluster.hasVowel) { return syllable.text.replace("\u05E8", "r\u02C1"); } if (coda.includes("\u05E8") && prevCluster.hasVowel) { return syllable.text.replace("\u05E8", "r\u02C1"); } } const nextCluster = (_b = cluster.next) == null ? void 0 : _b.value; const lamedAndNun = /[לנן]/; if (nextCluster && lamedAndNun.test(nextCluster.text)) { if (onset.includes("\u05E8") && !cluster.hasVowel) { return syllable.text.replace("\u05E8", "r\u02C1"); } if (coda.includes("\u05E8") && cluster.hasSheva) { return syllable.text.replace("\u05E8", "r\u02C1"); } } return syllable.text; } }, { FEATURE: "syllable", HEBREW: "\u05D7\u05B7\u05C3?$", PASS_THROUGH: true, TRANSLITERATION: (syllable, _hebrew, schema) => { var _a, _b; const prevText = ((_b = (_a = syllable.prev) == null ? void 0 : _a.value) == null ? void 0 : _b.text) || ""; if (syllable.isFinal && prevText) { if (/[יו]/.test(prevText)) { const glide = /ו/.test(prevText) ? "w" : "j"; return glide + schema["PATAH"] + schema["HET"]; } return schema["PATAH"] + schema["HET"]; } return syllable.text; } }, { FEATURE: "syllable", HEBREW: "\u05E2\u05B7\u05C3?$", PASS_THROUGH: true, TRANSLITERATION: (syllable, _hebrew, schema) => { var _a, _b; const prevText = (_b = (_a = syllable.prev) == null ? void 0 : _a.value) == null ? void 0 : _b.text; if (syllable.isFinal && prevText) { if (/[יו]/.test(prevText)) { const glide = /ו/.test(prevText) ? "w" : "j"; return glide + schema["PATAH"] + schema["AYIN"]; } return schema["PATAH"] + schema["AYIN"]; } return syllable.text; } }, { FEATURE: "syllable", HEBREW: "\u05D4\u05BC\u05B7\u05C3?$", PASS_THROUGH: true, TRANSLITERATION: (syllable, _hebrew, schema) => { var _a, _b; const prevText = (_b = (_a = syllable.prev) == null ? void 0 : _a.value) == null ? void 0 : _b.text; if (syllable.isFinal && prevText) { if (/[יו]/.test(prevText)) { const glide = /ו/.test(prevText) ? "w" : "j"; return glide + schema["PATAH"] + schema["HE"]; } return schema["PATAH"] + schema["HE"]; } return syllable.text; } }, { FEATURE: "syllable", HEBREW: /וּ(?![\u{05B4}-\u{05BB}])/u, TRANSLITERATION: (syllable, _, schema) => { if (!syllable.prev && syllable.clusters[0].isShureq) { const text = syllable.text; const hasMeteg = syllable.clusters.map((c) => c.hasMeteg).includes(true); const secondaryAccent = hasMeteg ? "\u02CC" : ""; const halfLengthMarker = hasMeteg ? "\u02D1" : ""; return text.replace("\u05D5\u05BC", `${secondaryAccent}wu${halfLengthMarker}`); } if (syllable.isAccented && syllable.isClosed) { const noLength = schema["SHUREQ"].replace("\u02D0", ""); return syllable.text.replace("\u05D5\u05BC", schema["SHUREQ"] + noLength); } return syllable.text; } }, { FEATURE: "syllable", HEBREW: /[\u{05B4}-\u{05BB}\u{05C7}]/u, TRANSLITERATION: (syllable, _, schema) => { const vowelName = syllable.vowelNames[0]; const vowel = syllable.vowels[0]; if (!vowel || !vowelName) { return syllable.text; } if (vowelName === "SHEVA") { throw new Error(`Syllable ${syllable.text} has a sheva as vowel, should not have matched`); } const hasHalfVowel = syllable.clusters.map((c) => c.hasHalfVowel).includes(true); if (hasHalfVowel) { throw new Error(`Syllable ${syllable.text} has a hataf as vowel, should not have matched`); } const [onset, _nuclues, coda] = syllable.structure(true); function determinePatachRealization(vowelChar) { var _a; if (vowelName !== "PATAH" && vowelName !== "HATAF_PATAH") { return vowelChar; } const pharyngealized = /rˁ|ט|צ|ץ/; if (pharyngealized.test(onset) || pharyngealized.test(coda)) { return "\u0251"; } const nextSyllable = (_a = syllable.next) == null ? void 0 : _a.value; const nextOnset = nextSyllable == null ? void 0 : nextSyllable.onset; const alveolars = /[דזצתטסלנ]|שׂ/; if (nextOnset === "\u05E8" && alveolars.test(coda)) { return "\u0251"; } return vowelChar; } const noMaterText = syllable.clusters.filter((c) => !c.isMater).map((c) => c.text).join("").replace(/([\u{05B5}\u{05B6}\u{05B9}].{1})\u{05D4}(?!\u{05BC})/u, "$1"); const hasMaters = syllable.clusters.map((c) => c.isMater).includes(true); const lengthMarker = "\u02D0"; const halfLengthMarker = "\u02D1"; const hasMeteg = syllable.clusters.map((c) => c.hasMeteg).includes(true); if (hasMeteg) { const hasLongVowel = syllable.clusters.map((c) => c.hasLongVowel).includes(true); const firstConsonant = noMaterText[0]; return noMaterText.replace(firstConsonant, `\u02CC${firstConsonant}`).replace(vowel, `${determinePatachRealization(vowel)}${hasLongVowel ? lengthMarker : halfLengthMarker}`); } const isClosed = syllable.isClosed; const isAccented = syllable.isAccented; if (isAccented && isClosed) { const syllableSeparator = schema["SYLLABLE_SEPARATOR"] || ""; const vowelRealization = determinePatachRealization(vowel); return noMaterText.replace(vowel, `${vowelRealization + lengthMarker + syllableSeparator + vowelRealization}`); } const longerVowels = ["HOLAM", "TSERE", "QAMATS"]; if (!isAccented && isClosed && !syllable.isFinal && longerVowels.includes(vowelName)) { const syllableSeparator = schema["SYLLABLE_SEPARATOR"] || ""; const vowelRealization = determinePatachRealization(vowel); return noMaterText.replace(vowel, `${vowelRealization + lengthMarker + syllableSeparator + vowelRealization}`); } if (isAccented || !isAccented && !isClosed) { return noMaterText.replace(vowel, `${determinePatachRealization(vowel) + lengthMarker}`); } if (!hasMaters && !isClosed && !isAccented) { return noMaterText.replace(vowel, `${determinePatachRealization(vowel)}`); } return syllable.text.replace(vowel, `${determinePatachRealization(vowel)}`); } }, { FEATURE: "syllable", HEBREW: /[\u{05B1}-\u{05B3}]/u, TRANSLITERATION: (syllable) => { const vowelName = syllable.vowelNames[0]; const vowel = syllable.vowels[0]; if (!vowel || !vowelName) { return syllable.text; } if (vowelName === "SHEVA") { throw new Error(`Syllable ${syllable.text} has a sheva as vowel, should not have matched`); } const hasNonHalfVowels = syllable.clusters.map((c) => c.hasShortVowel || c.hasLongVowel).includes(true); if (hasNonHalfVowels) { throw new Error(`Syllable ${syllable.text} does not have a hataf vowel, should not have matched`); } const [onset, _nuclues, coda] = syllable.structure(true); function determinePatachRealization(vowelChar) { var _a; if (vowelName !== "HATAF_PATAH") { return vowelChar; } const pharyngealized = /rˁ|ט|צ|ץ/; if (pharyngealized.test(onset) || pharyngealized.test(coda)) { return "\u0251"; } const nextSyllable = (_a = syllable.next) == null ? void 0 : _a.value; const nextOnset = nextSyllable == null ? void 0 : nextSyllable.onset; const alveolars = /[דזצתטסלנ]|שׂ/; if (nextOnset === "\u05E8" && alveolars.test(coda)) { return "\u0251"; } if (nextOnset && /[צץט]/.test(nextOnset)) { return "\u0251"; } return vowelChar; } return syllable.text.replace(vowel, `${determinePatachRealization(vowel)}`); } }, { FEATURE: "syllable", HEBREW: /(?<!.*([\u{05B4}-\u{05BB}\u{05C7}]|\u{05D5}\u{05BC}).*)\u{05B0}/u, TRANSLITERATION: (syllable, _hebrew, schema) => { var _a; const nextSyllable = (_a = syllable.next) == null ? void 0 : _a.value; if (!nextSyllable) return syllable.text; const nextSylFirstCluster = nextSyllable.clusters[0].text; if (!nextSylFirstCluster) return syllable.text; const [onset, _, coda] = syllable.structure(true); function isBackUnrounded() { var _a2; const pharyngealized = /rˁ|ט|צ|ץ/; if (pharyngealized.test(onset) || pharyngealized.test(coda)) { return true; } const nextSyllable2 = (_a2 = syllable.next) == null ? void 0 : _a2.value; if (!nextSyllable2) { return false; } const nextOnset = nextSyllable2.onset; if (pharyngealized.test(nextOnset)) { return true; } return false; } function transliterateShevaAsVowel(vowel) { const hasMeteg = syllable.clusters.map((c) => c.hasMeteg).includes(true); const secondaryAccent = hasMeteg ? "\u02CC" : ""; const halfLengthMarker = hasMeteg ? "\u02D1" : ""; const newVowel = vowel.replace("\u02D0", "") + halfLengthMarker; return secondaryAccent + syllable.text.replace(/\u{05B0}/u, newVowel); } const isGuttural = /[אהחע]/.test(nextSylFirstCluster); if (!isGuttural) { return transliterateShevaAsVowel(isBackUnrounded() ? "\u0251" : schema["PATAH"]); } const nextVowel = nextSyllable.vowelNames[0]; if (!nextVowel) { throw new Error(`Syllable ${syllable.text} has a sheva as a vowel, but the next syllable ${nextSylFirstCluster} does not have a vowel`); } if (nextVowel === "SHEVA") { throw new Error(`Syllable ${syllable.text} has a sheva as a vowel, but the next syllable ${nextSylFirstCluster} also has a sheva as a vowel`); } return transliterateShevaAsVowel(schema[nextVowel]); } }, { FEATURE: "syllable", HEBREW: /^\u{5B4}\u{5DD}/u, TRANSLITERATION: (syl, heb, schema) => { var _a; const prev = (_a = syl.prev) == null ? void 0 : _a.value; if (prev && !prev.isClosed && !prev.hasVowelName("QAMATS") && !prev.hasVowelName("PATAH") && prev.onset !== "\u05DC") { return syl.text; } return syl.text.replace(heb, `${schema["YOD"]}${schema["HIRIQ"]}${schema["FINAL_MEM"]}`); } }, { FEATURE: "word", HEBREW: /(וְ)?יִשָּׂשכָר/, PASS_THROUGH: true, TRANSLITERATION: (word, heb) => { const taamim = /[\u{0590}-\u{05AF}\u{05BD}\u{05BF}]/gu; const text = word.text.replace(taamim, ""); const match = text.match(heb); const vav = match && match[1] ? match[1] : ""; const issachar = "jiss\u0254\u02D0\u02C8\u03C7\u0254\u02D0\u0254\u0280\u031F"; return `${vav}${issachar}`; } } ], allowNoNiqqud: false, article: false, holemHaser: "remove", ketivQeres: [ { input: "\u05D4\u05B4\u05D5\u05D0", output: "\u05D4\u05B4\u05D9\u05D0", captureTaamim: true, ignoreTaamim: true } ], longVowels: false, qametsQatan: true, shevaAfterMeteg: false, shevaWithMeteg: true, sqnmlvy: false, strict: true, wawShureq: false }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { tiberian }); //# sourceMappingURL=tiberian.js.map