-
Notifications
You must be signed in to change notification settings - Fork 13
/
syllable-breaker.js
352 lines (309 loc) · 15.5 KB
/
syllable-breaker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
var MY_SYLLABLE_UNKNOWN = 0;
var MY_SYLLABLE_CONSONANT = 1;
var MY_SYLLABLE_MEDIAL = 2;
var MY_SYLLABLE_VOWEL = 3;
var MY_SYLLABLE_TONE = 4;
var MY_SYLLABLE_1039 = 5;
var MY_SYLLABLE_103A = 6;
var MY_SYLLABLE_NUMBER = 7;
var MY_SYLLABLE_SECTION = 8;
var CHAR_PART = [
MY_SYLLABLE_CONSONANT, // 1000;MYANMAR LETTER KA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1001;MYANMAR LETTER KHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1002;MYANMAR LETTER GA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1003;MYANMAR LETTER GHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1004;MYANMAR LETTER NGA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1005;MYANMAR LETTER CA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1006;MYANMAR LETTER CHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1007;MYANMAR LETTER JA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1008;MYANMAR LETTER JHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1009;MYANMAR LETTER NYA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100A;MYANMAR LETTER NNYA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100B;MYANMAR LETTER TTA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100C;MYANMAR LETTER TTHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100D;MYANMAR LETTER DDA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100E;MYANMAR LETTER DDHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 100F;MYANMAR LETTER NNA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1010;MYANMAR LETTER TA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1011;MYANMAR LETTER THA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1012;MYANMAR LETTER DA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1013;MYANMAR LETTER DHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1014;MYANMAR LETTER NA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1015;MYANMAR LETTER PA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1016;MYANMAR LETTER PHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1017;MYANMAR LETTER BA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1018;MYANMAR LETTER BHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1019;MYANMAR LETTER MA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101A;MYANMAR LETTER YA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101B;MYANMAR LETTER RA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101C;MYANMAR LETTER LA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101D;MYANMAR LETTER WA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101E;MYANMAR LETTER SA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 101F;MYANMAR LETTER HA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1020;MYANMAR LETTER LLA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1021;MYANMAR LETTER A;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1022;MYANMAR LETTER SHAN A;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1023;MYANMAR LETTER I;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1024;MYANMAR LETTER II;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1025;MYANMAR LETTER U;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1026;MYANMAR LETTER UU;Lo;0;L;1025 102E;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1027;MYANMAR LETTER E;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1028;MYANMAR LETTER MON E;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1029;MYANMAR LETTER O;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 102A;MYANMAR LETTER AU;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 102B;MYANMAR VOWEL SIGN TALL AA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 102C;MYANMAR VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 102D;MYANMAR VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 102E;MYANMAR VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 102F;MYANMAR VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1030;MYANMAR VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1031;MYANMAR VOWEL SIGN E;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1032;MYANMAR VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1033;MYANMAR VOWEL SIGN MON II;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1034;MYANMAR VOWEL SIGN MON O;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1035;MYANMAR VOWEL SIGN E ABOVE;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1036;MYANMAR SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1037;MYANMAR SIGN DOT BELOW;Mn;7;NSM;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1038;MYANMAR SIGN VISARGA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_1039, // 1039;MYANMAR SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;
MY_SYLLABLE_103A, // 103A;MYANMAR SIGN ASAT;Mn;9;NSM;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 103B;MYANMAR CONSONANT SIGN MEDIAL YA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 103C;MYANMAR CONSONANT SIGN MEDIAL RA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 103D;MYANMAR CONSONANT SIGN MEDIAL WA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 103E;MYANMAR CONSONANT SIGN MEDIAL HA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 103F;MYANMAR LETTER GREAT SA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_NUMBER, // 1040;MYANMAR DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
MY_SYLLABLE_NUMBER, // 1041;MYANMAR DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
MY_SYLLABLE_NUMBER, // 1042;MYANMAR DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
MY_SYLLABLE_NUMBER, // 1043;MYANMAR DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;
MY_SYLLABLE_NUMBER, // 1044;MYANMAR DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;
MY_SYLLABLE_NUMBER, // 1045;MYANMAR DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;
MY_SYLLABLE_NUMBER, // 1046;MYANMAR DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;
MY_SYLLABLE_NUMBER, // 1047;MYANMAR DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;
MY_SYLLABLE_NUMBER, // 1048;MYANMAR DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;
MY_SYLLABLE_NUMBER, // 1049;MYANMAR DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;
MY_SYLLABLE_SECTION, // 104A;MYANMAR SIGN LITTLE SECTION;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_SECTION, // 104B;MYANMAR SIGN SECTION;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 104C;MYANMAR SYMBOL LOCATIVE;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 104D;MYANMAR SYMBOL COMPLETED;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 104E;MYANMAR SYMBOL AFOREMENTIONED;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 104F;MYANMAR SYMBOL GENITIVE;Po;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1050;MYANMAR LETTER SHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1051;MYANMAR LETTER SSA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1052;MYANMAR LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1053;MYANMAR LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1054;MYANMAR LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1055;MYANMAR LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1056;MYANMAR VOWEL SIGN VOCALIC R;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1057;MYANMAR VOWEL SIGN VOCALIC RR;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1058;MYANMAR VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1059;MYANMAR VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 105A;MYANMAR LETTER MON NGA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 105B;MYANMAR LETTER MON JHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 105C;MYANMAR LETTER MON BBA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 105D;MYANMAR LETTER MON BBE;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 105E;MYANMAR CONSONANT SIGN MON MEDIAL NA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 105F;MYANMAR CONSONANT SIGN MON MEDIAL MA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 1060;MYANMAR CONSONANT SIGN MON MEDIAL LA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1061;MYANMAR LETTER SGAW KAREN SHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1062;MYANMAR VOWEL SIGN SGAW KAREN EU;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1063;MYANMAR TONE MARK SGAW KAREN HATHI;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1064;MYANMAR TONE MARK SGAW KAREN KE PHO;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1065;MYANMAR LETTER WESTERN PWO KAREN THA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1066;MYANMAR LETTER WESTERN PWO KAREN PWA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1067;MYANMAR VOWEL SIGN WESTERN PWO KAREN EU;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1068;MYANMAR VOWEL SIGN WESTERN PWO KAREN UE;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1069;MYANMAR SIGN WESTERN PWO KAREN TONE-1;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 106A;MYANMAR SIGN WESTERN PWO KAREN TONE-2;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 106B;MYANMAR SIGN WESTERN PWO KAREN TONE-3;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 106C;MYANMAR SIGN WESTERN PWO KAREN TONE-4;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 106D;MYANMAR SIGN WESTERN PWO KAREN TONE-5;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 106E;MYANMAR LETTER EASTERN PWO KAREN NNA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 106F;MYANMAR LETTER EASTERN PWO KAREN YWA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1070;MYANMAR LETTER EASTERN PWO KAREN GHWA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1071;MYANMAR VOWEL SIGN GEBA KAREN I;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1072;MYANMAR VOWEL SIGN KAYAH OE;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1073;MYANMAR VOWEL SIGN KAYAH U;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1074;MYANMAR VOWEL SIGN KAYAH EE;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1075;MYANMAR LETTER SHAN KA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1076;MYANMAR LETTER SHAN KHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1077;MYANMAR LETTER SHAN GA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1078;MYANMAR LETTER SHAN CA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1079;MYANMAR LETTER SHAN ZA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107A;MYANMAR LETTER SHAN NYA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107B;MYANMAR LETTER SHAN DA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107C;MYANMAR LETTER SHAN NA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107D;MYANMAR LETTER SHAN PHA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107E;MYANMAR LETTER SHAN FA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 107F;MYANMAR LETTER SHAN BA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1080;MYANMAR LETTER SHAN THA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 1081;MYANMAR LETTER SHAN HA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_MEDIAL, // 1082;MYANMAR CONSONANT SIGN SHAN MEDIAL WA;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1083;MYANMAR VOWEL SIGN SHAN AA;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1084;MYANMAR VOWEL SIGN SHAN E;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1085;MYANMAR VOWEL SIGN SHAN E ABOVE;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_VOWEL, // 1086;MYANMAR VOWEL SIGN SHAN FINAL Y;Mn;0;NSM;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1087;MYANMAR SIGN SHAN TONE-2;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1088;MYANMAR SIGN SHAN TONE-3;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 1089;MYANMAR SIGN SHAN TONE-5;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 108A;MYANMAR SIGN SHAN TONE-6;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 108B;MYANMAR SIGN SHAN COUNCIL TONE-2;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 108C;MYANMAR SIGN SHAN COUNCIL TONE-3;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 108D;MYANMAR SIGN SHAN COUNCIL EMPHATIC TONE;Mn;220;NSM;;;;;N;;;;;
MY_SYLLABLE_CONSONANT, // 108E;MYANMAR LETTER RUMAI PALAUNG FA;Lo;0;L;;;;;N;;;;;
MY_SYLLABLE_TONE, // 108F;MYANMAR SIGN RUMAI PALAUNG TONE-5;Mc;0;L;;;;;N;;;;;
MY_SYLLABLE_NUMBER, // 1090;MYANMAR SHAN DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
MY_SYLLABLE_NUMBER, // 1091;MYANMAR SHAN DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
MY_SYLLABLE_NUMBER, // 1092;MYANMAR SHAN DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
MY_SYLLABLE_NUMBER, // 1093;MYANMAR SHAN DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;
MY_SYLLABLE_NUMBER, // 1094;MYANMAR SHAN DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;
MY_SYLLABLE_NUMBER, // 1095;MYANMAR SHAN DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;
MY_SYLLABLE_NUMBER, // 1096;MYANMAR SHAN DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;
MY_SYLLABLE_NUMBER, // 1097;MYANMAR SHAN DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;
MY_SYLLABLE_NUMBER, // 1098;MYANMAR SHAN DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;
MY_SYLLABLE_NUMBER, // 1099;MYANMAR SHAN DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;
MY_SYLLABLE_TONE, // 109A
MY_SYLLABLE_TONE, // 109B
MY_SYLLABLE_TONE, // 109C
MY_SYLLABLE_TONE, // 109D??
MY_SYLLABLE_CONSONANT, // 109E;MYANMAR SYMBOL SHAN ONE;So;0;L;;;;;N;;;;;
MY_SYLLABLE_CONSONANT // 109F;MYANMAR SYMBOL SHAN EXCLAMATION;So;0;L;;;;;N;;;;;
];
var MY_PAIR_ILLEGAL = 0; // illegal sequence
var MY_PAIR_NO_BREAK = 1; // no break
var MY_PAIR_SYL_BREAK = 2; // syllable break
var MY_PAIR_WORD_BREAK = 3; // word break
var MY_PAIR_PUNCTUATION = 4; // punctuation break
var MY_PAIR_CONTEXT = 5; // needs further context analysis
var MY_PAIR_EOL = 6; // end of line
var LANG_MY = 0; // Myanmar
var MM_MAX_CONTEXT_LENGTH = 4;
function get_char_class(char) {
var identifiedClass = MY_SYLLABLE_UNKNOWN;
if ('\u1000' > char || char > '\u109F') {
if ('\uAA60' <= char < '\uAA7C') {
if(char == '\uAA70') {
return MY_SYLLABLE_TONE;
} else if (char == '\uAA7B') {
return MY_SYLLABLE_TONE;
}
return MY_SYLLABLE_CONSONANT;
}
return MY_SYLLABLE_UNKNOWN;
}
identifiedClass = CHAR_PART[char.charCodeAt(0) - '\u1000'.charCodeAt(0)];
return identifiedClass;
}
function get_break_status(before, after) {
// first char = row, second char = column
// 0=illegal, 1=no, 2=yes, 3=yes-line, 4=punctuation, 5=context,
var BKSTATUS = [
// - C M V T 39 3A N S
[ 1, 3, 1, 1, 1, 1, 1, 1, 1 ], // -
[ 3, 5, 1, 1, 1, 1, 1, 2, 4 ], // C
[ 3, 5, 1, 1, 1, 0, 1, 2, 4 ], // M
[ 3, 5, 0, 1, 1, 0, 1, 2, 4 ], // V
[ 3, 2, 0, 1, 1, 0, 1, 2, 4 ], // T
[ 3, 1, 0, 0, 0, 0, 0, 0, 0 ], // 1039
[ 3, 2, 1, 1, 1, 1, 0, 2, 4 ], // 103A
[ 3, 2, 1, 1, 1, 0, 0, 1, 4 ], // N
[ 3, 2, 0, 0, 0, 0, 0, 2, 0 ] // S
];
firstClass = get_char_class(before);
secondClass = get_char_class(after);
return BKSTATUS[firstClass][secondClass];
}
function evaluate_context(contextText, offset, langHint) {
var text = contextText.substring(offset, contextText.length);
var length = text.length;
if (length < 4) {
for(var x = 1; x <= 4 - length; x++) {
text += " ";
}
}
if(text[0] == '\u1021' && langHint == LANG_MY) {
return MY_PAIR_NO_BREAK;
}
if(text[1] == '\u002d') {
return MY_PAIR_NO_BREAK;
}
if(text[1] == '\u103F') {
return MY_PAIR_NO_BREAK;
}
if(text[2] == '\u1037' && text[3] == '\u103A') {
return MY_PAIR_NO_BREAK;
}
if(text[2] == '\u1039') {
return MY_PAIR_NO_BREAK;
}
if(text[2] == '\u103A' && langHint == LANG_MY) {
// Karen (and also some loan words in Myanmar) can have a starting 103A
return MY_PAIR_NO_BREAK;
}
return MY_PAIR_SYL_BREAK;
}
function get_next_syllable(text, length, offset) {
var breakType = MY_PAIR_NO_BREAK;
var i = offset;
var foundCluster = false;
if (offset >= length) {
return [breakType, length];
}
while ( (i + 1) < length ) {
var breakStatus = get_break_status(text[i], text[i+1]);
if(breakStatus == MY_PAIR_NO_BREAK) {
//
} else if(breakStatus == MY_PAIR_SYL_BREAK ||
breakStatus == MY_PAIR_WORD_BREAK ||
breakStatus == MY_PAIR_PUNCTUATION ||
breakStatus == MY_PAIR_ILLEGAL) {
breakType = breakStatus;
foundCluster = true;
} else if(breakStatus == MY_PAIR_CONTEXT) {
breakType = evaluate_context(text, i, LANG_MY);
if(breakType != MY_PAIR_NO_BREAK) {
foundCluster = true;
}
} else {
print ("Unexpected status" + breakStatus);
}
if(foundCluster) break;
i += 1;
}
if( (i + 1) == text.length) {
breakType = MY_PAIR_EOL;
}
return [breakType, i + 1];
}
function is_myanmar_char(char) {
if('\u1000' <= char <= '\u109f' || '\uaa60' <= char <= '\uaa7f') {
return true;
}
return false;
}
function is_not_myanmar(char) {
var charClass = get_char_class(char);
if(charClass == MMC_OT || charClass == MMC_RQ || charClass == MMC_LQ || charClass == MMC_SP) {
return true;
}
return false;
}
function is_neutral(char) {
var charClass = get_char_class(char);
if(charClass == MMC_WJ || charClass == MMC_RQ || charClass == MMC_LQ || charClass == MMC_SP || charClass == MMC_NJ) {
return true;
}
return false;
}
module.exports = function(input) {
var offset = 0;
var result = [];
while(offset < input.length) {
var output = get_next_syllable(input, input.length, offset);
var type = output[0];
var next = output[1];
result.push(input.substring(offset, next));
offset = next;
}
return result;
};