| 1 |
// Using visual code point representation for better human intelligibility |
| 2 |
const independentVowels = ['అ', 'ఆ', 'ఇ', 'ఈ', 'ఉ', 'ఊ', 'ఋ', 'ౠ', 'ఌ', 'ౡ', 'ఎ', 'ఏ', 'ఐ', 'ఒ', 'ఓ', 'ఔ']; |
| 3 |
const diacriticVowels = ['ా', 'ి', 'ీ', 'ు', 'ూ', 'ృ', 'ౄ', 'ౢ', 'ౣ', 'ె', 'ే', 'ై', 'ొ', 'ో', 'ౌ']; |
| 4 |
const consonants = ['క', 'ఖ', 'గ', 'ఘ', 'ఙ', 'చ', 'ఛ', 'జ', 'ఝ', 'ఞ', 'ట', 'ఠ', 'డ', 'ఢ', 'ణ', 'త', 'థ', 'ద', 'ధ', 'న', 'ప', 'ఫ', 'బ', 'భ', 'మ', 'య', 'ర', 'ల', 'వ', 'ళ', 'శ', 'ష', 'స', 'హ', 'ఱ']; |
| 5 |
const rareConsonants = ['ౘ', 'ౙ', 'ౚ']; |
| 6 |
const modifiers = ['్', 'ఁ', 'ం', 'ః', 'ౕ', 'ౖ']; |
| 7 |
const numerals = ['౦', '౧', '౨', '౩', '౪', '౫', '౬', '౭', '౮', '౯', '౸', '౹', '౺', '౻', '౼', '౽', '౾']; |
| 8 |
const virama = '్'; |
| 9 |
|
| 10 |
const doubleCombos = []; // Telugu symbols built out of two code points |
| 11 |
const tripleCombos = []; // Telugu symbols built out of three code points |
| 12 |
|
| 13 |
// Consonants can be combined with many other character modifiers |
| 14 |
for (const consonant of consonants) { |
| 15 |
// Consonant + vowel |
| 16 |
for (const vowel of diacriticVowels) { |
| 17 |
doubleCombos.push(String.fromCodePoint(consonant.codePointAt(0), vowel.codePointAt(0))); |
| 18 |
} |
| 19 |
|
| 20 |
// Consonant + special vowel modifier or length mark |
| 21 |
for (const modifier of modifiers) { |
| 22 |
doubleCombos.push(String.fromCodePoint(consonant.codePointAt(0), modifier.codePointAt(0))); |
| 23 |
} |
| 24 |
|
| 25 |
// Consonant + consonant (separated by ్) |
| 26 |
for (const consonant2 of consonants) { |
| 27 |
tripleCombos.push(String.fromCodePoint(consonant.codePointAt(0), virama.codePointAt(0), consonant2.codePointAt(0))); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
// Rare consonants like common consonants, but lack the consonant conjuncts |
| 32 |
for (const consonant of rareConsonants) { |
| 33 |
// Rare consonant + vowel |
| 34 |
for (const vowel of diacriticVowels) { |
| 35 |
doubleCombos.push(String.fromCodePoint(consonant.codePointAt(0), vowel.codePointAt(0))); |
| 36 |
} |
| 37 |
|
| 38 |
// Rare consonant + special vowel modifier or length mark |
| 39 |
for (const modifier of modifiers) { |
| 40 |
doubleCombos.push(String.fromCodePoint(consonant.codePointAt(0), modifier.codePointAt(0))); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
Create all single Telugu characters possible. |
| 46 |
|
| 47 |
@return {string[]} All single Telugu chars possible. |
| 48 |
*/ |
| 49 |
export function createAllTeluguChars() { |
| 50 |
return [...independentVowels, ...consonants, ...rareConsonants, ...numerals, ...doubleCombos, ...tripleCombos]; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
Create Telugu character pairs that might occur. |
| 55 |
|
| 56 |
Although it's possible in theory to create missed cases by combining certain single characters, they are hopefully not something that would happen in written Telugu. |
| 57 |
|
| 58 |
@return {string[]} Telugu char pairs. |
| 59 |
*/ |
| 60 |
export function createTeluguCharPairs() { |
| 61 |
const sampleCharsOneCodePoint = [...independentVowels, ...consonants, ...rareConsonants, ...numerals]; |
| 62 |
const sampleCharsTwoCodePoints = [...doubleCombos]; |
| 63 |
|
| 64 |
const charPairs = []; |
| 65 |
for (const char1 of sampleCharsOneCodePoint) { |
| 66 |
for (const char2 of sampleCharsOneCodePoint) { |
| 67 |
charPairs.push(`${char1}${char2}`); |
| 68 |
} |
| 69 |
|
| 70 |
for (const char2 of sampleCharsTwoCodePoints) { |
| 71 |
charPairs.push(`${char1}${char2}`); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
return charPairs; |
| 76 |
} |