hebrew-transliteration 2.7.0 → 2.8.1
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/cjs/rules.js +132 -130
- package/dist/cjs/rules.js.map +3 -3
- package/dist/cjs/schema.js +23 -9
- package/dist/cjs/schema.js.map +3 -3
- package/dist/cjs/schemas/jss.js +1 -1
- package/dist/cjs/schemas/jss.js.map +1 -1
- package/dist/cjs/schemas/sblAcademicSpirantization.js +1 -1
- package/dist/cjs/schemas/sblAcademicSpirantization.js.map +1 -1
- package/dist/cjs/schemas/tiberian.js +9 -4
- package/dist/cjs/schemas/tiberian.js.map +2 -2
- package/dist/esm/rules.js +182 -180
- package/dist/esm/rules.js.map +1 -1
- package/dist/esm/schema.js +31 -17
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/schemas/jss.js +1 -1
- package/dist/esm/schemas/sblAcademicSpirantization.js +1 -1
- package/dist/esm/schemas/tiberian.js +17 -6
- package/dist/esm/schemas/tiberian.js.map +1 -1
- package/dist/types/rules.d.ts +0 -18
- package/dist/types/schema.d.ts +42 -22
- package/package.json +3 -3
package/dist/cjs/rules.js
CHANGED
|
@@ -17,24 +17,63 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var rules_exports = {};
|
|
19
19
|
__export(rules_exports, {
|
|
20
|
-
replaceAndTransliterate: () => replaceAndTransliterate,
|
|
21
20
|
sylRules: () => sylRules,
|
|
22
21
|
wordRules: () => wordRules
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(rules_exports);
|
|
25
24
|
var import_cluster = require("havarotjs/cluster");
|
|
26
25
|
var import_syllable = require("havarotjs/syllable");
|
|
27
|
-
var import_word = require("havarotjs/word");
|
|
28
26
|
var import_regularExpressions = require("havarotjs/utils/regularExpressions");
|
|
27
|
+
var import_word = require("havarotjs/word");
|
|
29
28
|
var import_hebCharsTrans = require("./hebCharsTrans.js");
|
|
30
29
|
const taamim = /[\u{0590}-\u{05AF}\u{05BD}\u{05BF}]/gu;
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
const copySyllable = (newText, old) => {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
32
|
+
const newClusters = newText.split(import_regularExpressions.clusterSplitGroup).map((clusterString) => new import_cluster.Cluster(clusterString, true));
|
|
33
|
+
const oldClusters = old.clusters;
|
|
34
|
+
if (newClusters.length === oldClusters.length) {
|
|
35
|
+
newClusters.forEach((c, i) => {
|
|
36
|
+
var _a2, _b2, _c2, _d2;
|
|
37
|
+
return c.prev = (_b2 = (_a2 = oldClusters[i]) == null ? void 0 : _a2.prev) != null ? _b2 : null, c.next = (_d2 = (_c2 = oldClusters[i]) == null ? void 0 : _c2.next) != null ? _d2 : null;
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
for (let i = 0; i < newClusters.length; i++) {
|
|
41
|
+
const c = newClusters[i];
|
|
42
|
+
if (((_a = oldClusters[i]) == null ? void 0 : _a.text[0]) === (c == null ? void 0 : c.text[0])) {
|
|
43
|
+
c.prev = (_c = (_b = oldClusters[i]) == null ? void 0 : _b.prev) != null ? _c : null;
|
|
44
|
+
c.next = (_e = (_d = oldClusters[i]) == null ? void 0 : _d.next) != null ? _e : null;
|
|
45
|
+
} else {
|
|
46
|
+
c.prev = (_g = (_f = oldClusters[i]) == null ? void 0 : _f.prev) != null ? _g : null;
|
|
47
|
+
c.next = (_i = (_h = oldClusters[i + 1]) == null ? void 0 : _h.next) != null ? _i : null;
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const newSyl = new import_syllable.Syllable(newClusters, {
|
|
53
|
+
isClosed: old.isClosed,
|
|
54
|
+
isAccented: old.isAccented,
|
|
55
|
+
isFinal: old.isFinal
|
|
56
|
+
});
|
|
57
|
+
newClusters.forEach((c) => c.syllable = newSyl);
|
|
58
|
+
newSyl.prev = old.prev;
|
|
59
|
+
newSyl.next = old.next;
|
|
60
|
+
newSyl.word = old.word;
|
|
61
|
+
return newSyl;
|
|
33
62
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
63
|
+
const getDageshChazaqVal = (input, dagesh, isChazaq) => {
|
|
64
|
+
if (!isChazaq) {
|
|
65
|
+
return input;
|
|
66
|
+
}
|
|
67
|
+
if (typeof dagesh === "boolean") {
|
|
68
|
+
return input.repeat(2);
|
|
69
|
+
}
|
|
70
|
+
return input + dagesh;
|
|
71
|
+
};
|
|
72
|
+
const getDivineName = (str, schema) => {
|
|
73
|
+
const begn = str[0];
|
|
74
|
+
const end = str[str.length - 1];
|
|
75
|
+
const divineName = schema.DIVINE_NAME_ELOHIM && /\u{05B4}/u.test(str) ? schema.DIVINE_NAME_ELOHIM : schema.DIVINE_NAME;
|
|
76
|
+
return `${import_regularExpressions.hebChars.test(begn) ? "" : begn}${divineName}${import_regularExpressions.hebChars.test(end) ? "" : end}`;
|
|
38
77
|
};
|
|
39
78
|
const isDageshChazaq = (cluster, schema) => {
|
|
40
79
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -61,58 +100,6 @@ const isDageshChazaq = (cluster, schema) => {
|
|
|
61
100
|
}
|
|
62
101
|
return prevCoda === ((_f = cluster.syllable) == null ? void 0 : _f.onset);
|
|
63
102
|
};
|
|
64
|
-
const getDageshChazaqVal = (input, dagesh, isChazaq) => {
|
|
65
|
-
if (!isChazaq) {
|
|
66
|
-
return input;
|
|
67
|
-
}
|
|
68
|
-
if (typeof dagesh === "boolean") {
|
|
69
|
-
return input.repeat(2);
|
|
70
|
-
}
|
|
71
|
-
return input + dagesh;
|
|
72
|
-
};
|
|
73
|
-
const getDivineName = (str, schema) => {
|
|
74
|
-
const begn = str[0];
|
|
75
|
-
const end = str[str.length - 1];
|
|
76
|
-
const divineName = schema.DIVINE_NAME_ELOHIM && /\u{05B4}/u.test(str) ? schema.DIVINE_NAME_ELOHIM : schema.DIVINE_NAME;
|
|
77
|
-
return `${import_regularExpressions.hebChars.test(begn) ? "" : begn}${divineName}${import_regularExpressions.hebChars.test(end) ? "" : end}`;
|
|
78
|
-
};
|
|
79
|
-
const materFeatures = (syl, schema) => {
|
|
80
|
-
const mater = syl.clusters.filter((c) => c.isMater)[0];
|
|
81
|
-
const prev = mater.prev instanceof import_cluster.Cluster ? mater.prev : null;
|
|
82
|
-
const materText = mater.text;
|
|
83
|
-
const prevText = ((prev == null ? void 0 : prev.text) || "").replace(taamim, "");
|
|
84
|
-
let noMaterText = syl.clusters.filter((c) => !c.isMater).map((c) => consonantFeatures(c.text.replace(taamim, ""), syl, c, schema)).join("");
|
|
85
|
-
const hasMaqaf = mater.text.includes("\u05BE");
|
|
86
|
-
noMaterText = hasMaqaf ? noMaterText.concat("\u05BE") : noMaterText;
|
|
87
|
-
if (/י/.test(materText)) {
|
|
88
|
-
if (/\u{05B4}/u.test(prevText)) {
|
|
89
|
-
return replaceWithRegex(noMaterText, /\u{05B4}/u, schema.HIRIQ_YOD);
|
|
90
|
-
}
|
|
91
|
-
if (/\u{05B5}/u.test(prevText)) {
|
|
92
|
-
return replaceWithRegex(noMaterText, /\u{05B5}/u, schema.TSERE_YOD);
|
|
93
|
-
}
|
|
94
|
-
if (/\u{05B6}/u.test(prevText)) {
|
|
95
|
-
return replaceWithRegex(noMaterText, /\u{05B6}/u, schema.SEGOL_YOD);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (/ו/u.test(materText)) {
|
|
99
|
-
if (/\u{05B9}/u.test(prevText)) {
|
|
100
|
-
return replaceWithRegex(noMaterText, /\u{05B9}/u, schema.HOLAM_VAV);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (/ה/.test(materText)) {
|
|
104
|
-
if (/\u{05B8}/u.test(prevText)) {
|
|
105
|
-
return replaceWithRegex(noMaterText, /\u{05B8}/u, schema.QAMATS_HE);
|
|
106
|
-
}
|
|
107
|
-
if (/\u{05B6}/u.test(prevText)) {
|
|
108
|
-
return replaceWithRegex(noMaterText, /\u{05B6}/u, schema.SEGOL_HE);
|
|
109
|
-
}
|
|
110
|
-
if (/\u{05B5}/u.test(prevText)) {
|
|
111
|
-
return replaceWithRegex(noMaterText, /\u{05B5}/u, schema.TSERE_HE);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return materText;
|
|
115
|
-
};
|
|
116
103
|
const joinSyllableChars = (syl, sylChars, schema) => {
|
|
117
104
|
var _a, _b, _c;
|
|
118
105
|
const isInConstruct = (_a = syl.word) == null ? void 0 : _a.isInConstruct;
|
|
@@ -171,7 +158,7 @@ const joinSyllableChars = (syl, sylChars, schema) => {
|
|
|
171
158
|
schema.SEGOL_YOD,
|
|
172
159
|
schema.HOLAM_VAV,
|
|
173
160
|
schema.SHUREQ
|
|
174
|
-
].sort((a, b) => b.length - a.length);
|
|
161
|
+
].filter((v) => typeof v === "string").sort((a, b) => b.length - a.length);
|
|
175
162
|
const vowelRgx = new RegExp(`${vowels.join("|")}`);
|
|
176
163
|
const str = sylChars.map(mapChars(schema)).join("");
|
|
177
164
|
const match = str.match(vowelRgx);
|
|
@@ -182,30 +169,72 @@ const joinSyllableChars = (syl, sylChars, schema) => {
|
|
|
182
169
|
}
|
|
183
170
|
return sylChars.map(mapChars(schema)).join("");
|
|
184
171
|
};
|
|
185
|
-
const
|
|
172
|
+
const mapChars = (schema) => (input) => {
|
|
173
|
+
return [...input].map((char) => char in import_hebCharsTrans.transliterateMap ? schema[import_hebCharsTrans.transliterateMap[char]] : char).join("");
|
|
174
|
+
};
|
|
175
|
+
const materFeatures = (syl, schema) => {
|
|
176
|
+
const mater = syl.clusters.filter((c) => c.isMater)[0];
|
|
177
|
+
const prev = mater.prev instanceof import_cluster.Cluster ? mater.prev : null;
|
|
178
|
+
const materText = mater.text;
|
|
179
|
+
const prevText = ((prev == null ? void 0 : prev.text) || "").replace(taamim, "");
|
|
180
|
+
let noMaterText = syl.clusters.filter((c) => !c.isMater).map((c) => cluterRules(c, schema)).join("");
|
|
181
|
+
const hasMaqaf = mater.text.includes("\u05BE");
|
|
182
|
+
noMaterText = hasMaqaf ? noMaterText.concat("\u05BE") : noMaterText;
|
|
183
|
+
if (/י/.test(materText)) {
|
|
184
|
+
if (/\u{05B4}/u.test(prevText)) {
|
|
185
|
+
return replaceWithRegex(noMaterText, /\u{05B4}/u, schema.HIRIQ_YOD);
|
|
186
|
+
}
|
|
187
|
+
if (/\u{05B5}/u.test(prevText)) {
|
|
188
|
+
return replaceWithRegex(noMaterText, /\u{05B5}/u, schema.TSERE_YOD);
|
|
189
|
+
}
|
|
190
|
+
if (/\u{05B6}/u.test(prevText)) {
|
|
191
|
+
return replaceWithRegex(noMaterText, /\u{05B6}/u, schema.SEGOL_YOD);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (/ו/u.test(materText)) {
|
|
195
|
+
if (/\u{05B9}/u.test(prevText)) {
|
|
196
|
+
return replaceWithRegex(noMaterText, /\u{05B9}/u, schema.HOLAM_VAV);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (/ה/.test(materText)) {
|
|
200
|
+
if (/\u{05B8}/u.test(prevText)) {
|
|
201
|
+
return replaceWithRegex(noMaterText, /\u{05B8}/u, schema.QAMATS_HE);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return materText;
|
|
205
|
+
};
|
|
206
|
+
const removeTaamim = (input) => input.replace(taamim, "");
|
|
207
|
+
const replaceAndTransliterate = (input, regex, replaceValue, schema) => {
|
|
208
|
+
const sylSeq = replaceWithRegex(input, regex, replaceValue);
|
|
209
|
+
return [...sylSeq].map(mapChars(schema)).join("");
|
|
210
|
+
};
|
|
211
|
+
const replaceWithRegex = (input, regex, replaceValue) => input.replace(regex, replaceValue);
|
|
212
|
+
const cluterRules = (cluster, schema) => {
|
|
186
213
|
var _a, _b;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
214
|
+
let clusterText = removeTaamim(cluster.text);
|
|
215
|
+
const clusterFeatures = (_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.filter((seq) => seq.FEATURE === "cluster");
|
|
216
|
+
if (clusterFeatures) {
|
|
217
|
+
for (const feature of clusterFeatures) {
|
|
218
|
+
const heb = new RegExp(feature.HEBREW, "u");
|
|
219
|
+
if (feature.FEATURE === "cluster" && heb.test(clusterText)) {
|
|
220
|
+
const transliteration = feature.TRANSLITERATION;
|
|
221
|
+
const passThrough = (_b = feature.PASS_THROUGH) != null ? _b : true;
|
|
194
222
|
if (typeof transliteration === "string") {
|
|
195
223
|
return replaceAndTransliterate(clusterText, heb, transliteration, schema);
|
|
196
224
|
}
|
|
197
225
|
if (!passThrough) {
|
|
198
|
-
return transliteration(cluster,
|
|
226
|
+
return transliteration(cluster, feature.HEBREW, schema);
|
|
199
227
|
}
|
|
200
|
-
clusterText = transliteration(cluster,
|
|
228
|
+
clusterText = transliteration(cluster, feature.HEBREW, schema);
|
|
201
229
|
}
|
|
202
230
|
}
|
|
203
231
|
}
|
|
204
|
-
|
|
232
|
+
const syl = cluster.syllable;
|
|
233
|
+
clusterText = cluster.hasSheva && (syl == null ? void 0 : syl.isClosed) ? clusterText.replace(/\u{05B0}/u, "") : clusterText;
|
|
205
234
|
if (/ה\u{05BC}$/mu.test(clusterText)) {
|
|
206
235
|
return replaceWithRegex(clusterText, /ה\u{05BC}/u, schema.HE);
|
|
207
236
|
}
|
|
208
|
-
if (syl.isFinal && !syl.isClosed) {
|
|
237
|
+
if ((syl == null ? void 0 : syl.isFinal) && !(syl == null ? void 0 : syl.isClosed)) {
|
|
209
238
|
const furtiveChet = /\u{05D7}\u{05B7}$/mu;
|
|
210
239
|
if (furtiveChet.test(clusterText)) {
|
|
211
240
|
return replaceWithRegex(clusterText, furtiveChet, "\u05B7\u05D7");
|
|
@@ -257,56 +286,23 @@ const consonantFeatures = (clusterText, syl, cluster, schema) => {
|
|
|
257
286
|
}
|
|
258
287
|
return clusterText;
|
|
259
288
|
};
|
|
260
|
-
const copySyllable = (newText, old) => {
|
|
261
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
262
|
-
const newClusters = newText.split(import_regularExpressions.clusterSplitGroup).map((clusterString) => new import_cluster.Cluster(clusterString, true));
|
|
263
|
-
const oldClusters = old.clusters;
|
|
264
|
-
if (newClusters.length === oldClusters.length) {
|
|
265
|
-
newClusters.forEach((c, i) => {
|
|
266
|
-
var _a2, _b2, _c2, _d2;
|
|
267
|
-
return c.prev = (_b2 = (_a2 = oldClusters[i]) == null ? void 0 : _a2.prev) != null ? _b2 : null, c.next = (_d2 = (_c2 = oldClusters[i]) == null ? void 0 : _c2.next) != null ? _d2 : null;
|
|
268
|
-
});
|
|
269
|
-
} else {
|
|
270
|
-
for (let i = 0; i < newClusters.length; i++) {
|
|
271
|
-
const c = newClusters[i];
|
|
272
|
-
if (((_a = oldClusters[i]) == null ? void 0 : _a.text[0]) === (c == null ? void 0 : c.text[0])) {
|
|
273
|
-
c.prev = (_c = (_b = oldClusters[i]) == null ? void 0 : _b.prev) != null ? _c : null;
|
|
274
|
-
c.next = (_e = (_d = oldClusters[i]) == null ? void 0 : _d.next) != null ? _e : null;
|
|
275
|
-
} else {
|
|
276
|
-
c.prev = (_g = (_f = oldClusters[i]) == null ? void 0 : _f.prev) != null ? _g : null;
|
|
277
|
-
c.next = (_i = (_h = oldClusters[i + 1]) == null ? void 0 : _h.next) != null ? _i : null;
|
|
278
|
-
i++;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
const newSyl = new import_syllable.Syllable(newClusters, {
|
|
283
|
-
isClosed: old.isClosed,
|
|
284
|
-
isAccented: old.isAccented,
|
|
285
|
-
isFinal: old.isFinal
|
|
286
|
-
});
|
|
287
|
-
newClusters.forEach((c) => c.syllable = newSyl);
|
|
288
|
-
newSyl.prev = old.prev;
|
|
289
|
-
newSyl.next = old.next;
|
|
290
|
-
newSyl.word = old.word;
|
|
291
|
-
return newSyl;
|
|
292
|
-
};
|
|
293
289
|
const sylRules = (syl, schema) => {
|
|
294
290
|
var _a, _b;
|
|
295
291
|
const sylTxt = syl.text.replace(taamim, "");
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
for (const
|
|
299
|
-
const heb = new RegExp(
|
|
300
|
-
if (
|
|
301
|
-
const transliteration =
|
|
302
|
-
const passThrough = (_b =
|
|
292
|
+
const syllableFeatures = (_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.filter((seq) => seq.FEATURE === "syllable");
|
|
293
|
+
if (syllableFeatures) {
|
|
294
|
+
for (const feature of syllableFeatures) {
|
|
295
|
+
const heb = new RegExp(feature.HEBREW, "u");
|
|
296
|
+
if (feature.FEATURE === "syllable" && heb.test(sylTxt)) {
|
|
297
|
+
const transliteration = feature.TRANSLITERATION;
|
|
298
|
+
const passThrough = (_b = feature.PASS_THROUGH) != null ? _b : true;
|
|
303
299
|
if (typeof transliteration === "string") {
|
|
304
300
|
return replaceAndTransliterate(sylTxt, heb, transliteration, schema);
|
|
305
301
|
}
|
|
306
302
|
if (!passThrough) {
|
|
307
|
-
return transliteration(syl,
|
|
303
|
+
return transliteration(syl, feature.HEBREW, schema);
|
|
308
304
|
}
|
|
309
|
-
const newText = transliteration(syl,
|
|
305
|
+
const newText = transliteration(syl, feature.HEBREW, schema);
|
|
310
306
|
if (newText !== sylTxt) {
|
|
311
307
|
syl = copySyllable(newText, syl);
|
|
312
308
|
}
|
|
@@ -323,10 +319,17 @@ const sylRules = (syl, schema) => {
|
|
|
323
319
|
const materSyl = materFeatures(syl, schema);
|
|
324
320
|
return joinSyllableChars(syl, [...materSyl], schema);
|
|
325
321
|
}
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
322
|
+
if (schema.SEGOL_HE && /\u{05B6}\u{05D4}/u.test(sylTxt)) {
|
|
323
|
+
const returnTxt2 = syl.clusters.map((cluster) => cluterRules(cluster, schema));
|
|
324
|
+
const joined = joinSyllableChars(syl, returnTxt2, schema).replace(taamim, "");
|
|
325
|
+
return joined.replace(schema["SEGOL"] + schema["HE"], schema.SEGOL_HE);
|
|
326
|
+
}
|
|
327
|
+
if (schema.TSERE_HE && /\u{05B5}\u{05D4}/u.test(sylTxt)) {
|
|
328
|
+
const returnTxt2 = syl.clusters.map((cluster) => cluterRules(cluster, schema));
|
|
329
|
+
const joined = joinSyllableChars(syl, returnTxt2, schema).replace(taamim, "");
|
|
330
|
+
return joined.replace(schema["TSERE"] + schema["HE"], schema.TSERE_HE);
|
|
331
|
+
}
|
|
332
|
+
const returnTxt = syl.clusters.map((cluster) => cluterRules(cluster, schema));
|
|
330
333
|
return joinSyllableChars(syl, returnTxt, schema).replace(taamim, "");
|
|
331
334
|
};
|
|
332
335
|
const wordRules = (word, schema) => {
|
|
@@ -340,21 +343,21 @@ const wordRules = (word, schema) => {
|
|
|
340
343
|
if (word.isNotHebrew) {
|
|
341
344
|
return word.text;
|
|
342
345
|
}
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
const
|
|
346
|
-
for (const
|
|
347
|
-
const heb = new RegExp(
|
|
348
|
-
if (
|
|
349
|
-
const transliteration =
|
|
350
|
-
const passThrough = (_b =
|
|
346
|
+
const wordFeatures = (_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.filter((seq) => seq.FEATURE === "word");
|
|
347
|
+
if (wordFeatures) {
|
|
348
|
+
const text = word.text.replace(taamim, "");
|
|
349
|
+
for (const feature of wordFeatures) {
|
|
350
|
+
const heb = new RegExp(feature.HEBREW, "u");
|
|
351
|
+
if (heb.test(text)) {
|
|
352
|
+
const transliteration = feature.TRANSLITERATION;
|
|
353
|
+
const passThrough = (_b = feature.PASS_THROUGH) != null ? _b : true;
|
|
351
354
|
if (typeof transliteration === "string") {
|
|
352
355
|
return replaceAndTransliterate(text, heb, transliteration, schema);
|
|
353
356
|
}
|
|
354
357
|
if (!passThrough) {
|
|
355
|
-
return transliteration(word,
|
|
358
|
+
return transliteration(word, feature.HEBREW, schema);
|
|
356
359
|
}
|
|
357
|
-
return new import_word.Word(transliteration(word,
|
|
360
|
+
return new import_word.Word(transliteration(word, feature.HEBREW, schema), schema);
|
|
358
361
|
}
|
|
359
362
|
}
|
|
360
363
|
return word;
|
|
@@ -363,7 +366,6 @@ const wordRules = (word, schema) => {
|
|
|
363
366
|
};
|
|
364
367
|
// Annotate the CommonJS export names for ESM import in node:
|
|
365
368
|
0 && (module.exports = {
|
|
366
|
-
replaceAndTransliterate,
|
|
367
369
|
sylRules,
|
|
368
370
|
wordRules
|
|
369
371
|
});
|
package/dist/cjs/rules.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/rules.ts"],
|
|
4
|
-
"sourcesContent": ["import { Cluster } from \"havarotjs/cluster\";\nimport { Syllable } from \"havarotjs/syllable\";\nimport { Word } from \"havarotjs/word\";\nimport { hebChars, clusterSplitGroup } from \"havarotjs/utils/regularExpressions\";\nimport { Schema } from \"./schema\";\nimport { transliterateMap as map } from \"./hebCharsTrans\";\n\nconst taamim = /[\\u{0590}-\\u{05AF}\\u{05BD}\\u{05BF}]/gu;\n\n/**\n * maps Hebrew characters to schema\n *\n * @param input - text to be transliterated\n * @param schema - a {@link Schema} for transliterating the input\n * @returns transliteration of characters\n *\n */\nconst mapChars = (schema: Schema) => (input: string) => {\n return [...input].map((char: string) => (char in map ? schema[map[char]] : char)).join(\"\");\n};\n\n/**\n * a wrapper around String.replace() to constrain to a RegExp\n *\n * @param input the string to be modified\n * @param regex the regex to be used as the search value\n * @param replaceValue the string to replace the regex\n * @returns\n */\nconst replaceWithRegex = (input: string, regex: RegExp, replaceValue: string) => input.replace(regex, replaceValue);\n\n/**\n * replaces part of a string and transliterates the remaining characters according to the schema\n *\n * @example\n * ```ts\n * // replaces \u05D1\u05B8 as VA, but only when matching the regex sequence\n * const betAndQamats = /\\u{05D1}\\u{05B8}/u\n * replaceAndTransliterate(\"\u05D3\u05BC\u05B8\u05D1\u05B8\u05E8\", betAndQamats, \"VA\", schema);\n * // d\u0101VAr\n * ```\n *\n * @param input the text to be transliterated\n * @param regex the regex used as the search value\n * @param replaceValue the string to replace the regex\n * @param schema the Schema\n * @returns\n */\nexport const replaceAndTransliterate = (input: string, regex: RegExp, replaceValue: string, schema: Schema) => {\n const sylSeq = replaceWithRegex(input, regex, replaceValue);\n return [...sylSeq].map(mapChars(schema)).join(\"\");\n};\n\nconst isDageshChazaq = (cluster: Cluster, schema: Schema) => {\n // if there is no dagesh chazaq in the schema, then return false\n if (!schema.DAGESH_CHAZAQ) {\n return false;\n }\n\n // a shureq could potentially match because of dagesh\n if (cluster.isShureq) {\n return false;\n }\n\n // if there is no dagesh in the text, then return false\n if (!/\\u{05BC}/u.test(cluster.text)) {\n return false;\n }\n\n const prevWord = cluster.syllable?.word?.prev?.value;\n if (prevWord && prevWord?.isInConstruct && !prevWord.syllables[prevWord.syllables.length - 1].isClosed) {\n return true;\n }\n\n // this could be a code smell, b/c the copySyllable function results are not the most predictable\n const prevSyllable = cluster.syllable?.prev;\n if (!prevSyllable) {\n return false;\n }\n\n const prevCoda = prevSyllable.value?.codaWithGemination;\n if (!prevCoda) {\n return false;\n }\n\n return prevCoda === cluster.syllable?.onset;\n};\n\nconst getDageshChazaqVal = (input: string, dagesh: Schema[\"DAGESH_CHAZAQ\"], isChazaq: boolean) => {\n if (!isChazaq) {\n return input;\n }\n\n if (typeof dagesh === \"boolean\") {\n return input.repeat(2);\n }\n\n return input + dagesh;\n};\n\n/**\n * formats the Divine Name with any Latin chars\n *\n * @param str word text\n * @param schema\n * @returns the Divine Name with any pre or proceding Latin chars\n */\nconst getDivineName = (str: string, schema: Schema): string => {\n const begn = str[0];\n const end = str[str.length - 1];\n // if DN is pointed with a hiriq, then it is read as 'elohim\n const divineName =\n schema.DIVINE_NAME_ELOHIM && /\\u{05B4}/u.test(str) ? schema.DIVINE_NAME_ELOHIM : schema.DIVINE_NAME;\n return `${hebChars.test(begn) ? \"\" : begn}${divineName}${hebChars.test(end) ? \"\" : end}`;\n};\n\nconst materFeatures = (syl: Syllable, schema: Schema) => {\n const mater = syl.clusters.filter((c) => c.isMater)[0];\n const prev = mater.prev instanceof Cluster ? mater.prev : null;\n const materText = mater.text;\n const prevText = (prev?.text || \"\").replace(taamim, \"\");\n // string comprised of all non-mater clusters in a syl with a mater\n let noMaterText = syl.clusters\n .filter((c) => !c.isMater)\n .map((c) => consonantFeatures(c.text.replace(taamim, \"\"), syl, c, schema))\n .join(\"\");\n\n // workaround for maqaf\n const hasMaqaf = mater.text.includes(\"\u05BE\");\n noMaterText = hasMaqaf ? noMaterText.concat(\"\u05BE\") : noMaterText;\n\n if (/\u05D9/.test(materText)) {\n // hiriq\n if (/\\u{05B4}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B4}/u, schema.HIRIQ_YOD);\n }\n // tsere\n if (/\\u{05B5}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B5}/u, schema.TSERE_YOD);\n }\n // segol\n if (/\\u{05B6}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B6}/u, schema.SEGOL_YOD);\n }\n }\n\n if (/\u05D5/u.test(materText)) {\n // holam\n if (/\\u{05B9}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B9}/u, schema.HOLAM_VAV);\n }\n }\n\n if (/\u05D4/.test(materText)) {\n // qamets\n if (/\\u{05B8}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B8}/u, schema.QAMATS_HE);\n }\n\n // seghol\n if (/\\u{05B6}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B6}/u, schema.SEGOL_HE);\n }\n\n // tsere\n if (/\\u{05B5}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B5}/u, schema.TSERE_HE);\n }\n }\n\n return materText;\n};\n\nconst joinSyllableChars = (syl: Syllable, sylChars: string[], schema: Schema): string => {\n const isInConstruct = syl.word?.isInConstruct;\n\n if (isInConstruct) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (!syl.isAccented) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n // if syllable is only punctuation (e.g. a paseq), it should not receive a stress marker\n const isOnlyPunctuation = syl.clusters.map((c) => c.isPunctuation).every((c) => c);\n if (isOnlyPunctuation) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (schema.STRESS_MARKER) {\n const exclude = schema.STRESS_MARKER?.exclude ?? \"never\";\n\n if (exclude === \"single\" && !syl.prev && !syl.next) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (exclude === \"final\" && !syl.next) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n const location = schema.STRESS_MARKER.location;\n const mark = schema.STRESS_MARKER.mark;\n\n // if the stress marker is already present, no need to add it again\n if (syl.text.includes(mark)) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (location === \"before-syllable\") {\n const isDoubled = syl.clusters.map((c) => isDageshChazaq(c, schema)).includes(true);\n if (isDoubled) {\n const chars = sylChars.map(mapChars(schema)).join(\"\");\n const [first, ...rest] = chars;\n return `${first}${mark}${rest.join(\"\")}`;\n }\n\n return `${mark}${sylChars.map(mapChars(schema)).join(\"\")}`;\n }\n\n if (location === \"after-syllable\") {\n return `${sylChars.map(mapChars(schema)).join(\"\")}${mark}`;\n }\n\n const vowels = [\n schema.PATAH,\n schema.HATAF_PATAH,\n schema.QAMATS,\n schema.HATAF_QAMATS,\n schema.SEGOL,\n schema.HATAF_SEGOL,\n schema.TSERE,\n schema.HIRIQ,\n schema.HOLAM,\n schema.QAMATS_QATAN,\n schema.QUBUTS,\n schema.QAMATS_HE,\n schema.SEGOL_HE,\n schema.TSERE_HE,\n schema.HIRIQ_YOD,\n schema.TSERE_YOD,\n schema.SEGOL_YOD,\n schema.HOLAM_VAV,\n schema.SHUREQ\n ].sort((a, b) => b.length - a.length);\n const vowelRgx = new RegExp(`${vowels.join(\"|\")}`);\n const str = sylChars.map(mapChars(schema)).join(\"\");\n const match = str.match(vowelRgx);\n\n if (location === \"before-vowel\") {\n return match?.length ? str.replace(match[0], `${mark}${match[0]}`) : str;\n }\n\n // after-vowel\n return match?.length ? str.replace(match[0], `${match[0]}${mark}`) : str;\n }\n\n return sylChars.map(mapChars(schema)).join(\"\");\n};\n\nconst consonantFeatures = (clusterText: string, syl: Syllable, cluster: Cluster, schema: Schema) => {\n if (schema.ADDITIONAL_FEATURES?.length) {\n const seqs = schema.ADDITIONAL_FEATURES;\n for (const seq of seqs) {\n const heb = new RegExp(seq.HEBREW, \"u\");\n if (seq.FEATURE === \"cluster\" && heb.test(clusterText)) {\n const transliteration = seq.TRANSLITERATION;\n const passThrough = seq.PASS_THROUGH ?? true;\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(clusterText, heb, transliteration, schema);\n }\n if (!passThrough) {\n return transliteration(cluster, seq.HEBREW, schema);\n }\n clusterText = transliteration(cluster, seq.HEBREW, schema);\n }\n }\n }\n\n clusterText = cluster.hasSheva && syl.isClosed ? clusterText.replace(/\\u{05B0}/u, \"\") : clusterText;\n\n // mappiq he\n if (/\u05D4\\u{05BC}$/mu.test(clusterText)) {\n return replaceWithRegex(clusterText, /\u05D4\\u{05BC}/u, schema.HE);\n }\n\n if (syl.isFinal && !syl.isClosed) {\n const furtiveChet = /\\u{05D7}\\u{05B7}$/mu;\n if (furtiveChet.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveChet, \"\\u{05B7}\\u{05D7}\");\n }\n\n const furtiveAyin = /\\u{05E2}\\u{05B7}$/mu;\n if (furtiveAyin.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveAyin, \"\\u{05B7}\\u{05E2}\");\n }\n\n const furtiveHe = /\\u{05D4}\\u{05BC}\\u{05B7}$/mu;\n if (furtiveHe.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveHe, \"\\u{05B7}\\u{05D4}\\u{05BC}\");\n }\n }\n\n // dagesh chazaq\n const isDageshChazq = isDageshChazaq(cluster, schema);\n\n if (schema.BET_DAGESH && /\u05D1\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D1\\u{05BC}/u,\n getDageshChazaqVal(schema.BET_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.GIMEL_DAGESH && /\u05D2\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D2\\u{05BC}/u,\n getDageshChazaqVal(schema.GIMEL_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.DALET_DAGESH && /\u05D3\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D3\\u{05BC}/u,\n getDageshChazaqVal(schema.DALET_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.KAF_DAGESH && /\u05DB\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05DB\\u{05BC}/u,\n getDageshChazaqVal(schema.KAF_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.KAF_DAGESH && /\u05DA\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05DA\\u{05BC}/u,\n getDageshChazaqVal(schema.KAF_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.PE_DAGESH && /\u05E4\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E4\\u{05BC}/u,\n getDageshChazaqVal(schema.PE_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.TAV_DAGESH && /\u05EA\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05EA\\u{05BC}/u,\n getDageshChazaqVal(schema.TAV_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (/\u05E9\\u{05C1}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E9\\u{05C1}/u,\n getDageshChazaqVal(schema.SHIN, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (/\u05E9\\u{05C2}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E9\\u{05C2}/u,\n getDageshChazaqVal(schema.SIN, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (isDageshChazq) {\n const consonant = cluster.chars[0].text;\n const consonantDagesh = new RegExp(consonant + \"\\u{05BC}\", \"u\");\n return replaceWithRegex(\n clusterText,\n consonantDagesh,\n getDageshChazaqVal(consonant, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (cluster.isShureq) {\n return clusterText.replace(\"\u05D5\u05BC\", schema.SHUREQ);\n }\n\n return clusterText;\n};\n\nconst copySyllable = (newText: string, old: Syllable) => {\n const newClusters = newText.split(clusterSplitGroup).map((clusterString) => new Cluster(clusterString, true));\n const oldClusters = old.clusters;\n\n // set prev and next based on old syllable\n if (newClusters.length === oldClusters.length) {\n newClusters.forEach((c, i) => ((c.prev = oldClusters[i]?.prev ?? null), (c.next = oldClusters[i]?.next ?? null)));\n } else {\n for (let i = 0; i < newClusters.length; i++) {\n const c = newClusters[i];\n if (oldClusters[i]?.text[0] === c?.text[0]) {\n c.prev = oldClusters[i]?.prev ?? null;\n c.next = oldClusters[i]?.next ?? null;\n } else {\n c.prev = oldClusters[i]?.prev ?? null;\n c.next = oldClusters[i + 1]?.next ?? null;\n i++;\n }\n }\n }\n\n const newSyl = new Syllable(newClusters, {\n isClosed: old.isClosed,\n isAccented: old.isAccented,\n isFinal: old.isFinal\n });\n\n newClusters.forEach((c) => (c.syllable = newSyl));\n\n newSyl.prev = old.prev;\n newSyl.next = old.next;\n newSyl.word = old.word;\n\n return newSyl;\n};\n\nexport const sylRules = (syl: Syllable, schema: Schema): string => {\n const sylTxt = syl.text.replace(taamim, \"\");\n\n if (schema.ADDITIONAL_FEATURES?.length) {\n const seqs = schema.ADDITIONAL_FEATURES;\n for (const seq of seqs) {\n const heb = new RegExp(seq.HEBREW, \"u\");\n if (seq.FEATURE === \"syllable\" && heb.test(sylTxt)) {\n const transliteration = seq.TRANSLITERATION;\n const passThrough = seq.PASS_THROUGH ?? true;\n\n // if transliteration is a string, then replace\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(sylTxt, heb, transliteration, schema);\n }\n\n // if transliteration is a function and passThrough is false, then transliterate and exit\n if (!passThrough) {\n return transliteration(syl, seq.HEBREW, schema);\n }\n\n const newText = transliteration(syl, seq.HEBREW, schema);\n\n // if the transliteration just returns the syllable.text, then no need to copy the syllable\n if (newText !== sylTxt) {\n syl = copySyllable(newText, syl);\n }\n }\n } // end of seqs loop\n }\n\n // syllable is 3ms sufx\n const mSSuffix = /\\u{05B8}\\u{05D9}\\u{05D5}/u;\n if (syl.isFinal && mSSuffix.test(sylTxt)) {\n const sufxSyl = replaceWithRegex(sylTxt, mSSuffix, schema.MS_SUFX);\n return joinSyllableChars(syl, [...sufxSyl], schema);\n }\n\n // syllable has a mater\n const hasMater = syl.clusters.map((c) => c.isMater).includes(true);\n if (hasMater) {\n const materSyl = materFeatures(syl, schema);\n return joinSyllableChars(syl, [...materSyl], schema);\n }\n\n // regular syllables\n const returnTxt = syl.clusters.map((cluster) => {\n const clusterText = cluster.text.replace(taamim, \"\");\n return consonantFeatures(clusterText, syl, cluster, schema);\n });\n\n // there may be taamim still in the text, so remove them\n return joinSyllableChars(syl, returnTxt, schema).replace(taamim, \"\");\n};\n\nexport const wordRules = (word: Word, schema: Schema): string | Word => {\n if (word.isDivineName) {\n return getDivineName(word.text, schema);\n }\n\n if (word.hasDivineName) {\n return `${sylRules(word.syllables[0], schema)}-${getDivineName(word.text, schema)}`;\n }\n\n if (word.isNotHebrew) {\n return word.text;\n }\n\n const text = word.text.replace(taamim, \"\");\n if (schema.ADDITIONAL_FEATURES?.length) {\n const seqs = schema.ADDITIONAL_FEATURES;\n for (const seq of seqs) {\n const heb = new RegExp(seq.HEBREW, \"u\");\n if (seq.FEATURE === \"word\" && heb.test(text)) {\n const transliteration = seq.TRANSLITERATION;\n const passThrough = seq.PASS_THROUGH ?? true;\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(text, heb, transliteration, schema);\n }\n if (!passThrough) {\n return transliteration(word, seq.HEBREW, schema);\n }\n return new Word(transliteration(word, seq.HEBREW, schema), schema);\n }\n }\n return word;\n }\n return word;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { Cluster } from \"havarotjs/cluster\";\nimport { Syllable } from \"havarotjs/syllable\";\nimport { clusterSplitGroup, hebChars } from \"havarotjs/utils/regularExpressions\";\nimport { Word } from \"havarotjs/word\";\nimport { transliterateMap as map } from \"./hebCharsTrans\";\nimport { Schema } from \"./schema\";\n\nconst taamim = /[\\u{0590}-\\u{05AF}\\u{05BD}\\u{05BF}]/gu;\n\nconst copySyllable = (newText: string, old: Syllable) => {\n const newClusters = newText.split(clusterSplitGroup).map((clusterString) => new Cluster(clusterString, true));\n const oldClusters = old.clusters;\n\n // set prev and next based on old syllable\n if (newClusters.length === oldClusters.length) {\n newClusters.forEach((c, i) => ((c.prev = oldClusters[i]?.prev ?? null), (c.next = oldClusters[i]?.next ?? null)));\n } else {\n for (let i = 0; i < newClusters.length; i++) {\n const c = newClusters[i];\n if (oldClusters[i]?.text[0] === c?.text[0]) {\n c.prev = oldClusters[i]?.prev ?? null;\n c.next = oldClusters[i]?.next ?? null;\n } else {\n c.prev = oldClusters[i]?.prev ?? null;\n c.next = oldClusters[i + 1]?.next ?? null;\n i++;\n }\n }\n }\n\n const newSyl = new Syllable(newClusters, {\n isClosed: old.isClosed,\n isAccented: old.isAccented,\n isFinal: old.isFinal\n });\n\n newClusters.forEach((c) => (c.syllable = newSyl));\n\n newSyl.prev = old.prev;\n newSyl.next = old.next;\n newSyl.word = old.word;\n\n return newSyl;\n};\n\nconst getDageshChazaqVal = (input: string, dagesh: Schema[\"DAGESH_CHAZAQ\"], isChazaq: boolean) => {\n if (!isChazaq) {\n return input;\n }\n\n if (typeof dagesh === \"boolean\") {\n return input.repeat(2);\n }\n\n return input + dagesh;\n};\n\n/**\n * Formats the Divine Name with any Latin chars\n *\n * @param str word text\n * @param schema\n * @returns the Divine Name with any pre or proceding Latin chars\n */\nconst getDivineName = (str: string, schema: Schema): string => {\n const begn = str[0];\n const end = str[str.length - 1];\n // if DN is pointed with a hiriq, then it is read as 'elohim\n const divineName =\n schema.DIVINE_NAME_ELOHIM && /\\u{05B4}/u.test(str) ? schema.DIVINE_NAME_ELOHIM : schema.DIVINE_NAME;\n return `${hebChars.test(begn) ? \"\" : begn}${divineName}${hebChars.test(end) ? \"\" : end}`;\n};\n\nconst isDageshChazaq = (cluster: Cluster, schema: Schema) => {\n // if there is no dagesh chazaq in the schema, then return false\n if (!schema.DAGESH_CHAZAQ) {\n return false;\n }\n\n // a shureq could potentially match because of dagesh\n if (cluster.isShureq) {\n return false;\n }\n\n // if there is no dagesh in the text, then return false\n if (!/\\u{05BC}/u.test(cluster.text)) {\n return false;\n }\n\n const prevWord = cluster.syllable?.word?.prev?.value;\n if (prevWord && prevWord?.isInConstruct && !prevWord.syllables[prevWord.syllables.length - 1].isClosed) {\n return true;\n }\n\n // this could be a code smell, b/c the copySyllable function results are not the most predictable\n const prevSyllable = cluster.syllable?.prev;\n if (!prevSyllable) {\n return false;\n }\n\n const prevCoda = prevSyllable.value?.codaWithGemination;\n if (!prevCoda) {\n return false;\n }\n\n return prevCoda === cluster.syllable?.onset;\n};\n\nconst joinSyllableChars = (syl: Syllable, sylChars: string[], schema: Schema): string => {\n const isInConstruct = syl.word?.isInConstruct;\n\n if (isInConstruct) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (!syl.isAccented) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n // if syllable is only punctuation (e.g. a paseq), it should not receive a stress marker\n const isOnlyPunctuation = syl.clusters.map((c) => c.isPunctuation).every((c) => c);\n if (isOnlyPunctuation) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (schema.STRESS_MARKER) {\n const exclude = schema.STRESS_MARKER?.exclude ?? \"never\";\n\n if (exclude === \"single\" && !syl.prev && !syl.next) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (exclude === \"final\" && !syl.next) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n const location = schema.STRESS_MARKER.location;\n const mark = schema.STRESS_MARKER.mark;\n\n // if the stress marker is already present, no need to add it again\n if (syl.text.includes(mark)) {\n return sylChars.map(mapChars(schema)).join(\"\");\n }\n\n if (location === \"before-syllable\") {\n const isDoubled = syl.clusters.map((c) => isDageshChazaq(c, schema)).includes(true);\n if (isDoubled) {\n const chars = sylChars.map(mapChars(schema)).join(\"\");\n const [first, ...rest] = chars;\n return `${first}${mark}${rest.join(\"\")}`;\n }\n\n return `${mark}${sylChars.map(mapChars(schema)).join(\"\")}`;\n }\n\n if (location === \"after-syllable\") {\n return `${sylChars.map(mapChars(schema)).join(\"\")}${mark}`;\n }\n\n const vowels = [\n schema.PATAH,\n schema.HATAF_PATAH,\n schema.QAMATS,\n schema.HATAF_QAMATS,\n schema.SEGOL,\n schema.HATAF_SEGOL,\n schema.TSERE,\n schema.HIRIQ,\n schema.HOLAM,\n schema.QAMATS_QATAN,\n schema.QUBUTS,\n schema.QAMATS_HE,\n schema.SEGOL_HE,\n schema.TSERE_HE,\n schema.HIRIQ_YOD,\n schema.TSERE_YOD,\n schema.SEGOL_YOD,\n schema.HOLAM_VAV,\n schema.SHUREQ\n ]\n .filter((v) => typeof v === \"string\")\n .sort((a, b) => b.length - a.length);\n const vowelRgx = new RegExp(`${vowels.join(\"|\")}`);\n const str = sylChars.map(mapChars(schema)).join(\"\");\n const match = str.match(vowelRgx);\n\n if (location === \"before-vowel\") {\n return match?.length ? str.replace(match[0], `${mark}${match[0]}`) : str;\n }\n\n // after-vowel\n return match?.length ? str.replace(match[0], `${match[0]}${mark}`) : str;\n }\n\n return sylChars.map(mapChars(schema)).join(\"\");\n};\n\n/**\n * Maps Hebrew characters to schema\n *\n * @param input - text to be transliterated\n * @param schema - a {@link Schema} for transliterating the input\n * @returns transliteration of characters\n *\n */\nconst mapChars = (schema: Schema) => (input: string) => {\n return [...input].map((char: string) => (char in map ? schema[map[char]] : char)).join(\"\");\n};\n\nconst materFeatures = (syl: Syllable, schema: Schema) => {\n const mater = syl.clusters.filter((c) => c.isMater)[0];\n const prev = mater.prev instanceof Cluster ? mater.prev : null;\n const materText = mater.text;\n const prevText = (prev?.text || \"\").replace(taamim, \"\");\n // string comprised of all non-mater clusters in a syl with a mater\n let noMaterText = syl.clusters\n .filter((c) => !c.isMater)\n .map((c) => cluterRules(c, schema))\n .join(\"\");\n\n // workaround for maqaf\n const hasMaqaf = mater.text.includes(\"\u05BE\");\n noMaterText = hasMaqaf ? noMaterText.concat(\"\u05BE\") : noMaterText;\n\n if (/\u05D9/.test(materText)) {\n // hiriq\n if (/\\u{05B4}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B4}/u, schema.HIRIQ_YOD);\n }\n // tsere\n if (/\\u{05B5}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B5}/u, schema.TSERE_YOD);\n }\n // segol\n if (/\\u{05B6}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B6}/u, schema.SEGOL_YOD);\n }\n }\n\n if (/\u05D5/u.test(materText)) {\n // holam\n if (/\\u{05B9}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B9}/u, schema.HOLAM_VAV);\n }\n }\n\n if (/\u05D4/.test(materText)) {\n // qamets\n if (/\\u{05B8}/u.test(prevText)) {\n return replaceWithRegex(noMaterText, /\\u{05B8}/u, schema.QAMATS_HE);\n }\n }\n\n return materText;\n};\n\nconst removeTaamim = (input: string) => input.replace(taamim, \"\");\n\n/**\n * Replaces part of a string and transliterates the remaining characters according to the schema\n *\n * @example\n * ```ts\n * // replaces \u05D1\u05B8 as VA, but only when matching the regex sequence\n * const betAndQamats = /\\u{05D1}\\u{05B8}/u\n * replaceAndTransliterate(\"\u05D3\u05BC\u05B8\u05D1\u05B8\u05E8\", betAndQamats, \"VA\", schema);\n * // d\u0101VAr\n * ```\n *\n * @param input the text to be transliterated\n * @param regex the regex used as the search value\n * @param replaceValue the string to replace the regex\n * @param schema the Schema\n */\nconst replaceAndTransliterate = (input: string, regex: RegExp, replaceValue: string, schema: Schema) => {\n const sylSeq = replaceWithRegex(input, regex, replaceValue);\n return [...sylSeq].map(mapChars(schema)).join(\"\");\n};\n\n/**\n * Wrapper around `String.replace()` to constrain to a RegExp\n *\n * @param input the string to be modified\n * @param regex the regex to be used as the search value\n * @param replaceValue the string to replace the regex\n */\nconst replaceWithRegex = (input: string, regex: RegExp, replaceValue: string) => input.replace(regex, replaceValue);\n\n// MAIN RULES\n\nconst cluterRules = (cluster: Cluster, schema: Schema) => {\n let clusterText = removeTaamim(cluster.text);\n const clusterFeatures = schema.ADDITIONAL_FEATURES?.filter((seq) => seq.FEATURE === \"cluster\");\n if (clusterFeatures) {\n for (const feature of clusterFeatures) {\n const heb = new RegExp(feature.HEBREW, \"u\");\n if (feature.FEATURE === \"cluster\" && heb.test(clusterText)) {\n const transliteration = feature.TRANSLITERATION;\n const passThrough = feature.PASS_THROUGH ?? true;\n\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(clusterText, heb, transliteration, schema);\n }\n\n if (!passThrough) {\n return transliteration(cluster, feature.HEBREW, schema);\n }\n\n clusterText = transliteration(cluster, feature.HEBREW, schema);\n }\n }\n }\n\n const syl = cluster.syllable;\n clusterText = cluster.hasSheva && syl?.isClosed ? clusterText.replace(/\\u{05B0}/u, \"\") : clusterText;\n\n // mappiq he\n if (/\u05D4\\u{05BC}$/mu.test(clusterText)) {\n return replaceWithRegex(clusterText, /\u05D4\\u{05BC}/u, schema.HE);\n }\n\n if (syl?.isFinal && !syl?.isClosed) {\n const furtiveChet = /\\u{05D7}\\u{05B7}$/mu;\n if (furtiveChet.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveChet, \"\\u{05B7}\\u{05D7}\");\n }\n\n const furtiveAyin = /\\u{05E2}\\u{05B7}$/mu;\n if (furtiveAyin.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveAyin, \"\\u{05B7}\\u{05E2}\");\n }\n\n const furtiveHe = /\\u{05D4}\\u{05BC}\\u{05B7}$/mu;\n if (furtiveHe.test(clusterText)) {\n return replaceWithRegex(clusterText, furtiveHe, \"\\u{05B7}\\u{05D4}\\u{05BC}\");\n }\n }\n\n // dagesh chazaq\n const isDageshChazq = isDageshChazaq(cluster, schema);\n\n if (schema.BET_DAGESH && /\u05D1\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D1\\u{05BC}/u,\n getDageshChazaqVal(schema.BET_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.GIMEL_DAGESH && /\u05D2\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D2\\u{05BC}/u,\n getDageshChazaqVal(schema.GIMEL_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.DALET_DAGESH && /\u05D3\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05D3\\u{05BC}/u,\n getDageshChazaqVal(schema.DALET_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.KAF_DAGESH && /\u05DB\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05DB\\u{05BC}/u,\n getDageshChazaqVal(schema.KAF_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.KAF_DAGESH && /\u05DA\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05DA\\u{05BC}/u,\n getDageshChazaqVal(schema.KAF_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.PE_DAGESH && /\u05E4\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E4\\u{05BC}/u,\n getDageshChazaqVal(schema.PE_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (schema.TAV_DAGESH && /\u05EA\\u{05BC}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05EA\\u{05BC}/u,\n getDageshChazaqVal(schema.TAV_DAGESH, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (/\u05E9\\u{05C1}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E9\\u{05C1}/u,\n getDageshChazaqVal(schema.SHIN, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (/\u05E9\\u{05C2}/u.test(clusterText)) {\n return replaceWithRegex(\n clusterText,\n /\u05E9\\u{05C2}/u,\n getDageshChazaqVal(schema.SIN, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (isDageshChazq) {\n const consonant = cluster.chars[0].text;\n const consonantDagesh = new RegExp(consonant + \"\\u{05BC}\", \"u\");\n return replaceWithRegex(\n clusterText,\n consonantDagesh,\n getDageshChazaqVal(consonant, schema.DAGESH_CHAZAQ, isDageshChazq)\n );\n }\n\n if (cluster.isShureq) {\n return clusterText.replace(\"\u05D5\u05BC\", schema.SHUREQ);\n }\n\n return clusterText;\n};\n\nexport const sylRules = (syl: Syllable, schema: Schema): string => {\n const sylTxt = syl.text.replace(taamim, \"\");\n\n const syllableFeatures = schema.ADDITIONAL_FEATURES?.filter((seq) => seq.FEATURE === \"syllable\");\n if (syllableFeatures) {\n for (const feature of syllableFeatures) {\n const heb = new RegExp(feature.HEBREW, \"u\");\n if (feature.FEATURE === \"syllable\" && heb.test(sylTxt)) {\n const transliteration = feature.TRANSLITERATION;\n const passThrough = feature.PASS_THROUGH ?? true;\n\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(sylTxt, heb, transliteration, schema);\n }\n\n if (!passThrough) {\n return transliteration(syl, feature.HEBREW, schema);\n }\n\n const newText = transliteration(syl, feature.HEBREW, schema);\n\n // if the transliteration just returns the syllable.text, then no need to copy the syllable\n if (newText !== sylTxt) {\n syl = copySyllable(newText, syl);\n }\n }\n }\n }\n\n // syllable is 3ms sufx\n const mSSuffix = /\\u{05B8}\\u{05D9}\\u{05D5}/u;\n if (syl.isFinal && mSSuffix.test(sylTxt)) {\n const sufxSyl = replaceWithRegex(sylTxt, mSSuffix, schema.MS_SUFX);\n return joinSyllableChars(syl, [...sufxSyl], schema);\n }\n\n // syllable has a mater\n const hasMater = syl.clusters.map((c) => c.isMater).includes(true);\n if (hasMater) {\n const materSyl = materFeatures(syl, schema);\n return joinSyllableChars(syl, [...materSyl], schema);\n }\n\n if (schema.SEGOL_HE && /\\u{05B6}\\u{05D4}/u.test(sylTxt)) {\n const returnTxt = syl.clusters.map((cluster) => cluterRules(cluster, schema));\n const joined = joinSyllableChars(syl, returnTxt, schema).replace(taamim, \"\");\n return joined.replace(schema[\"SEGOL\"] + schema[\"HE\"], schema.SEGOL_HE);\n }\n\n // tsere\n if (schema.TSERE_HE && /\\u{05B5}\\u{05D4}/u.test(sylTxt)) {\n const returnTxt = syl.clusters.map((cluster) => cluterRules(cluster, schema));\n const joined = joinSyllableChars(syl, returnTxt, schema).replace(taamim, \"\");\n return joined.replace(schema[\"TSERE\"] + schema[\"HE\"], schema.TSERE_HE);\n }\n\n // regular syllables\n const returnTxt = syl.clusters.map((cluster) => cluterRules(cluster, schema));\n\n // there may be taamim still in the text, so remove them\n return joinSyllableChars(syl, returnTxt, schema).replace(taamim, \"\");\n};\n\nexport const wordRules = (word: Word, schema: Schema): string | Word => {\n if (word.isDivineName) {\n return getDivineName(word.text, schema);\n }\n\n if (word.hasDivineName) {\n return `${sylRules(word.syllables[0], schema)}-${getDivineName(word.text, schema)}`;\n }\n\n if (word.isNotHebrew) {\n return word.text;\n }\n\n const wordFeatures = schema.ADDITIONAL_FEATURES?.filter((seq) => seq.FEATURE === \"word\");\n if (wordFeatures) {\n const text = word.text.replace(taamim, \"\");\n for (const feature of wordFeatures) {\n const heb = new RegExp(feature.HEBREW, \"u\");\n if (heb.test(text)) {\n const transliteration = feature.TRANSLITERATION;\n const passThrough = feature.PASS_THROUGH ?? true;\n\n if (typeof transliteration === \"string\") {\n return replaceAndTransliterate(text, heb, transliteration, schema);\n }\n\n if (!passThrough) {\n return transliteration(word, feature.HEBREW, schema);\n }\n\n return new Word(transliteration(word, feature.HEBREW, schema), schema);\n }\n }\n return word;\n }\n\n return word;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;;;;;qBAAwB;AACxB,sBAAyB;AACzB,gCAA4C;AAC5C,kBAAqB;AACrB,2BAAwC;AAGxC,MAAM,SAAS;AAEf,MAAM,eAAe,CAAC,SAAiB,QAAiB;AATxD;AAUE,QAAM,cAAc,QAAQ,MAAM,2CAAiB,EAAE,IAAI,CAAC,kBAAkB,IAAI,uBAAQ,eAAe,IAAI,CAAC;AAC5G,QAAM,cAAc,IAAI;AAGxB,MAAI,YAAY,WAAW,YAAY,QAAQ;AAC7C,gBAAY,QAAQ,CAAC,GAAG,MAAG;AAf/B,UAAAA,KAAAC,KAAAC,KAAAC;AAeoC,eAAE,QAAOF,OAAAD,MAAA,YAAY,OAAZ,gBAAAA,IAAgB,SAAhB,OAAAC,MAAwB,MAAQ,EAAE,QAAOE,OAAAD,MAAA,YAAY,OAAZ,gBAAAA,IAAgB,SAAhB,OAAAC,MAAwB;KAAM;EAClH,OAAO;A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;AAEA,MAAI,KAAK,eAAe;AACtB,WAAO,GAAG,SAAS,KAAK,UAAU,IAAI,MAAM,KAAK,cAAc,KAAK,MAAM,MAAM;EAClF;AAEA,MAAI,KAAK,aAAa;AACpB,WAAO,KAAK;EACd;AAEA,QAAM,gBAAe,YAAO,wBAAP,mBAA4B,OAAO,CAAC,QAAQ,IAAI,YAAY;AACjF,MAAI,cAAc;AAChB,UAAM,OAAO,KAAK,KAAK,QAAQ,QAAQ,EAAE;AACzC,eAAW,WAAW,cAAc;AAClC,YAAM,MAAM,IAAI,OAAO,QAAQ,QAAQ,GAAG;AAC1C,UAAI,IAAI,KAAK,IAAI,GAAG;AAClB,cAAM,kBAAkB,QAAQ;AAChC,cAAM,eAAc,aAAQ,iBAAR,YAAwB;AAE5C,YAAI,OAAO,oBAAoB,UAAU;AACvC,iBAAO,wBAAwB,MAAM,KAAK,iBAAiB,MAAM;QACnE;AAEA,YAAI,CAAC,aAAa;AAChB,iBAAO,gBAAgB,MAAM,QAAQ,QAAQ,MAAM;QACrD;AAEA,eAAO,IAAI,iBAAK,gBAAgB,MAAM,QAAQ,QAAQ,MAAM,GAAG,MAAM;MACvE;IACF;AACA,WAAO;EACT;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["_a", "_b", "_c", "_d", "map", "returnTxt"]
|
|
7
7
|
}
|
package/dist/cjs/schema.js
CHANGED
|
@@ -190,7 +190,7 @@ class SBL extends Schema {
|
|
|
190
190
|
constructor(schema) {
|
|
191
191
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb, _Ab, _Bb, _Cb, _Db, _Eb, _Fb, _Gb, _Hb, _Ib, _Jb, _Kb, _Lb, _Mb, _Nb, _Ob, _Pb, _Qb, _Rb, _Sb, _Tb;
|
|
192
192
|
super({
|
|
193
|
-
VOCAL_SHEVA: (_a = schema.VOCAL_SHEVA) != null ? _a : "\
|
|
193
|
+
VOCAL_SHEVA: (_a = schema.VOCAL_SHEVA) != null ? _a : "\u0259",
|
|
194
194
|
HATAF_SEGOL: (_b = schema.HATAF_SEGOL) != null ? _b : "\u0115",
|
|
195
195
|
HATAF_PATAH: (_c = schema.HATAF_PATAH) != null ? _c : "\u0103",
|
|
196
196
|
HATAF_QAMATS: (_d = schema.HATAF_QAMATS) != null ? _d : "\u014F",
|
|
@@ -201,7 +201,7 @@ class SBL extends Schema {
|
|
|
201
201
|
QAMATS: (_i = schema.QAMATS) != null ? _i : "\u0101",
|
|
202
202
|
HOLAM: (_j = schema.HOLAM) != null ? _j : "\u014D",
|
|
203
203
|
HOLAM_HASER: (_k = schema.HOLAM_HASER) != null ? _k : "\u014D",
|
|
204
|
-
QUBUTS: (_l = schema.QUBUTS) != null ? _l : "
|
|
204
|
+
QUBUTS: (_l = schema.QUBUTS) != null ? _l : "u",
|
|
205
205
|
DAGESH: (_m = schema.DAGESH) != null ? _m : "",
|
|
206
206
|
DAGESH_CHAZAQ: (_n = schema.DAGESH_CHAZAQ) != null ? _n : true,
|
|
207
207
|
MAQAF: (_o = schema.MAQAF) != null ? _o : "-",
|
|
@@ -215,8 +215,8 @@ class SBL extends Schema {
|
|
|
215
215
|
SHUREQ: (_w = schema.SHUREQ) != null ? _w : "\xFB",
|
|
216
216
|
HOLAM_VAV: (_x = schema.HOLAM_VAV) != null ? _x : "\xF4",
|
|
217
217
|
QAMATS_HE: (_y = schema.QAMATS_HE) != null ? _y : "\xE2",
|
|
218
|
-
SEGOL_HE: (_z = schema.SEGOL_HE) != null ? _z :
|
|
219
|
-
TSERE_HE: (_A = schema.TSERE_HE) != null ? _A :
|
|
218
|
+
SEGOL_HE: (_z = schema.SEGOL_HE) != null ? _z : void 0,
|
|
219
|
+
TSERE_HE: (_A = schema.TSERE_HE) != null ? _A : void 0,
|
|
220
220
|
MS_SUFX: (_B = schema.MS_SUFX) != null ? _B : "\u0101yw",
|
|
221
221
|
ALEF: (_C = schema.ALEF) != null ? _C : "\u02BE",
|
|
222
222
|
BET: (_D = schema.BET) != null ? _D : "b",
|
|
@@ -269,7 +269,7 @@ class SBL extends Schema {
|
|
|
269
269
|
holemHaser: schema.holemHaser || "remove",
|
|
270
270
|
ketivQeres: schema.ketivQeres || void 0
|
|
271
271
|
});
|
|
272
|
-
this.VOCAL_SHEVA = (_wa = schema.VOCAL_SHEVA) != null ? _wa : "\
|
|
272
|
+
this.VOCAL_SHEVA = (_wa = schema.VOCAL_SHEVA) != null ? _wa : "\u0259";
|
|
273
273
|
this.HATAF_SEGOL = (_xa = schema.HATAF_SEGOL) != null ? _xa : "\u0115";
|
|
274
274
|
this.HATAF_PATAH = (_ya = schema.HATAF_PATAH) != null ? _ya : "\u0103";
|
|
275
275
|
this.HATAF_QAMATS = (_za = schema.HATAF_QAMATS) != null ? _za : "\u014F";
|
|
@@ -280,7 +280,7 @@ class SBL extends Schema {
|
|
|
280
280
|
this.QAMATS = (_Ea = schema.QAMATS) != null ? _Ea : "\u0101";
|
|
281
281
|
this.HOLAM = (_Fa = schema.HOLAM) != null ? _Fa : "\u014D";
|
|
282
282
|
this.HOLAM_HASER = (_Ga = schema.HOLAM_HASER) != null ? _Ga : "\u014D";
|
|
283
|
-
this.QUBUTS = (_Ha = schema.QUBUTS) != null ? _Ha : "
|
|
283
|
+
this.QUBUTS = (_Ha = schema.QUBUTS) != null ? _Ha : "u";
|
|
284
284
|
this.DAGESH = (_Ia = schema.DAGESH) != null ? _Ia : "";
|
|
285
285
|
this.DAGESH_CHAZAQ = (_Ja = schema.DAGESH_CHAZAQ) != null ? _Ja : true;
|
|
286
286
|
this.MAQAF = (_Ka = schema.MAQAF) != null ? _Ka : "-";
|
|
@@ -294,8 +294,8 @@ class SBL extends Schema {
|
|
|
294
294
|
this.SHUREQ = (_Sa = schema.SHUREQ) != null ? _Sa : "\xFB";
|
|
295
295
|
this.HOLAM_VAV = (_Ta = schema.HOLAM_VAV) != null ? _Ta : "\xF4";
|
|
296
296
|
this.QAMATS_HE = (_Ua = schema.QAMATS_HE) != null ? _Ua : "\xE2";
|
|
297
|
-
this.SEGOL_HE = (_Va = schema.SEGOL_HE) != null ? _Va :
|
|
298
|
-
this.TSERE_HE = (_Wa = schema.TSERE_HE) != null ? _Wa :
|
|
297
|
+
this.SEGOL_HE = (_Va = schema.SEGOL_HE) != null ? _Va : void 0;
|
|
298
|
+
this.TSERE_HE = (_Wa = schema.TSERE_HE) != null ? _Wa : void 0;
|
|
299
299
|
this.MS_SUFX = (_Xa = schema.MS_SUFX) != null ? _Xa : "\u0101yw";
|
|
300
300
|
this.ALEF = (_Ya = schema.ALEF) != null ? _Ya : "\u02BE";
|
|
301
301
|
this.BET = (_Za = schema.BET) != null ? _Za : "b";
|
|
@@ -334,7 +334,21 @@ class SBL extends Schema {
|
|
|
334
334
|
this.DIVINE_NAME = (_Eb = schema.DIVINE_NAME) != null ? _Eb : "yhwh";
|
|
335
335
|
this.DIVINE_NAME_ELOHIM = (_Fb = schema.DIVINE_NAME_ELOHIM) != null ? _Fb : void 0;
|
|
336
336
|
this.SYLLABLE_SEPARATOR = (_Gb = schema.SYLLABLE_SEPARATOR) != null ? _Gb : void 0;
|
|
337
|
-
this.ADDITIONAL_FEATURES = (_Hb = schema.ADDITIONAL_FEATURES) != null ? _Hb :
|
|
337
|
+
this.ADDITIONAL_FEATURES = (_Hb = schema.ADDITIONAL_FEATURES) != null ? _Hb : [
|
|
338
|
+
{
|
|
339
|
+
FEATURE: "syllable",
|
|
340
|
+
HEBREW: /[\u{05B4}\u{05BB}]/u,
|
|
341
|
+
TRANSLITERATION: (syllable, heb, schema2) => {
|
|
342
|
+
const hasMater = syllable.clusters.some((cluster) => cluster.isMater);
|
|
343
|
+
if (syllable.isAccented && !hasMater) {
|
|
344
|
+
const macron = "\u0304";
|
|
345
|
+
const output = syllable.hasVowelName("HIRIQ") ? schema2["HIRIQ"] + macron : schema2["QUBUTS"] + macron;
|
|
346
|
+
return syllable.text.replace(heb, output.normalize("NFC"));
|
|
347
|
+
}
|
|
348
|
+
return syllable.text;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
];
|
|
338
352
|
this.STRESS_MARKER = (_Ib = schema.STRESS_MARKER) != null ? _Ib : void 0;
|
|
339
353
|
this.longVowels = (_Jb = schema.longVowels) != null ? _Jb : true;
|
|
340
354
|
this.qametsQatan = (_Kb = schema.qametsQatan) != null ? _Kb : true;
|