hebrew-transliteration 1.3.0 → 2.0.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.
@@ -1,7 +1,7 @@
1
- Copyright 2019 Charles Loder
1
+ Copyright 2022 Charles Loder
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
5
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # hebrew-transliteration
2
2
 
3
- Transliterate Unicode Hebrew text according to SBL's guidelines
3
+ A JavaScript package for transliterating Hebrew
4
4
 
5
5
  ## install
6
6
 
7
7
  ### npm
8
8
 
9
- `npm install --save hebrew-transliteration`
9
+ ```bash
10
+ npm install hebrew-transliteration
11
+ ```
10
12
 
11
13
  ### local
12
14
 
13
- Download or clone this repository.
15
+ You will need to have [node installed](https://nodejs.org/en/download/).
16
+
17
+ Download or clone this repository
14
18
 
15
19
  ```bash
16
20
  cd hebrew-transliteration
@@ -23,44 +27,67 @@ npm run build
23
27
  ```javascript
24
28
  const heb = require("hebrew-transliteration");
25
29
  const transliterate = heb.transliterate;
26
-
27
30
  transliterate("אֱלֹהִים");
28
- // "ʾĕlōhîm";
31
+ // ʾĕlōhîm
29
32
  ```
30
33
 
31
34
  ## DOCS
32
35
 
33
- ### transliterate
36
+ ### About
34
37
 
35
- ```javascript
36
- heb.transliterate(text, { isSequenced: true, qametsQatan: false, isSimple: false });
37
- ```
38
+ This is a JavaScript package for transliterating Hebrew.
38
39
 
39
- Takes `text` \<\<String\>\> and `[options]` \<\<Object\>\>.
40
+ It exports 3 [functions](#functions):
40
41
 
41
- ```javascript
42
- heb.transliterate("כָּל־הָעָם");
43
- // "kāl-hāʿām";
42
+ 1. [`transliterate()`](#transliterate) — the main function which transliterates Hebrew
43
+ 2. [`remove()`](#remove) — removes taamim and optionally removes certain niqqudim
44
+ 3. [`sequence()`](#sequence) — sequences Hebrew characters according to the [SBL Hebrew Font Manual](https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf)
45
+
46
+ And it exports 2 [classes](#classes):
47
+
48
+ 1. [`Text`](#text) — the [`Text`](https://charlesloder.github.io/havarot/classes/text.Text.html) class from the `havarotjs` package
49
+ 2. [`Schema`](#schema) — a schema for transliterating Hebrew
44
50
 
45
- heb.transliterate("כָּל־הָעָם", { qametsQatan: true });
46
- // "kol-hāʿām";
51
+ ### Functions
47
52
 
48
- heb.transliterate("שָׁלֹום");
49
- // "šālôm";
53
+ #### `transliterate()`
50
54
 
51
- heb.transliterate("שָׁלֹום", { isSimple: true });
52
- // "shalom";
55
+ Takes a `string` or [`Text`](#text), and optionally a [`Schema`](#schema) or `Partial<Schema>`
56
+
57
+ ```javascript
58
+ heb.transliterate("אֱלֹהִים");
59
+ // "ʾĕlōhîm";
53
60
  ```
54
61
 
55
- ---
62
+ If no [`Schema`](#schema) is passed, then the package defaults to SBL's academic style.
63
+
64
+ You can pass in a `Partial<Schema>` that will modify SBL's academic style:
65
+
66
+ ```javascript
67
+ heb.transliterate("שָׁלוֹם", { SHIN: "sh" });
68
+ // shālôm
69
+ ```
56
70
 
57
- ### remove
71
+ If you need a fully customized transliteration, it is best to use the [`Schema`](#schema) constructor:
58
72
 
59
73
  ```javascript
60
- heb.remove(text, { removeVowels: false, removeShinDot: false, removeSinDot: false });
74
+ const schema = new heb.Schema({
75
+ ALEF: "'",
76
+ BET: "B",
77
+ ...
78
+ QAMETS: "A",
79
+ ...
80
+ }) // truncated for brevity
81
+
82
+ heb.transliterate("אָ֣ב", schema)
83
+ // 'AB
61
84
  ```
62
85
 
63
- Takes `text` \<\<String\>\> and `[options]` \<\<Object\>\>. With `{removeVowels: false}`, will only remove cantillation (i.e., accent) marks.
86
+ ---
87
+
88
+ #### `remove()`
89
+
90
+ Takes `string` and options. The default only removes taamim (i.e., accent or cantillation) marks.
64
91
 
65
92
  ```javascript
66
93
  heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔");
@@ -75,35 +102,216 @@ heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true, remove
75
102
 
76
103
  ---
77
104
 
78
- ### sequence
105
+ #### `sequence()`
106
+
107
+ Takes a `string`. Returns a string of properly sequenced characters according to the [SBL Hebrew Font manual](https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf) following the pattern of: consonant - dagesh - vowel - ta'am
108
+
109
+ ```javascript
110
+ heb.sequence("\u{5D1}\u{5B0}\u{5BC}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5B4}\u{5C1}\u{596}\u{5D9}\u{5EA}");
111
+ // "\u{5D1}\u{5BC}\u{5B0}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5C1}\u{5B4}\u{596}\u{5D9}\u{5EA}"
112
+ ```
113
+
114
+ ### Classes
115
+
116
+ #### Text
117
+
118
+ The [`Text`](https://charlesloder.github.io/havarot/classes/text.Text.html) class from the [`havarotjs`](https://www.npmjs.com/package/havarotjs) package.
119
+
120
+ This class is used by [`transliterate()`](#transliterate) internally to syllabify Hebrew text, but it is exposed as well.
79
121
 
80
122
  ```javascript
81
- heb.sequence(text);
123
+ const text = new heb.Text("הֲבָרֹות");
124
+ text.syllables;
125
+ // [
126
+ // Syllable { original: "הֲ" },
127
+ // Syllable { original: "בָ" },
128
+ // Syllable { original: "רֹות" }
129
+ // ]
82
130
  ```
83
131
 
84
- Takes `text` \<\<String\>\>. Returns a string of properly sequenced characters according to the [SBL Hebrew Font manual](https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf).
132
+ If a `Text` is passed into [`transliterate()`](#transliterate) instead of a `string`, then the syllabification from the `Text` class is used.
133
+ If a `string` is passed in, then syllabification come from the options passed into the [`Schema`](#schema).
134
+ See more under [syllabification](#syllabification).
135
+
136
+ #### Schema
137
+
138
+ A `Schema` is used to define a schema for transliteration. See the [`Schema` source](src/schema.ts) for all available properties.
139
+
140
+ The `Schema` can be divided into a few categories.
141
+
142
+ ##### 1) Syllabification
143
+
144
+ The options used for syllabifying Hebrew text can be found [here](https://charlesloder.github.io/havarot/interfaces/text.SylOpts.html)
145
+
146
+ ###### Differences between `Text` and `Schema`
147
+
148
+ There are 5 options for syllabification that are the [same as the ones used by the `Text`](https://charlesloder.github.io/havarot/interfaces/text.SylOpts.html) class. The only `Text` syllabification option that `Schema` does not use is `schema` (yes, that's confusing):
85
149
 
86
150
  ```javascript
87
- heb.sequence("\u{5D1}\u{5B0}\u{5BC}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5B4}\u{5C1}\u{596}\u{5D9}\u{5EA}");
88
- // --------- "\u{5D1}\u{5BC}\u{5B0}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5C1}\u{5B4}\u{596}\u{5D9}\u{5EA}";
151
+ const text = new heb.Text("חׇכְמָ֣ה", { schema: "traditional" }); // this is okay
152
+ const schema = new heb.Schema({ schema: "traditional" }); // this does nothing
89
153
  ```
90
154
 
91
- ## License
155
+ Read more about the syllabification options for the [`Text`](https://charlesloder.github.io/havarot/interfaces/text.SylOpts.html) and a [higher level overview](https://charlesloder.github.io/havarot/pages/Linguistic/syllabification.html)
92
156
 
93
- MIT
157
+ ###### Precedence of `Text` over `Schema`
94
158
 
95
- ## Live
159
+ The syllabification options set by `Schema` are used if a `string` is passed into [`transliterate()`](#transliterate). If a `Text` is passed into [`transliterate()`](#transliterate) instead of a `string`, then the syllabification from the `Text` class is used:
96
160
 
97
- Use it live at [charlesLoder.github.io/hebrewTransliteration](https://charlesloder.github.io/hebrewTransliteration/index.html)
161
+ ```javascript
162
+ // using default
163
+ heb.transliterate("חָכְמָ֣ה"); // ḥokmâ
164
+
165
+ // using Schema for syllabification
166
+ heb.transliterate("חָכְמָ֣ה", { qametsQatan: false }); // ḥākǝmâ
167
+
168
+ // using Text for syllabification
169
+ heb.transliterate(new heb.Text("חָכְמָ֣ה", { qametsQatan: false })); // ḥākǝmâ
170
+
171
+ // using Schema and Text — Text takes precedence
172
+ heb.transliterate(new heb.Text("חָכְמָ֣ה", { qametsQatan: true }), { qametsQatan: false }); // ḥokmâ
173
+ ```
174
+
175
+ **Note**: `qametsQatan` only converts a regular _qamets_ character; if a [_qamets qatan_ character](https://www.compart.com/en/unicode/U+05C7) is used, it will always be a _qamets qatan_.
176
+
177
+ ##### 2) Characters
98
178
 
99
- ## Changelog
179
+ Most `Schema` properties are for defining single Hebrew characters:
180
+
181
+ ```javascript
182
+ heb.transliterate("אָ", { ALEF: "@", QAMETS: "A" });
183
+ // @A
184
+ ```
100
185
 
101
- - v1.1.0: in `transliterate()` the `options` was changed from the misspelled `isSeqeunced` to `isSequenced`.
102
- - v1.2.0:
103
- - rewrote in in TypeScript
104
- - added `isSimple` option to `transliterate()` for SBL's General Purpose Style
105
- - v1.3.0: added `removeShinDot` and `removeSinDot` option to `remove()` for more granular control
186
+ ##### 3) Orthographic Features
187
+
188
+ Some properties are for defining common Hebrew orthographies for:
189
+
190
+ ###### _BeGaDKePhaT_
191
+
192
+ There are properties for the digraphs of _BeGaDKePhaT_ letters:
193
+
194
+ - `BET_DAGESH`
195
+ - `GIMEL_DAGESH`
196
+ - `DALET_DAGESH`
197
+ - `KAF_DAGESH`
198
+ - `PE_DAGESH`
199
+ - `TAV_DAGESH`
200
+
201
+ Each one is the consonant character followed by the _dagesh_ character (U+05BC).
202
+
203
+ These are helpful for distinguishing between spirantized forms.
204
+
205
+ ```javascript
206
+ heb.transliterate("בְּבֵית", { BET: "b" });
207
+ // bǝbêt
208
+
209
+ heb.transliterate("בְּבֵית", { BET: "v", BET_DAGESH: "b" });
210
+ // bǝvêt
211
+ ```
212
+
213
+ ###### Matres Lectionis
214
+
215
+ The following properties are for _matres lectionis_:
216
+
217
+ - `HIRIQ_YOD`
218
+ - `TSERE_YOD`
219
+ - `SEGOL_YOD`
220
+ - `SHUREQ`
221
+ - `HOLAM_VAV`
222
+ - `QAMATS_HE`
223
+ - `SEGOL_HE`
224
+ - `TSERE_HE`
225
+
226
+ ```javascript
227
+ heb.transliterate("פֶּה", { SEGOL_HE: "é" });
228
+ // pé
229
+ ```
230
+
231
+ ###### Others
232
+
233
+ There are other orthographic features:
234
+
235
+ - `MS_SUFX` — HEBREW LETTER QAMATS (U+05B8) and YOD (U+05D9) and VAV (U+05D5) יו◌ָ
236
+ - `DIVINE_NAME` — the full form of the divine name - יהוה
237
+ - `SYLLABLE_SEPARATOR` — a syllable separator, usually an empty string
238
+ - `DAGESH_CHAZAQ` — if true, repeats the consonant with the _dagesh_
239
+
240
+ ```javascript
241
+ heb.transliterate("שַׁבָּת", { DAGESH_CHAZAQ: true });
242
+ // šabbāt
243
+
244
+ heb.transliterate("שַׁבָּת", { DAGESH_CHAZAQ: false });
245
+ // šabāt
246
+
247
+ heb.transliterate("הָאָֽרֶץ", { SYLLABLE_SEPARATOR: "-" });
248
+ // hā-ʾā-reṣ
249
+ ```
250
+
251
+ ##### 4) Others
252
+
253
+ ###### Additional Features
254
+
255
+ The `ADDITIONAL_FEATURES` property is for defining non-typical Hebrew orthography, example:
256
+
257
+ ```javascript
258
+ heb.transliterate("הַזֹּאת", {
259
+ ADDITIONAL_FEATURES: [
260
+ {
261
+ FEATURE: "cluster",
262
+ HEBREW: "זּ",
263
+ TRANSLITERATION: "tz"
264
+ }
265
+ ]
266
+ });
267
+ // hatzōʾt
268
+ ```
269
+
270
+ - The orthography `זּ` is most often a doubling of the `ZAYIN` (i.e. `'z'` with no _dagesh_, and `'zz'` with a _dagesh chazaq_)
271
+ - In the Romaniote reading tradition, however, the `ZAYIN` is usually transliterated with `'z'` (really `'ζ'`),
272
+ - but a `ZAYIN` followed by a _dagesh_ is transliterated as `'tz'` (really `'τζ'`)
273
+
274
+ Each additional feature consists of 3 parts:
275
+
276
+ 1. `FEATURE` — has three options:
277
+ - `"cluster"` — a `cluster` is any combination of a single character and optionally a *dagesh* and vowel.
278
+ - `"syllable"` — a `syllable` is any combination of a multiple characters and a single vowel and optionally a *dagesh*
279
+ - `"word"` — covers everything else
280
+ 2. `HEBREW` — the Hebrew text to be transliterated
281
+ 3. `TRANSLITERATION` — the text used to transliterate the Hebrew text
282
+
283
+ :warning: this is an experimental property; results may not always meet expectations
284
+
285
+ ###### Stress Marker
286
+
287
+ The `STRESS_MARKER` property is an optional mark to indicate stress in transliteration.
288
+
289
+ ```javascript
290
+ heb.transliterate("מֶ֣לֶךְ", { STRESS_MARKER: { location: "after-vowel", mark: "\u0301" } });
291
+ // mélek
292
+ ```
293
+
294
+ The `location` has four options:
295
+
296
+ - `"before-syllable"`
297
+ - `"after-syllable"`
298
+ - `"before-vowel"`
299
+ - `"after-vowel"`
300
+
301
+ A combining mark (e.g. `"\u0301"`) placed `"after-vowel"` will print on top of the vowel, and placed after a digraph will print on the second vowel.
302
+
303
+ ```javascript
304
+ heb.transliterate("בֵּ֣ית", {
305
+ TSERE_YOD: "ei",
306
+ STRESS_MARKER: { location: "after-vowel", mark: "\u0301" }
307
+ });
308
+ // beít
309
+ ```
310
+
311
+ ## Live
312
+
313
+ Use it live at [charlesLoder.github.io/hebrewTransliteration](https://charlesloder.github.io/hebrewTransliteration/index.html)
106
314
 
107
315
  ## Contributing
108
316
 
109
- Please feel free to Fork, create Pull Requests, or submit issues. This is my first npm package, so any feedback is appreciated!
317
+ See [contributing](./CONTRIBUTING.md)