hebrew-transliteration 1.3.1 → 2.0.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/{LICENSE → LICENSE.md} +2 -2
- package/README.md +247 -39
- package/dist/index.d.ts +658 -4
- package/dist/index.esm.js +404 -0
- package/dist/index.js +437 -24
- package/package.json +25 -13
- package/dist/hebCharsTrans.d.ts +0 -2
- package/dist/hebCharsTrans.js +0 -55
- package/dist/hebCharsTrans.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interfaces.d.ts +0 -13
- package/dist/interfaces.js +0 -3
- package/dist/interfaces.js.map +0 -1
- package/dist/qametsQatan.d.ts +0 -1
- package/dist/qametsQatan.js +0 -141
- package/dist/qametsQatan.js.map +0 -1
- package/dist/remove.d.ts +0 -2
- package/dist/remove.js +0 -17
- package/dist/remove.js.map +0 -1
- package/dist/sequence.d.ts +0 -1
- package/dist/sequence.js +0 -63
- package/dist/sequence.js.map +0 -1
- package/dist/testEach.d.ts +0 -2
- package/dist/testEach.js +0 -294
- package/dist/testEach.js.map +0 -1
- package/dist/titForTat.d.ts +0 -1
- package/dist/titForTat.js +0 -29
- package/dist/titForTat.js.map +0 -1
- package/dist/transliterate.d.ts +0 -2
- package/dist/transliterate.js +0 -20
- package/dist/transliterate.js.map +0 -1
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Text as Text3 } from "havarotjs";
|
|
3
|
+
|
|
4
|
+
// src/sequence.ts
|
|
5
|
+
import { Text } from "havarotjs";
|
|
6
|
+
var vowels = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/u;
|
|
7
|
+
var sequence = (text, qametsQatan = false) => {
|
|
8
|
+
return vowels.test(text) ? new Text(text, { qametsQatan }).text : text;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/rules.ts
|
|
12
|
+
import { Cluster } from "havarotjs/dist/cluster";
|
|
13
|
+
|
|
14
|
+
// src/hebCharsTrans.ts
|
|
15
|
+
var transliterateMap = {
|
|
16
|
+
"\u05B0": "VOCAL_SHEVA",
|
|
17
|
+
"\u05B1": "HATAF_SEGOL",
|
|
18
|
+
"\u05B2": "HATAF_PATAH",
|
|
19
|
+
"\u05B3": "HATAF_QAMATS",
|
|
20
|
+
"\u05B4": "HIRIQ",
|
|
21
|
+
"\u05B5": "TSERE",
|
|
22
|
+
"\u05B6": "SEGOL",
|
|
23
|
+
"\u05B7": "PATAH",
|
|
24
|
+
"\u05B8": "QAMATS",
|
|
25
|
+
"\u05B9": "HOLAM",
|
|
26
|
+
"\u05BA": "HOLAM",
|
|
27
|
+
"\u05BB": "QUBUTS",
|
|
28
|
+
"\u05BC": "DAGESH",
|
|
29
|
+
"\u05BE": "MAQAF",
|
|
30
|
+
"\u05C0": "PASEQ",
|
|
31
|
+
"\u05C3": "SOF_PASUQ",
|
|
32
|
+
"\u05C7": "QAMATS_QATAN",
|
|
33
|
+
\u05D0: "ALEF",
|
|
34
|
+
\u05D1: "BET",
|
|
35
|
+
\u05D2: "GIMEL",
|
|
36
|
+
\u05D3: "DALET",
|
|
37
|
+
\u05D4: "HE",
|
|
38
|
+
\u05D5: "VAV",
|
|
39
|
+
\u05D6: "ZAYIN",
|
|
40
|
+
\u05D7: "HET",
|
|
41
|
+
\u05D8: "TET",
|
|
42
|
+
\u05D9: "YOD",
|
|
43
|
+
\u05DA: "FINAL_KAF",
|
|
44
|
+
\u05DB: "KAF",
|
|
45
|
+
\u05DC: "LAMED",
|
|
46
|
+
\u05DD: "FINAL_MEM",
|
|
47
|
+
\u05DE: "MEM",
|
|
48
|
+
\u05DF: "FINAL_NUN",
|
|
49
|
+
\u05E0: "NUN",
|
|
50
|
+
\u05E1: "SAMEKH",
|
|
51
|
+
\u05E2: "AYIN",
|
|
52
|
+
\u05E3: "FINAL_PE",
|
|
53
|
+
\u05E4: "PE",
|
|
54
|
+
\u05E5: "FINAL_TSADI",
|
|
55
|
+
\u05E6: "TSADI",
|
|
56
|
+
\u05E7: "QOF",
|
|
57
|
+
\u05E8: "RESH",
|
|
58
|
+
\u05E9: "SHIN",
|
|
59
|
+
\u05EA: "TAV"
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/mapChars.ts
|
|
63
|
+
var mapChars = (text, schema) => [...text].map((char) => char in transliterateMap ? schema[transliterateMap[char]] : char).join("");
|
|
64
|
+
|
|
65
|
+
// src/rules.ts
|
|
66
|
+
var taamim = /[\u{0590}-\u{05AF}\u{05BD}\u{05BF}]/u;
|
|
67
|
+
var changeElementSplit = (input, split, join) => input.split(split).join(join);
|
|
68
|
+
var consonantFeatures = (clusterText, syl, cluster, schema) => {
|
|
69
|
+
var _a;
|
|
70
|
+
if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
|
|
71
|
+
const clusterSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "cluster");
|
|
72
|
+
for (const seq of clusterSeqs) {
|
|
73
|
+
const heb = new RegExp(seq.HEBREW, "u");
|
|
74
|
+
if (heb.test(clusterText)) {
|
|
75
|
+
const sylSeq = changeElementSplit(clusterText, heb, seq.TRANSLITERATION);
|
|
76
|
+
return [...sylSeq].map((char) => mapChars(char, schema)).join("");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
clusterText = cluster.hasShewa && syl.isClosed ? clusterText.replace(/\u{05B0}/u, "") : clusterText;
|
|
81
|
+
if (/ה\u{05BC}$/mu.test(clusterText)) {
|
|
82
|
+
return changeElementSplit(clusterText, /ה\u{05BC}/u, schema.HE);
|
|
83
|
+
}
|
|
84
|
+
if (syl.isFinal && !syl.isClosed) {
|
|
85
|
+
const furtiveChet = /\u{05D7}\u{05B7}$/mu;
|
|
86
|
+
if (furtiveChet.test(clusterText)) {
|
|
87
|
+
return changeElementSplit(clusterText, furtiveChet, "\u05B7\u05D7");
|
|
88
|
+
}
|
|
89
|
+
const furtiveAyin = /\u{05E2}\u{05B7}$/mu;
|
|
90
|
+
if (furtiveAyin.test(clusterText)) {
|
|
91
|
+
return changeElementSplit(clusterText, furtiveAyin, "\u05B7\u05E2");
|
|
92
|
+
}
|
|
93
|
+
const furtiveHe = /\u{05D4}\u{05BC}\u{05B7}$/mu;
|
|
94
|
+
if (furtiveHe.test(clusterText)) {
|
|
95
|
+
return changeElementSplit(clusterText, furtiveHe, "\u05B7\u05D4\u05BC");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const prevHasVowel = cluster.prev instanceof Cluster ? cluster.prev.hasVowel : false;
|
|
99
|
+
const isDoubled = schema.DAGESH_CHAZAQ && prevHasVowel && /\u{05BC}/u.test(clusterText);
|
|
100
|
+
if (schema.BET_DAGESH && /ב\u{05BC}/u.test(clusterText)) {
|
|
101
|
+
return changeElementSplit(clusterText, /ב\u{05BC}/u, schema.BET_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
102
|
+
}
|
|
103
|
+
if (schema.GIMEL_DAGESH && /ג\u{05BC}/u.test(clusterText)) {
|
|
104
|
+
return changeElementSplit(clusterText, /ג\u{05BC}/u, schema.GIMEL_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
105
|
+
}
|
|
106
|
+
if (schema.DALET_DAGESH && /ד\u{05BC}/u.test(clusterText)) {
|
|
107
|
+
return changeElementSplit(clusterText, /ד\u{05BC}/u, schema.DALET_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
108
|
+
}
|
|
109
|
+
if (schema.KAF_DAGESH && /כ\u{05BC}/u.test(clusterText)) {
|
|
110
|
+
return changeElementSplit(clusterText, /כ\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
111
|
+
}
|
|
112
|
+
if (schema.KAF_DAGESH && /ך\u{05BC}/u.test(clusterText)) {
|
|
113
|
+
return changeElementSplit(clusterText, /ך\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
114
|
+
}
|
|
115
|
+
if (schema.PE_DAGESH && /פ\u{05BC}/u.test(clusterText)) {
|
|
116
|
+
return changeElementSplit(clusterText, /פ\u{05BC}/u, schema.PE_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
117
|
+
}
|
|
118
|
+
if (schema.TAV_DAGESH && /ת\u{05BC}/u.test(clusterText)) {
|
|
119
|
+
return changeElementSplit(clusterText, /ת\u{05BC}/u, schema.TAV_DAGESH.repeat(isDoubled ? 2 : 1));
|
|
120
|
+
}
|
|
121
|
+
if (/ש\u{05C1}/u.test(clusterText)) {
|
|
122
|
+
return changeElementSplit(clusterText, /ש\u{05C1}/u, schema.SHIN.repeat(isDoubled ? 2 : 1));
|
|
123
|
+
}
|
|
124
|
+
if (/ש\u{05C2}/u.test(clusterText)) {
|
|
125
|
+
return changeElementSplit(clusterText, /ש\u{05C2}/u, schema.SIN.repeat(isDoubled ? 2 : 1));
|
|
126
|
+
}
|
|
127
|
+
if (isDoubled) {
|
|
128
|
+
const consonant = cluster.chars[0].text;
|
|
129
|
+
const consonantDagesh = new RegExp(consonant + "\u05BC", "u");
|
|
130
|
+
return changeElementSplit(clusterText, consonantDagesh, `${consonant + consonant}`);
|
|
131
|
+
}
|
|
132
|
+
if (cluster.isShureq) {
|
|
133
|
+
return schema.SHUREQ;
|
|
134
|
+
}
|
|
135
|
+
return clusterText;
|
|
136
|
+
};
|
|
137
|
+
var materFeatures = (syl, schema) => {
|
|
138
|
+
const mater = syl.clusters.filter((c) => c.isMater)[0];
|
|
139
|
+
const prev = mater.prev instanceof Cluster ? mater.prev : null;
|
|
140
|
+
const materText = mater.text;
|
|
141
|
+
const prevText = ((prev == null ? void 0 : prev.text) || "").replace(taamim, "");
|
|
142
|
+
let noMaterText = syl.clusters.filter((c) => !c.isMater).map((c) => consonantFeatures(c.text.replace(taamim, ""), syl, c, schema)).join("");
|
|
143
|
+
const hasMaqaf = mater.text.includes("\u05BE");
|
|
144
|
+
noMaterText = hasMaqaf ? noMaterText.concat("\u05BE") : noMaterText;
|
|
145
|
+
if (/י/.test(materText)) {
|
|
146
|
+
if (/\u{05B4}/u.test(prevText)) {
|
|
147
|
+
return changeElementSplit(noMaterText, /\u{05B4}/u, schema.HIRIQ_YOD);
|
|
148
|
+
}
|
|
149
|
+
if (/\u{05B5}/u.test(prevText)) {
|
|
150
|
+
return changeElementSplit(noMaterText, /\u{05B5}/u, schema.TSERE_YOD);
|
|
151
|
+
}
|
|
152
|
+
if (/\u{05B6}/u.test(prevText)) {
|
|
153
|
+
return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_YOD);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (/ו/u.test(materText)) {
|
|
157
|
+
if (/\u{05B9}/u.test(prevText)) {
|
|
158
|
+
return changeElementSplit(noMaterText, /\u{05B9}/u, schema.HOLAM_VAV);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (/ה/.test(materText)) {
|
|
162
|
+
if (/\u{05B8}/u.test(prevText)) {
|
|
163
|
+
return changeElementSplit(noMaterText, /\u{05B8}/u, schema.QAMATS_HE);
|
|
164
|
+
}
|
|
165
|
+
if (/\u{05B6}/u.test(prevText)) {
|
|
166
|
+
return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_HE);
|
|
167
|
+
}
|
|
168
|
+
if (/\u{05B5}/u.test(prevText)) {
|
|
169
|
+
return changeElementSplit(noMaterText, /\u{05B5}/u, schema.SEGOL_HE);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return materText;
|
|
173
|
+
};
|
|
174
|
+
var joinChars = (isAccented, sylChars, schema) => {
|
|
175
|
+
if (!isAccented) {
|
|
176
|
+
return sylChars.map((char) => mapChars(char, schema)).join("");
|
|
177
|
+
}
|
|
178
|
+
if (schema.STRESS_MARKER) {
|
|
179
|
+
const location = schema.STRESS_MARKER.location;
|
|
180
|
+
const mark = schema.STRESS_MARKER.mark;
|
|
181
|
+
if (location === "before-syllable") {
|
|
182
|
+
return `${mark}${sylChars.map((char) => mapChars(char, schema)).join("")}`;
|
|
183
|
+
}
|
|
184
|
+
if (location === "after-syllable") {
|
|
185
|
+
return `${sylChars.map((char) => mapChars(char, schema)).join("")}${mark}`;
|
|
186
|
+
}
|
|
187
|
+
const vowels3 = [
|
|
188
|
+
schema.PATAH,
|
|
189
|
+
schema.HATAF_PATAH,
|
|
190
|
+
schema.QAMATS,
|
|
191
|
+
schema.HATAF_QAMATS,
|
|
192
|
+
schema.SEGOL,
|
|
193
|
+
schema.HATAF_SEGOL,
|
|
194
|
+
schema.TSERE,
|
|
195
|
+
schema.HIRIQ,
|
|
196
|
+
schema.HOLAM,
|
|
197
|
+
schema.QAMATS_QATAN,
|
|
198
|
+
schema.QUBUTS,
|
|
199
|
+
schema.QAMATS_HE,
|
|
200
|
+
schema.SEGOL_HE,
|
|
201
|
+
schema.TSERE_HE,
|
|
202
|
+
schema.HIRIQ_YOD,
|
|
203
|
+
schema.TSERE_YOD,
|
|
204
|
+
schema.SEGOL_YOD,
|
|
205
|
+
schema.HOLAM_VAV,
|
|
206
|
+
schema.SHUREQ
|
|
207
|
+
].sort((a, b) => b.length - a.length);
|
|
208
|
+
const vowelRgx = new RegExp(`${vowels3.join("|")}`);
|
|
209
|
+
const str = sylChars.map((char) => mapChars(char, schema)).join("");
|
|
210
|
+
const match = str.match(vowelRgx);
|
|
211
|
+
if (location === "before-vowel") {
|
|
212
|
+
return (match == null ? void 0 : match.length) ? str.replace(match[0], `${mark}${match[0]}`) : str;
|
|
213
|
+
}
|
|
214
|
+
return (match == null ? void 0 : match.length) ? str.replace(match[0], `${match[0]}${mark}`) : str;
|
|
215
|
+
}
|
|
216
|
+
return sylChars.map((char) => mapChars(char, schema)).join("");
|
|
217
|
+
};
|
|
218
|
+
var sylRules = (syl, schema) => {
|
|
219
|
+
var _a;
|
|
220
|
+
const sylTxt = syl.text.replace(taamim, "");
|
|
221
|
+
if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
|
|
222
|
+
const sylSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "syllable");
|
|
223
|
+
for (const seq of sylSeqs) {
|
|
224
|
+
const heb = new RegExp(seq.HEBREW, "u");
|
|
225
|
+
if (heb.test(sylTxt)) {
|
|
226
|
+
const wordSeq = changeElementSplit(sylTxt, heb, seq.TRANSLITERATION);
|
|
227
|
+
return joinChars(syl.isAccented, [...wordSeq], schema);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const mSSuffix = /\u{05B8}\u{05D9}\u{05D5}/u;
|
|
232
|
+
if (syl.isFinal && mSSuffix.test(sylTxt)) {
|
|
233
|
+
const sufxSyl = changeElementSplit(sylTxt, mSSuffix, schema.MS_SUFX);
|
|
234
|
+
return joinChars(syl.isAccented, [...sufxSyl], schema);
|
|
235
|
+
}
|
|
236
|
+
const hasMater = syl.clusters.map((c) => c.isMater).includes(true);
|
|
237
|
+
if (hasMater) {
|
|
238
|
+
const materSyl = materFeatures(syl, schema);
|
|
239
|
+
return joinChars(syl.isAccented, [...materSyl], schema);
|
|
240
|
+
}
|
|
241
|
+
const returnTxt = syl.clusters.map((cluster) => {
|
|
242
|
+
const clusterText = cluster.text.replace(taamim, "");
|
|
243
|
+
return consonantFeatures(clusterText, syl, cluster, schema);
|
|
244
|
+
});
|
|
245
|
+
return joinChars(syl.isAccented, returnTxt, schema);
|
|
246
|
+
};
|
|
247
|
+
var wordRules = (word, schema) => {
|
|
248
|
+
var _a;
|
|
249
|
+
if (word.isDivineName)
|
|
250
|
+
return schema.DIVINE_NAME;
|
|
251
|
+
if (word.hasDivineName)
|
|
252
|
+
return `${sylRules(word.syllables[0], schema)}-${schema.DIVINE_NAME}`;
|
|
253
|
+
if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
|
|
254
|
+
const wordSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "word");
|
|
255
|
+
for (const seq of wordSeqs) {
|
|
256
|
+
const heb = new RegExp(seq.HEBREW, "u");
|
|
257
|
+
const wordText = word.text.replace(taamim, "");
|
|
258
|
+
if (heb.test(wordText)) {
|
|
259
|
+
const wordSeq = changeElementSplit(wordText, heb, seq.TRANSLITERATION);
|
|
260
|
+
return [...wordSeq].map((char) => mapChars(char, schema)).join("");
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return word;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/schema.ts
|
|
268
|
+
var Schema = class {
|
|
269
|
+
constructor(schema) {
|
|
270
|
+
this.VOCAL_SHEVA = schema.VOCAL_SHEVA, this.HATAF_SEGOL = schema.HATAF_SEGOL, this.HATAF_PATAH = schema.HATAF_PATAH, this.HATAF_QAMATS = schema.HATAF_QAMATS, this.HIRIQ = schema.HIRIQ, this.TSERE = schema.TSERE, this.SEGOL = schema.SEGOL, this.PATAH = schema.PATAH, this.QAMATS = schema.QAMATS, this.HOLAM = schema.HOLAM, this.QUBUTS = schema.QUBUTS, this.DAGESH = schema.DAGESH, this.DAGESH_CHAZAQ = schema.DAGESH_CHAZAQ, this.MAQAF = schema.MAQAF, this.PASEQ = schema.PASEQ, this.SOF_PASUQ = schema.SOF_PASUQ, this.QAMATS_QATAN = schema.QAMATS_QATAN, this.FURTIVE_PATAH = schema.FURTIVE_PATAH, this.HIRIQ_YOD = schema.HIRIQ_YOD, this.TSERE_YOD = schema.TSERE_YOD, this.SEGOL_YOD = schema.SEGOL_YOD, this.SHUREQ = schema.SHUREQ, this.HOLAM_VAV = schema.HOLAM_VAV, this.QAMATS_HE = schema.QAMATS_HE, this.SEGOL_HE = schema.SEGOL_HE, this.TSERE_HE = schema.TSERE_HE, this.MS_SUFX = schema.MS_SUFX, this.ALEF = schema.ALEF, this.BET_DAGESH = schema.BET_DAGESH, this.BET = schema.BET, this.GIMEL = schema.GIMEL, this.GIMEL_DAGESH = schema.GIMEL_DAGESH, this.DALET = schema.DALET, this.DALET_DAGESH = schema.DALET_DAGESH, this.HE = schema.HE, this.VAV = schema.VAV, this.ZAYIN = schema.ZAYIN, this.HET = schema.HET, this.TET = schema.TET, this.YOD = schema.YOD, this.FINAL_KAF = schema.FINAL_KAF, this.KAF = schema.KAF, this.KAF_DAGESH = schema.KAF_DAGESH, this.LAMED = schema.LAMED, this.FINAL_MEM = schema.FINAL_MEM, this.MEM = schema.MEM, this.FINAL_NUN = schema.FINAL_NUN, this.NUN = schema.NUN, this.SAMEKH = schema.SAMEKH, this.AYIN = schema.AYIN, this.FINAL_PE = schema.FINAL_PE, this.PE = schema.PE, this.PE_DAGESH = schema.PE_DAGESH, this.FINAL_TSADI = schema.FINAL_TSADI, this.TSADI = schema.TSADI, this.QOF = schema.QOF, this.RESH = schema.RESH, this.SHIN = schema.SHIN, this.SIN = schema.SIN, this.TAV = schema.TAV, this.TAV_DAGESH = schema.TAV_DAGESH, this.DIVINE_NAME = schema.DIVINE_NAME, this.SYLLABLE_SEPARATOR = schema.SYLLABLE_SEPARATOR, this.ADDITIONAL_FEATURES = schema.ADDITIONAL_FEATURES, this.STRESS_MARKER = schema.STRESS_MARKER, this.longVowels = schema.longVowels, this.qametsQatan = schema.qametsQatan, this.sqnmlvy = schema.sqnmlvy, this.wawShureq = schema.wawShureq, this.article = schema.article;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var SBL = class extends Schema {
|
|
274
|
+
constructor(schema) {
|
|
275
|
+
super({
|
|
276
|
+
VOCAL_SHEVA: schema.VOCAL_SHEVA || "\u01DD",
|
|
277
|
+
HATAF_SEGOL: schema.HATAF_SEGOL || "\u0115",
|
|
278
|
+
HATAF_PATAH: schema.HATAF_PATAH || "\u0103",
|
|
279
|
+
HATAF_QAMATS: schema.HATAF_QAMATS || "\u014F",
|
|
280
|
+
HIRIQ: schema.HIRIQ || "i",
|
|
281
|
+
TSERE: schema.TSERE || "\u0113",
|
|
282
|
+
SEGOL: schema.SEGOL || "e",
|
|
283
|
+
PATAH: schema.PATAH || "a",
|
|
284
|
+
QAMATS: schema.QAMATS || "\u0101",
|
|
285
|
+
HOLAM: schema.HOLAM || "\u014D",
|
|
286
|
+
QUBUTS: schema.QUBUTS || "\u016B",
|
|
287
|
+
DAGESH: schema.DAGESH || "",
|
|
288
|
+
DAGESH_CHAZAQ: (_a = schema.DAGESH_CHAZAQ) != null ? _a : true,
|
|
289
|
+
MAQAF: schema.MAQAF || "-",
|
|
290
|
+
PASEQ: schema.PASEQ || "",
|
|
291
|
+
SOF_PASUQ: schema.SOF_PASUQ || "",
|
|
292
|
+
QAMATS_QATAN: schema.QAMATS_QATAN || "o",
|
|
293
|
+
FURTIVE_PATAH: schema.FURTIVE_PATAH || "a",
|
|
294
|
+
HIRIQ_YOD: schema.HIRIQ_YOD || "\xEE",
|
|
295
|
+
TSERE_YOD: schema.TSERE_YOD || "\xEA",
|
|
296
|
+
SEGOL_YOD: schema.SEGOL_YOD || "\xEA",
|
|
297
|
+
SHUREQ: schema.SHUREQ || "\xFB",
|
|
298
|
+
HOLAM_VAV: schema.HOLAM_VAV || "\xF4",
|
|
299
|
+
QAMATS_HE: schema.QAMATS_HE || "\xE2",
|
|
300
|
+
SEGOL_HE: schema.SEGOL_HE || "\xEA",
|
|
301
|
+
TSERE_HE: schema.TSERE_HE || "\xEA",
|
|
302
|
+
MS_SUFX: schema.MS_SUFX || "\u0101yw",
|
|
303
|
+
ALEF: schema.ALEF || "\u02BE",
|
|
304
|
+
BET: schema.BET || "b",
|
|
305
|
+
BET_DAGESH: schema.BET_DAGESH || void 0,
|
|
306
|
+
GIMEL: schema.GIMEL || "g",
|
|
307
|
+
GIMEL_DAGESH: schema.GIMEL_DAGESH || void 0,
|
|
308
|
+
DALET: schema.DALET || "d",
|
|
309
|
+
DALET_DAGESH: schema.DALET_DAGESH || void 0,
|
|
310
|
+
HE: schema.HE || "h",
|
|
311
|
+
VAV: schema.VAV || "w",
|
|
312
|
+
ZAYIN: schema.ZAYIN || "z",
|
|
313
|
+
HET: schema.HET || "\u1E25",
|
|
314
|
+
TET: schema.TET || "\u1E6D",
|
|
315
|
+
YOD: schema.YOD || "y",
|
|
316
|
+
FINAL_KAF: schema.FINAL_KAF || "k",
|
|
317
|
+
KAF: schema.KAF || "k",
|
|
318
|
+
KAF_DAGESH: schema.KAF_DAGESH || void 0,
|
|
319
|
+
LAMED: schema.LAMED || "l",
|
|
320
|
+
FINAL_MEM: schema.FINAL_MEM || "m",
|
|
321
|
+
MEM: schema.MEM || "m",
|
|
322
|
+
FINAL_NUN: schema.FINAL_NUN || "n",
|
|
323
|
+
NUN: schema.NUN || "n",
|
|
324
|
+
SAMEKH: schema.SAMEKH || "s",
|
|
325
|
+
AYIN: schema.AYIN || "\u02BF",
|
|
326
|
+
FINAL_PE: schema.FINAL_PE || "p",
|
|
327
|
+
PE: schema.PE || "p",
|
|
328
|
+
PE_DAGESH: schema.PE_DAGESH || void 0,
|
|
329
|
+
FINAL_TSADI: schema.FINAL_TSADI || "\u1E63",
|
|
330
|
+
TSADI: schema.TSADI || "\u1E63",
|
|
331
|
+
QOF: schema.QOF || "q",
|
|
332
|
+
RESH: schema.RESH || "r",
|
|
333
|
+
SHIN: schema.SHIN || "\u0161",
|
|
334
|
+
SIN: schema.SIN || "\u015B",
|
|
335
|
+
TAV: schema.TAV || "t",
|
|
336
|
+
TAV_DAGESH: schema.TAV_DAGESH || void 0,
|
|
337
|
+
DIVINE_NAME: schema.DIVINE_NAME || "yhwh",
|
|
338
|
+
SYLLABLE_SEPARATOR: schema.SYLLABLE_SEPARATOR || void 0,
|
|
339
|
+
ADDITIONAL_FEATURES: schema.ADDITIONAL_FEATURES || void 0,
|
|
340
|
+
STRESS_MARKER: schema.STRESS_MARKER || void 0,
|
|
341
|
+
longVowels: (_b = schema.longVowels) != null ? _b : true,
|
|
342
|
+
qametsQatan: (_c = schema.qametsQatan) != null ? _c : true,
|
|
343
|
+
sqnmlvy: (_d = schema.sqnmlvy) != null ? _d : true,
|
|
344
|
+
wawShureq: (_e = schema.wawShureq) != null ? _e : true,
|
|
345
|
+
article: (_f = schema.article) != null ? _f : true
|
|
346
|
+
});
|
|
347
|
+
var _a, _b, _c, _d, _e, _f;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// src/transliterate.ts
|
|
352
|
+
import { Text as Text2 } from "havarotjs";
|
|
353
|
+
import { Word } from "havarotjs/dist/word";
|
|
354
|
+
var getSylOpts = (schema) => {
|
|
355
|
+
const options = {};
|
|
356
|
+
if ("longVowels" in schema)
|
|
357
|
+
options.longVowels = schema.longVowels;
|
|
358
|
+
if ("qametsQatan" in schema)
|
|
359
|
+
options.qametsQatan = schema.qametsQatan;
|
|
360
|
+
if ("sqnmlvy" in schema)
|
|
361
|
+
options.sqnmlvy = schema.sqnmlvy;
|
|
362
|
+
if ("wawShureq" in schema)
|
|
363
|
+
options.wawShureq = schema.wawShureq;
|
|
364
|
+
if ("article" in schema)
|
|
365
|
+
options.article = schema.article;
|
|
366
|
+
return options;
|
|
367
|
+
};
|
|
368
|
+
var transliterate = (text, schema) => {
|
|
369
|
+
const transSchema = schema instanceof Schema ? schema : new SBL(schema != null ? schema : {});
|
|
370
|
+
const isText = text instanceof Text2;
|
|
371
|
+
if (!isText && !vowels.test(text))
|
|
372
|
+
return mapChars(text, transSchema);
|
|
373
|
+
const sylOptions = getSylOpts(transSchema != null ? transSchema : {});
|
|
374
|
+
const newText = isText ? text : new Text2(text, sylOptions);
|
|
375
|
+
return newText.words.map((word) => {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
let transliteration = wordRules(word, transSchema);
|
|
378
|
+
if (transliteration instanceof Word) {
|
|
379
|
+
transliteration = word.syllables.map((s) => sylRules(s, transSchema)).join((_a = transSchema.SYLLABLE_SEPARATOR) != null ? _a : "");
|
|
380
|
+
}
|
|
381
|
+
return `${transliteration}${(_b = word.whiteSpaceAfter) != null ? _b : ""}`;
|
|
382
|
+
}).join("");
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/remove.ts
|
|
386
|
+
var cantillation = /[\u{0591}-\u{05AF}\u{05BF}\u{05C0}\u{05C3}-\u{05C6}\u{05F3}\u{05F4}]/gu;
|
|
387
|
+
var vowels2 = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/gu;
|
|
388
|
+
var shinDot = /\u{05C1}/gu;
|
|
389
|
+
var sinDot = /\u{05C2}/gu;
|
|
390
|
+
var removeItem = (text, item) => text.replace(item, "");
|
|
391
|
+
var remove = (text, { removeVowels = false, removeShinDot = false, removeSinDot = false } = {}) => {
|
|
392
|
+
const sequenced = sequence(text);
|
|
393
|
+
const remCantillation = removeItem(sequenced, cantillation);
|
|
394
|
+
const remVowels = removeVowels ? removeItem(remCantillation, vowels2) : remCantillation;
|
|
395
|
+
const remShin = removeShinDot ? removeItem(remVowels, shinDot) : remVowels;
|
|
396
|
+
return removeSinDot ? removeItem(remShin, sinDot) : remShin;
|
|
397
|
+
};
|
|
398
|
+
export {
|
|
399
|
+
Schema,
|
|
400
|
+
Text3 as Text,
|
|
401
|
+
remove,
|
|
402
|
+
sequence,
|
|
403
|
+
transliterate
|
|
404
|
+
};
|