-
Notifications
You must be signed in to change notification settings - Fork 0
/
bzhe-trans.js
328 lines (293 loc) · 11.7 KB
/
bzhe-trans.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
// The file was created by Anna Sorokina on 19.08.2019
// It is based on a similar convertion map-file by George Moroz (created 11.06.2013).
function result() {
var result_field = ady_bzhe2field(input_text);
document.getElementById("output").style.display = "block";
document.getElementById("tip").innerHTML = result_field;
}
function transliterate() {
var input_text = document.getElementById("inp_text").value;
// var trans_sys = document.getElementById("trans_sys").value;
// var stress = document.getElementById("stress").checked;
var punct = document.getElementById("punct").checked;
var tab = document.getElementById("tab").checked;
// if (stress == true) {input_text = input_text.toLowerCase()}
if (tab == true) {input_text = tabulate(input_text)}
if (punct == true) {input_text = rm_punct(input_text)};
var result_field = ady_bzhe2field(input_text);
document.getElementById("output").style.display = "block";
document.getElementById("tip").innerHTML = result_field;
}
document.getElementById("transliterate").onclick = function() {
transliterate();
};
// from bzhedug adyghe cyrillic script to fieldwork notation
function ady_bzhe2field(value) {
value = value.toLowerCase()
// convert combinations of five letters
value = value.replace(/къhуа/g,'qʰa')
value = value.replace(/сшъуа/g,'cʷa')
value = value.replace(/сшӏуа/g,'t͡ṣ̂ʷa')
value = value.replace(/сш1уа/g,'t͡ṣ̂ʷa')
value = value.replace(/сшIуа/g,'t͡ṣ̂ʷa')
value = value.replace(/сшӀуа/g,'t͡ṣ̂ʷa')
value = value.replace(/сшiуа/g,'t͡ṣ̂ʷa')
// convert combinations of four letters
value = value.replace(/пӏуа/g,'ṗʷa')
value = value.replace(/п1уа/g,'ṗʷa')
value = value.replace(/пiуа/g,'ṗʷa')
value = value.replace(/пӀуа/g,'ṗʷa')
value = value.replace(/пIуа/g,'ṗʷa')
value = value.replace(/т1уа/g,'ṭʷa')
value = value.replace(/тIуа/g,'ṭʷa')
value = value.replace(/тӏуа/g,'ṭʷa')
value = value.replace(/тӀуа/g,'ṭʷa')
value = value.replace(/тiуа/g,'ṭʷa')
value = value.replace(/с1уа/g,'c̣ʷa')
value = value.replace(/сIуа/g,'c̣ʷa')
value = value.replace(/сiуа/g,'c̣ʷa')
value = value.replace(/сӏуа/g,'c̣ʷa')
value = value.replace(/сӀуа/g,'c̣ʷa')
value = value.replace(/дзуа/g,'ʒʷa')
value = value.replace(/шъуа/g,'ŝʷa')
value = value.replace(/ш1уа/g,'ṣ̂ʷa')
value = value.replace(/шIуа/g,'ṣ̂ʷa')
value = value.replace(/шӏуа/g,'ṣ̂ʷa')
value = value.replace(/шӀуа/g,'ṣ̂ʷa')
value = value.replace(/шiуа/g,'ṣ̂ʷa')
value = value.replace(/жъуа/g,'ẑʷa')
value = value.replace(/кiуа/g,'ḳʷa')
value = value.replace(/к1уа/g,'ḳʷa')
value = value.replace(/кIуа/g,'ḳʷa')
value = value.replace(/кӏуа/g,'ḳʷa')
value = value.replace(/кӀуа/g,'ḳʷa')
value = value.replace(/кhуа/g,'kʰʷa')
value = value.replace(/къуа/g,'qʷa')
value = value.replace(/къhо/g,'qʰʷe')
value = value.replace(/къhу/g,'qʰʷə')
value = value.replace(/хъуа/g,'χʷa')
value = value.replace(/гъуа/g,'ᴙʷa')
value = value.replace(/сшъу/g,'cʷə')
value = value.replace(/сшъо/g,'cʷe')
value = value.replace(/сш1у/g,'t͡ṣ̂ʷə')
value = value.replace(/сшIу/g,'t͡ṣ̂ʷə')
value = value.replace(/сшӏу/g,'t͡ṣ̂ʷə')
value = value.replace(/сшӀу/g,'t͡ṣ̂ʷə')
value = value.replace(/сшiу/g,'t͡ṣ̂ʷə')
value = value.replace(/сшIо/g,'t͡ṣ̂ʷe')
value = value.replace(/сшiо/g,'t͡ṣ̂ʷe')
value = value.replace(/сш1о/g,'t͡ṣ̂ʷe')
value = value.replace(/сшӏо/g,'t͡ṣ̂ʷe')
value = value.replace(/сшӀо/g,'t͡ṣ̂ʷe')
value = value.replace(/сштh/g,'čʰ')
// convert trigraphic consonants
value = value.replace(/п1о/g,'ṗʷe')
value = value.replace(/п1у/g,'ṗʷə')
value = value.replace(/пIо/g,'ṗʷe')
value = value.replace(/пIу/g,'ṗʷə')
value = value.replace(/пӏо/g,'ṗʷe')
value = value.replace(/пӏу/g,'ṗʷə')
value = value.replace(/пӀо/g,'ṗʷe')
value = value.replace(/пӀу/g,'ṗʷə')
value = value.replace(/пiо/g,'ṗʷe')
value = value.replace(/пiу/g,'ṗʷə')
value = value.replace(/ц1о/g,'c̣ʷe')
value = value.replace(/ц1у/g,'c̣ʷə')
value = value.replace(/цIо/g,'c̣ʷe')
value = value.replace(/цIу/g,'c̣ʷə')
value = value.replace(/цӏо/g,'c̣ʷe')
value = value.replace(/цӏу/g,'c̣ʷə')
value = value.replace(/цӀо/g,'c̣ʷe')
value = value.replace(/цӀу/g,'c̣ʷə')
value = value.replace(/цiо/g,'c̣ʷe')
value = value.replace(/цiу/g,'c̣ʷə')
value = value.replace(/т1о/g,'ṭʷe')
value = value.replace(/т1у/g,'ṭʷə')
value = value.replace(/тIо/g,'ṭʷe')
value = value.replace(/тIу/g,'ṭʷə')
value = value.replace(/тӏо/g,'ṭʷe')
value = value.replace(/тӏу/g,'ṭʷə')
value = value.replace(/тӀо/g,'ṭʷe')
value = value.replace(/тӀу/g,'ṭʷə')
value = value.replace(/тiо/g,'ṭʷe')
value = value.replace(/тiу/g,'ṭʷə')
value = value.replace(/дзо/g,'ʒʷe')
value = value.replace(/дзу/g,'ʒʷə')
value = value.replace(/чъh/g,'čʰ')
value = value.replace(/шъо/g,'ŝʷe')
value = value.replace(/шъу/g,'ŝʷə')
value = value.replace(/ш1у/g,'ṣ̂ʷə')
value = value.replace(/шIу/g,'ṣ̂ʷə')
value = value.replace(/шӏу/g,'ṣ̂ʷə')
value = value.replace(/шӀу/g,'ṣ̂ʷə')
value = value.replace(/шiу/g,'ṣ̂ʷə')
value = value.replace(/ш1о/g,'ṣ̂ʷe')
value = value.replace(/шIо/g,'ṣ̂ʷe')
value = value.replace(/шӏо/g,'ṣ̂ʷe')
value = value.replace(/шӀо/g,'ṣ̂ʷe')
value = value.replace(/шiо/g,'ṣ̂ʷe')
value = value.replace(/жъо/g,'ẑʷe')
value = value.replace(/жъу/g,'ẑʷə')
value = value.replace(/куа/g,'kʷa')
value = value.replace(/к1о/g,'ḳʷe')
value = value.replace(/кiо/g,'ḳʷe')
value = value.replace(/кIо/g,'ḳʷe')
value = value.replace(/кӏо/g,'ḳʷe')
value = value.replace(/кӀо/g,'ḳʷe')
value = value.replace(/кiу/g,'ḳʷə')
value = value.replace(/к1у/g,'ḳʷə')
value = value.replace(/кIу/g,'ḳʷə')
value = value.replace(/кӏу/g,'ḳʷə')
value = value.replace(/кӀу/g,'ḳʷə')
value = value.replace(/к1ь/g,'ḳʼ')
value = value.replace(/кIь/g,'ḳʼ')
value = value.replace(/кӏь/g,'ḳʼ')
value = value.replace(/кӀь/g,'ḳʼ')
value = value.replace(/кiь/g,'ḳʼ')
value = value.replace(/кhо/g,'kʰʷe')
value = value.replace(/кhу/g,'kʰʷə')
value = value.replace(/гуа/g,'gʷa')
value = value.replace(/къо/g,'qʷe')
value = value.replace(/къу/g,'qʷə')
value = value.replace(/къh/g,'qʰ')
value = value.replace(/хъо/g,'χʷe')
value = value.replace(/хъу/g,'χʷə')
value = value.replace(/гъо/g,'ʁʷe')
value = value.replace(/гъу/g,'ʁʷə')
value = value.replace(/1уа/g,'ʔʷa')
value = value.replace(/Iуа/g,'ʔʷa')
value = value.replace(/ӏуа/g,'ʔʷa')
value = value.replace(/Ӏуа/g,'ʔʷa')
value = value.replace(/iуа/g,'ʔʷa')
value = value.replace(/сшт/g,'č')
value = value.replace(/сщh/g,'čʼʰ')
value = value.replace(/сшh/g,'čʰ')
value = value.replace(/сш1/g,'t͡ṣ̂')
value = value.replace(/сшI/g,'t͡ṣ̂')
value = value.replace(/сшӏ/g,'t͡ṣ̂')
value = value.replace(/сшӀ/g,'t͡ṣ̂')
value = value.replace(/сшi/g,'t͡ṣ̂')
value = value.replace(/сшъ/g,'t͡ŝ')
// convert digraphic consonants
value = value.replace(/п1/g,'ṗ')
value = value.replace(/пI/g,'ṗ')
value = value.replace(/пӏ/g,'ṗ')
value = value.replace(/пӀ/g,'ṗ')
value = value.replace(/пi/g,'ṗ')
value = value.replace(/пh/g,'pʰ')
value = value.replace(/т1/g,'ṭ')
value = value.replace(/тI/g,'ṭ')
value = value.replace(/тӏ/g,'ṭ')
value = value.replace(/тӀ/g,'ṭ')
value = value.replace(/тi/g,'ṭ')
value = value.replace(/тh/g,'tʰ')
value = value.replace(/ц1/g,'c̣')
value = value.replace(/цI/g,'c̣')
value = value.replace(/цӏ/g,'c̣')
value = value.replace(/цӀ/g,'c̣')
value = value.replace(/цi/g,'c̣')
value = value.replace(/цh/g,'cʰ')
value = value.replace(/цо/g,'cʷe')
value = value.replace(/цу/g,'cʷə')
value = value.replace(/дз/g,'ʒ')
value = value.replace(/чъ/g,'č')
value = value.replace(/ч1/g,'č̣')
value = value.replace(/чI/g,'č̣')
value = value.replace(/чӏ/g,'č̣')
value = value.replace(/чӀ/g,'č̣')
value = value.replace(/чi/g,'č̣')
value = value.replace(/лъ/g,'λ')
value = value.replace(/л1/g,'λ̣')
value = value.replace(/лI/g,'λ̣')
value = value.replace(/лӏ/g,'λ̣')
value = value.replace(/лӀ/g,'λ̣')
value = value.replace(/лi/g,'λ̣')
value = value.replace(/шъ/g,'ŝ')
value = value.replace(/ш1/g,'ṣ̂')
value = value.replace(/шI/g,'ṣ̂')
value = value.replace(/шӏ/g,'ṣ̂')
value = value.replace(/шӀ/g,'ṣ̂')
value = value.replace(/шi/g,'ṣ̂')
value = value.replace(/жъ/g,'ẑ')
value = value.replace(/щh/g,'šʼʰ')
value = value.replace(/жь/g,'žʼ')
value = value.replace(/чh/g,'čʼʰ')
value = value.replace(/дж/g,'ǯʼ')
value = value.replace(/к1/g,'č̣ʼ')
value = value.replace(/кI/g,'č̣ʼ')
value = value.replace(/кӏ/g,'č̣ʼ')
value = value.replace(/кӀ/g,'č̣ʼ')
value = value.replace(/кi/g,'č̣ʼ')
value = value.replace(/ко/g,'kʷe')
value = value.replace(/ку/g,'kʷə')
value = value.replace(/кh/g,'kʰ')
value = value.replace(/го/g,'gʷe')
value = value.replace(/гу/g,'gʷə')
value = value.replace(/къ/g,'q')
value = value.replace(/хъ/g,'χ')
value = value.replace(/гъ/g,'ʁ')
value = value.replace(/хь/g,'h')
value = value.replace(/1о/g,'ʔʷe')
value = value.replace(/1у/g,'ʔʷə')
value = value.replace(/iо/g,'ʔʷe')
value = value.replace(/iу/g,'ʔʷə')
value = value.replace(/Iо/g,'ʔʷe')
value = value.replace(/Iу/g,'ʔʷə')
value = value.replace(/ӏо/g,'ʔʷe')
value = value.replace(/ӏу/g,'ʔʷə')
value = value.replace(/Ӏо/g,'ʔʷe')
value = value.replace(/Ӏу/g,'ʔʷə')
value = value.replace(/сщ/g,'čʼ')
value = value.replace(/сш/g,'č')
// convert unigraphic consonants
value = value.replace(/п/g,'p')
value = value.replace(/б/g,'b')
value = value.replace(/ф/g,'f')
value = value.replace(/м/g,'m')
value = value.replace(/т/g,'t')
value = value.replace(/д/g,'d')
value = value.replace(/с/g,'s')
value = value.replace(/з/g,'z')
value = value.replace(/ц/g,'c')
value = value.replace(/р/g,'r')
value = value.replace(/н/g,'n')
value = value.replace(/ш/g,'š')
value = value.replace(/ш/g,'šʰ')
value = value.replace(/ж/g,'ž')
value = value.replace(/л/g,'l')
value = value.replace(/щ/g,'šʼ')
value = value.replace(/ч/g,'čʼ')
value = value.replace(/к/g,'k')
value = value.replace(/г/g,'g')
value = value.replace(/х/g,'x')
value = value.replace(/1/g,'ʔ')
value = value.replace(/I/g,'ʔ')
value = value.replace(/ӏ/g,'ʔ')
value = value.replace(/Ӏ/g,'ʔ')
value = value.replace(/i/g,'ʔ')
value = value.replace(/й/g,'j')
// convert digraphic vowels
value = value.replace(/уа/g,'wa')
value = value.replace(/эу([\s\t\r\n])+/g,'ew$1')
value = value.replace(/эу([!")(@#$\[\]%^/\&_=—'*+,.:;<>»«?\\{}|~—])+/g,'ew$1')
// convert unigraphic vowels
value = value.replace(/э/g,'e')
value = value.replace(/а/g,'a')
value = value.replace(/ы/g,'ə')
value = value.replace(/о/g,'we')
value = value.replace(/у/g,'wə')
value = value.replace(/я/g,'ja')
value = value.replace(/е/g,'je')
value = value.replace(/и/g,'jə')
return value
}
// punctuation
function rm_punct(value) {
value = value.replace(/[!")(@#$\[\]%^/\&_=—'*+,.:;<>»«?\\{}|~—]/g,"")
return value
}
// tabs
function tabulate(value) {
value = value.replace(/ /g," ")
return value
}