phonetic-code-util
Version:
Semitic phonetic transliteration utilities
286 lines (252 loc) • 8.79 kB
JavaScript
/**
* @file Semitic phonetic transliteration utilities
* @version 1.0.5
* @author Greg Borota
* @copyright (c) 2017 Greg Borota.
* @license MIT
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
// https://peshitta.github.io
// https://sedra.bethmardutho.org/about/fonts
// http://cal1.cn.huc.edu/searching/fullbrowser.html
import { clearDotting, hasDotting } from 'aramaic-mapper';
/** @module phoneticCodeUtil */
/**
* Phonetic latin consonant name to value map
* @constant
* @type { Object.<string, string> }
*/
var consonantsByName = Object.freeze(
Object.create(null, {
alaph: { value: '\u2019', enumerable: true },
beth: { value: 'b', enumerable: true },
gamal: { value: 'g', enumerable: true },
dalath: { value: 'd', enumerable: true },
he: { value: 'h', enumerable: true },
waw: { value: 'w', enumerable: true },
zayn: { value: 'z', enumerable: true },
heth: { value: 'ḥ', enumerable: true },
teth: { value: 'ṭ', enumerable: true },
yod: { value: 'y', enumerable: true },
kaph: { value: 'k', enumerable: true },
lamadh: { value: 'l', enumerable: true },
mim: { value: 'm', enumerable: true },
nun: { value: 'n', enumerable: true },
semkath: { value: 's', enumerable: true },
e: { value: '\u2018', enumerable: true },
pe: { value: 'p', enumerable: true },
sadhe: { value: 'ṣ', enumerable: true },
qoph: { value: 'q', enumerable: true },
resh: { value: 'r', enumerable: true },
shin: { value: 'š', enumerable: true },
taw: { value: 't', enumerable: true }
})
);
var l = consonantsByName;
/**
* Semitic 22 base consonants
* @constant
* @type { string[] }
*/
var consonants = Object.freeze([
// abgad
l.alaph, // '\u2019', Ālaph - Glottal Stop
l.beth, // 'b', Bēth - Voiced bilabial stop
l.gamal, // 'g', Gāmal - Voiced velar stop
l.dalath, // 'd', Dālath - Voiced alveolar stop
// hawaz
l.he, // 'h', Hē - Voiceless glottal fricative
l.waw, // 'w', Waw - Voiced labio-velar approximant
l.zayn, // 'z', Zain - Voiced alveolar fricative
// ḥaṭy
l.heth, // 'ḥ', Ḥēth - Voiceless pharyngeal fricative
l.teth, // 'ṭ', Ṭēth - Emphatic pharyngealized T
l.yod, // 'y', Yodh - Voiced palatal approximant
// kalman
l.kaph, // 'k', Kāph - Voiceless velar stop
l.lamadh, // 'l', Lāmadh - Alveolar lateral approximant
l.mim, // 'm', Mem - Bilabial nasal
l.nun, // 'n', Nun - Alveolar nasal
// saʿpac
l.semkath, // 's', Semkath - Voiceless alveolar fricative
l.e, // '\u2018', ʿĒ - Voiced pharyngeal fricative
l.pe, // 'p', Pē - Voiceless bilabial stop
l.sadhe, // 'ṣ', Ṣādhē - Emphatic pharyngealized s
// qarshat
l.qoph, // 'q', Qoph - Voiceless uvular stop
l.resh, // 'r', Rēsh - Alveolar trill
l.shin, // 'š', Shin - Voiceless palato-alveolar sibilant
l.taw ]);
/**
* Begadkepat consonants
* @constant
* @type { string[] }
*/
var begadkepatConsonants = [
l.beth, // 'b', Bēth - Voiced bilabial stop
l.gamal, // 'g', Gāmal - Voiced velar stop
l.dalath, // 'd', Dālath - Voiced alveolar stop
l.kaph, // 'k', Kāph - Voiceless velar stop
l.pe, // 'p', Pē - Voiceless bilabial stop
l.taw ];
/**
* Veghadhkhefath consonants
* @constant
* @type { string[] }
*/
var veghadhkhefathConsonants = [
'ḇ', // Vēth - Voiced labiodental fricative
'g̱', // Ghāmal - Voiced velar fricative
'ḏ', // Dhālath - Voiced dental fricative
'ḵ', // Khāph - Voiceless velar fricative
'p̱', // Fē - voiceless labiodental fricative
'ṯ' // Thaw - Voiceless dental fricative
];
/**
* Begadkepat to veghadhkhefath map
* @const
* @type { Object.<string, string> }
*/
var begadkepatMap = Object.freeze(
Object.create(null, {
b: { value: 'ḇ', enumerable: true },
g: { value: 'g̱', enumerable: true },
d: { value: 'ḏ', enumerable: true },
k: { value: 'ḵ', enumerable: true },
p: { value: 'p̱', enumerable: true },
t: { value: 'ṯ', enumerable: true }
})
);
/**
* Other semitic consonants
* @constant
* @type { string[] }
*/
var extraConsonants = [
'ś', // Śin - Voiceless alveolar lateral fricative
'ḍ', // Ḍād - Emphatic pharyngealized D, ~ strike-through for pharyngealization
'ẓ' ];
/**
* All consonants concatenated
* @constant
* @type { string[] }
*/
var allConsonants = Object.freeze(
consonants.concat(veghadhkhefathConsonants).concat(extraConsonants)
);
/**
* Phonetic latin vowel name to value map
* @constant
* @type { Object.<string, string> }
*/
var vowelsByName = Object.freeze(
Object.create(null, {
pthaha: { value: 'a', enumerable: true },
zqapha: { value: 'ā', enumerable: true },
rbasa: { value: 'ē', enumerable: true },
hbasa: { value: 'ī', enumerable: true },
esasa: { value: 'ū', enumerable: true },
zlama: { value: 'e', enumerable: true },
rwaha: { value: 'ō', enumerable: true }
})
);
var v = vowelsByName;
/**
* Common aramaic vowels
* @constant
* @type { string[] }
*/
var commonVowels = Object.freeze([
v.pthaha, // 'a', Pthāḥā - Open front unrounded vowel
v.zqapha, // 'ā', Zqāphā - Open back unrounded vowel
v.rbasa, // 'ē', Zlāmā qašyā - Close-mid front unrounded vowel
v.hbasa, // 'ī', Ḥḇāṣā - Close front unrounded vowel
v.esasa // 'ū' Rvāṣā - Close back rounded vowel
]);
/**
* Eastern/hebrew only vowels
* @constant
* @type { string[] }
*/
var easternVowels = Object.freeze([
v.zlama, // 'e', Zlāmā pšīqā - Open-mid front unrounded - short version of e
v.rwaha // 'ō' Rwāḥā - Close-mid back rounded vowel
]);
/**
* Other semitic vowels
* @constant
* @type { string[] }
*/
var otherVowels = Object.freeze([
'u', // Near-close near-back rounded vowel. Short version of u.
'i', // Near-close near-front unrounded vowel. Short version of i.
'o' // Open-mid back rounded vowel. Short version of o.
]);
/**
* Semitic vowels including Eastern/Hebrew ones and other short vowels.
* @constant
* @type { string[] }
*/
var allVowels = Object.freeze(
commonVowels.concat(easternVowels).concat(otherVowels)
);
/**
* The silent letter symbol
* @const
* @type { string }
*/
var silent = '∅';
/**
* Is character c a semitic consonant
* @param { string } c input character
* @returns { boolean } true if c is semitic consonant
*/
var isConsonant = function (c) { return allConsonants.indexOf(c) > -1; };
/**
* Is character c a semitic vowel
* @param { string } c input character
* @returns { boolean } true if c is semitic vowel
*/
var isVowel = function (c) { return allVowels.indexOf(c) > -1; };
/**
* Return true if input word has vowels
* @param { string } word input word
* @returns { boolean } true if word has vowels
*/
var isDotted = hasDotting(isVowel);
/**
* Remove vowels, leaving consonantal word only.
* @param { string } word input word to be processed
* @returns { string } consonantal word
*/
var removeVowels = clearDotting(isVowel);
/**
* Returns true if c is a begadkepat consonant
* @param { string } c input character
* @returns { boolean } true if c is a begadkepat consonant
*/
var isBegadkepat = function (c) { return begadkepatConsonants.indexOf(c) > -1; };
/**
* Returns true if c is a veghadhkhefath consonant
* @param { string } c input character
* @returns { boolean } true if c is a veghadhkhefath consonant
*/
var isVeghadhkhefath = function (c) { return veghadhkhefathConsonants.indexOf(c) > -1; };
export { consonantsByName, consonants, begadkepatConsonants, veghadhkhefathConsonants, begadkepatMap, extraConsonants, allConsonants, vowelsByName, commonVowels, easternVowels, otherVowels, allVowels, silent, isConsonant, isVowel, isDotted, removeVowels, isBegadkepat, isVeghadhkhefath };