hebrew-transliteration
Version:
a package for transliterating Hebrew
197 lines (196 loc) • 4.44 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all2) => {
for (var name in all2)
__defProp(target, name, { get: all2[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 remove_exports = {};
__export(remove_exports, {
accents: () => accents,
all: () => all,
marks: () => marks,
points: () => points,
punctuation: () => punctuation,
remove: () => remove,
vowels: () => vowels
});
module.exports = __toCommonJS(remove_exports);
var import_sequence = require("./sequence.js");
const removeMap = {
ETNAHTA: "\u0591",
SEGOLTA: "\u0592",
SHALSHELET: "\u0593",
ZAQEF_QATAN: "\u0594",
ZAQEF_GADOL: "\u0595",
TIPEHA: "\u0596",
REVIA: "\u0597",
ZARQA: "\u0598",
PASHTA: "\u0599",
YETIV: "\u059A",
TEVIR: "\u059B",
GERESH: "\u059C",
GERESH_MUQDAM: "\u059D",
GERSHAYIM: "\u059E",
QARNEY_PARA: "\u059F",
TELISHA_GEDOLA: "\u05A0",
PAZER: "\u05A1",
ATNAH_HAFUKH: "\u05A2",
MUNAH: "\u05A3",
MAHAPAKH: "\u05A4",
MERKHA: "\u05A5",
MERKHA_KEFULA: "\u05A6",
DARGA: "\u05A7",
QADMA: "\u05A8",
TELISHA_QETANA: "\u05A9",
YERAH_BEN_YOMO: "\u05AA",
OLE: "\u05AB",
ILUY: "\u05AC",
DEHI: "\u05AD",
ZINOR: "\u05AE",
SHEVA: "\u05B0",
HATAF_SEGOL: "\u05B1",
HATAF_PATAH: "\u05B2",
HATAF_QAMATS: "\u05B3",
HIRIQ: "\u05B4",
TSERE: "\u05B5",
SEGOL: "\u05B6",
PATAH: "\u05B7",
QAMATS: "\u05B8",
HOLAM: "\u05B9",
QUBUTS: "\u05BB",
DAGESH: "\u05BC",
METEG: "\u05BD",
RAFE: "\u05BF",
SHIN_DOT: "\u05C1",
SIN_DOT: "\u05C2",
QAMATS_QATAN: "\u05C7",
MAQAF: "\u05BE",
PASEQ: "\u05C0",
SOF_PASUQ: "\u05C3",
NUN_HAFUKHA: "\u05C6",
PUNC_GERESH: "\u05F3",
PUNC_GERSHAYIM: "\u05F4",
MASORA_CIRCLE: "\u05AF",
UPPER_DOT: "\u05C4",
LOWER_DOT: "\u05C5"
};
const accents = {
ETNAHTA: true,
SEGOLTA: true,
SHALSHELET: true,
ZAQEF_QATAN: true,
ZAQEF_GADOL: true,
TIPEHA: true,
REVIA: true,
ZARQA: true,
PASHTA: true,
YETIV: true,
TEVIR: true,
GERESH: true,
GERESH_MUQDAM: true,
GERSHAYIM: true,
QARNEY_PARA: true,
TELISHA_GEDOLA: true,
PAZER: true,
ATNAH_HAFUKH: true,
MUNAH: true,
MAHAPAKH: true,
MERKHA: true,
MERKHA_KEFULA: true,
DARGA: true,
QADMA: true,
TELISHA_QETANA: true,
YERAH_BEN_YOMO: true,
OLE: true,
ILUY: true,
DEHI: true,
ZINOR: true
};
const points = {
SHEVA: true,
HATAF_SEGOL: true,
HATAF_PATAH: true,
HATAF_QAMATS: true,
HIRIQ: true,
TSERE: true,
SEGOL: true,
PATAH: true,
QAMATS: true,
HOLAM: true,
QUBUTS: true,
DAGESH: true,
SHIN_DOT: true,
SIN_DOT: true,
METEG: true,
RAFE: true,
QAMATS_QATAN: true
};
const vowels = {
SHEVA: true,
HATAF_SEGOL: true,
HATAF_PATAH: true,
HATAF_QAMATS: true,
HIRIQ: true,
TSERE: true,
SEGOL: true,
PATAH: true,
QAMATS: true,
HOLAM: true,
QUBUTS: true,
DAGESH: true,
QAMATS_QATAN: true
};
const punctuation = {
MAQAF: true,
PASEQ: true,
SOF_PASUQ: true,
NUN_HAFUKHA: true,
PUNC_GERESH: true,
PUNC_GERSHAYIM: true
};
const marks = {
MASORA_CIRCLE: true,
UPPER_DOT: true,
LOWER_DOT: true
};
const all = {
...accents,
...points,
...punctuation,
...marks
};
const remove = (text, options = { ...accents, METEG: true, RAFE: true }) => {
const keys = Object.keys(options).filter((k) => k in options ? options[k] : false);
const sequenced = (0, import_sequence.sequence)(text);
return keys.reduce((a, c) => {
var _a;
const key = (_a = removeMap[c]) != null ? _a : null;
if (key) {
const replacement = key === "\u05BE" ? " " : "";
return a.replace(new RegExp(key, "gu"), replacement);
}
return a;
}, sequenced);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
accents,
all,
marks,
points,
punctuation,
remove,
vowels
});
//# sourceMappingURL=remove.js.map