-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubstitution.py
executable file
·411 lines (397 loc) · 11.2 KB
/
substitution.py
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
substitution_dict = {
"া": "a ",
"ি": "i ",
"ী": "i ",
"ু": "u ",
"ূ": "u ",
"ৃ": "r ",
"ৄ": "r ",
"ে": "e ",
"ৈ": "oi ",
"ো": "o ",
"ৌ": "ou ",
"ৗ": "ou ",
"অ": "o ",
"আ": "a ",
"ই": "e ",
"ঈ": "e ",
"উ": "u ",
"ঊ": "u ",
"ঋ": "r ",
"এ": "e ",
"ঐ": "oi ",
"ও": "o ",
"ঔ": "ou ",
"ক": "k ",
"খ": "kh ",
"গ": "g ",
"ঘ": "gh ",
"ঙ": "ng ",
"চ": "ch ",
"ছ": "cch ",
"জ": "j ",
"ঝ": "jh ",
"ঞ": "", # er por kar jeta shetar uccharon,..kar na thakle emniy o diye replace er shomoy replace hobe
"ট": "t ",
"ঠ": "th ",
"ড": "d ",
"ঢ": "dh ",
"ণ": "n ",
"ত": "t ",
"থ": "th ",
"দ": "d ",
"ধ": "dh ",
"ন": "n ",
"প": "p ",
"ফ": "ph ",
"ব": "b ",
"ভ": "bh ",
"ম": "m ",
"য": "j ",
"র": "r ",
"ল": "l ",
"শ": "sh ",
"ষ": "sh ",
"স": "s ",
"হ": "h ",
"ড়": "r ", #??
"ড়": "r ", #?? some of this char was not being matched wirh the immediate prev one
"ঢ়": "r ",
"ঢ়": "r ", # prothom alo
"য়": "y ", # will eventually be replaced by 'o' or any other kar
"য়": "y ", #??
"ক্ক": "kk ",
"ক্ট": "kt ",
"ক্ট্র": "ktr ",
"ক্ত": "kt ",
"ক্ত্র": "ktr ",
"ক্ব": "kk ",
"ক্ম": "km ",
"ক্য": "ky ", #
"ক্র": "kr ",
"ক্ল": "kl ",
"ক্ষ": "kkh ",
"ক্ষ্ণ": "khn ",
"ক্ষ্ব": "ksh ", #
"ক্ষ্ম": "kkh ",
"ক্ষ্ম্য": "kkh ",
"ক্ষ্য": "kkh ",
"ক্স": "ks ",
"খ্য": "kkh ", #
"খ্র": "khr ",
"গ্ণ": "gn ",
"গ্ধ": "gdh ",
"গ্ধ্য": "gdh ",
"গ্ধ্র": "gdhr ",
"গ্ন": "gn ",
"গ্ন্য": "gn ",
"গ্ব": "gb ",
"গ্ম": "gm ",
"গ্য": "gg ", #
"গ্র": "gr ",
"গ্র্য": "gr ", #
"গ্ল": "gl ",
"ঘ্ন": "ghn ",
"ঘ্য": "gh ", #
"ঘ্র": "ghr ",
"ঙ্ক": "nk ", #
"ঙ্ক্ত": "ngkt ",
"ঙ্ক্য": "nk ", #
"ঙ্ক্ষ": "nkh ",
"ঙ্খ": "nkh ",
"ঙ্খ্য": "nkh ", #
"ঙ্গ": "ng ", #
"ঙ্গ্য": "ng ", #
"ঙ্ঘ": "ngh ",
"ঙ্ঘ্য": "ngh ", #
"ঙ্ঘ্র": "ngghr ", #
"ঙ্ম": "ngm ",
"চ্চ": "cc ",
"চ্ছ": "cch ",
"চ্ছ্ব": "cch ",
"চ্ছ্র": "cchr ",
"চ্ঞ": "nch ",
"চ্ব": "ch ",
"চ্য": "ch ",
"জ্জ": "jj ",
"জ্জ্ব": "jj ",
"জ্ঝ": "jjh ",
"জ্ঞ": "g ", #
"জ্ব": "j ",
"জ্য": "jj ",
"জ্র": "jr ",
"ঞ্চ": "nch ",
"ঞ্ছ": "ncch ",
"ঞ্জ": "nj ",
"ঞ্ঝ": "njh ",
"ট্ট": "tt ",
"ট্ব": "tt ",
"ট্ম": "tm ",
"ট্য": "tt ",
"ট্র": "tr ",
"ড্ড": "dd ",
"ড্ব": "d ",
"ড্য": "d ", #
"ড্র": "dr ",
"ড়্গ": "rog ",
"ঢ্য": "ddh ",
"ঢ্র": "dhr ",
"ণ্ট": "nt ",
"ণ্ঠ": "nth ",
"ণ্ঠ্য": "nth ",
"ণ্ড": "nd ",
"ণ্ড্য": "nd ",
"ণ্ড্র": "ndr ",
"ণ্ঢ": "nt ",
"ণ্ণ": "nn ",
"ণ্ব": "n ",
"ণ্ম": "nm ",
"ণ্য": "nn ", #
"ৎক": "tk ",
"ৎখ": "tkh ",
"ত্ত": "tt ",
"ত্ত্ব": "tt ",
"ত্ত্য": "tt ",
"ত্থ": "th ",
"ত্ন": "tn ",
"ৎপ": "tp ",
"ত্ব": "tt ",
"ত্ম": "tt ",
"ত্ম্য": "tt ",
"ত্য": "tt ",
"ত্র": "tr ",
"ত্র্য": "tr ",
"ৎল": "tl ",
"ৎস": "tsh ",
"থ্ব": "thb ",
"থ্য": "th ",
"থ্র": "thr ",
"দ্গ": "dg ",
"দ্ঘ": "dgh ",
"দ্দ": "dd ",
"দ্দ্ব": "dd ",
"দ্ধ": "ddh ",
"দ্ব": "dd ",
"দ্ভ": "dbh ",
"দ্ভ্র": "dbhr ",
"দ্ম": "dd ",
"দ্য": "dd ",
"দ্র": "dr ",
"দ্র্য": "dr ",
"ধ্ন": "dhn ",
"ধ্ব": "dh ",
"ধ্ম": "dhm ",
"ধ্য": "ddh ",
"ধ্র": "dhr ",
"ন্ট": "nt ",
"ন্ট্র": "ntr ",
"ন্ঠ": "nth ",
"ন্ড": "nd ",
"ন্ড্র": "ndr ",
"ন্ত": "nt ",
"ন্ত্ব": "nt ",
"ন্ত্য": "nt ",
"ন্ত্র": "ntr ",
"ন্ত্র্য": "ntr ",
"ন্থ": "nth ",
"ন্থ্র": "nthr ",
"ন্দ": "nd ",
"ন্দ্য": "nd ",
"ন্দ্ব": "nd ",
"ন্দ্র": "ndr ",
"ন্ধ": "ndh ",
"ন্ধ্য": "ndh ",
"ন্ধ্র": "ndhr ",
"ন্ন": "nn ",
"ন্ব": "n ",
"ন্ম": "nm ",
"ন্য": "n ", #
"প্ট": "pt ",
"প্ত": "pt ",
"প্ন": "pn ",
"প্প": "pp ",
"প্য": "p ", #
"প্র": "pr ",
"প্র্য": "pr ",
"প্ল": "pl ",
"প্স": "psh ",
"ফ্র": "fr ",
"ফ্ল": "fl ",
"ব্জ": "bj ",
"ব্দ": "bd ",
"ব্ধ": "bdh ",
"ব্ব": "bb ",
"ব্য": "b ",
"ব্র": "br ",
"ব্ল": "bl ",
"ভ্ব": "bh ",
"ভ্য": "bh ",
"ভ্র": "bhr ",
"ম্ন": "mn ",
"ম্প": "mp ",
"ম্প্র": "mpr ",
"ম্ফ": "mph ",
"ম্ব": "mb ",
"ম্ব্র": "mbr ",
"ম্ভ": "mbh ",
"ম্ভ্র": "mbhr ",
"ম্ম": "mm ",
"ম্য": "m ",
"ম্র": "mr ",
"ম্ল": "ml ",
"য্য": "jj ",
"র্ক": "rk ",
"র্ক্য": "rk ",
"র্গ্য": "rg ",
"র্ঘ্য": "rgh ",
"র্চ্য": "rch ",
"র্জ্য": "rj ",
"র্জ্ঞ": "rg ",
"র্ণ্য": "rn ",
"র্ত্য": "rt ",
"র্থ্য": "rth ",
"র্ব্য": "rb ",
"র্ম্য": "rm ",
"র্শ্য": "rsh ",
"র্ষ্য": "rsh ",
"র্হ্য": "rh ",
"র্খ": "rkh ",
"র্গ": "rg ",
"র্গ্র": "rgr ",
"র্ঘ": "rgh ",
"র্চ": "rch ",
"র্ছ": "rcch ",
"র্জ": "rj ",
"র্ঝ": "rjh ",
"র্ট": "rt ",
"র্ড": "rd ",
"র্ণ": "rn ",
"র্ত": "rt ",
"র্ত্ম": "rtm ",
"র্ত্র": "rtr ",
"র্ৎস": "rtsh ",
"র্থ": "rth ",
"র্দ": "rd ",
"র্দ্ব": "rd ",
"র্দ্র": "rd ",
"র্ধ": "rdh ",
"র্ধ্ব": "rdh ",
"র্ন": "rn ",
"র্প": "rp ",
"র্ফ": "rf ",
"র্ব": "rb ",
"র্ভ": "rbh ",
"র্ম": "rm ",
"র্য": "rj ",
"র্ল": "rl ",
"র্শ": "rsh ",
"র্শ্ব": "rsh ",
"র্ষ": "rsh ",
"র্স": "rs ",
"র্হ": "rh ",
"র্হ্য": "rh ",
"র্ঢ্য": "rdh ",
"ল্ক": "lk ",
"ল্ক্য": "lk ",
"ল্গ": "lg ",
"ল্ট": "lt ",
"ল্ড": "ld ",
"ল্প": "lp ",
"ল্ফ": "lf ",
"ল্ব": "lb ",
"ল্ভ": "lbh ",
"ল্ম": "lm ",
"ল্য": "l ",
"ল্ল": "ll ",
"শ্চ": "sch ",
"শ্ছ": "scch ",
"শ্ন": "shn ",
"শ্ব": "ssh ",
"শ্ম": "ssh ",
"শ্য": "ssh ",
"শ্র": "shr ",
"শ্ল": "shl ",
"ষ্ক": "shk ",
"ষ্ক্র": "shkr ",
"ষ্ট": "sht ",
"ষ্ট্য": "sht ",
"ষ্ট্র": "shtr ",
"ষ্ঠ": "shth ",
"ষ্ঠ্য": "shth ",
"ষ্ণ": "shn ",
"ষ্প": "shp ",
"ষ্প্র": "shpr ",
"ষ্ফ": "shf ",
"ষ্ব": "sh ",
"ষ্ম": "shm ",
"ষ্য": "sh ",
"স্ক": "shk ",
"স্ক্র": "skr ",
"স্খ": "sth ",
"স্ট": "st ",
"স্ট্র": "str ",
"স্ত": "st ",
"স্ত্ব": "st ",
"স্ত্য": "st ",
"স্ত্র": "str ",
"স্থ": "sth ",
"স্থ্য": "sth ", # age eta chk howa uchit na er ager tar che?
"স্ন": "sn ",
"স্প": "shp ",
"স্প্র": "spr ",
"স্প্ল": "spl ",
"স্ফ": "shf ",
"স্বা": "sh ",
"স্ম": "sm ",
"স্য": "sh ",
"স্র": "sr ",
"স্ল": "sl ",
"হ্ণ": "hn ",
"হ্ন": "nh ",
"হ্ব": "hb ",
"হ্ম": "hm ", #
"হ্য": "h ",
"হ্র": "r ",
"হ্ল": "hl ",
"ৎ": "t ",
"ং": "ng ",
"ঃ": "h ", #
# "ঁ": "", # chondrobindu / onno kauke skip korte chaile blank rakhbo..space dile word bhenge jabe (separate word hishebe considered hobe)
"ঁ": "", # some texts on prothom alo requires this version to be replaced...although they look the same (this one and prev one)
"্": "h ",
" ্": "h ", # prothom alo
" ্": "h ", # prothom alo (another)
"ঽ": "h ",
"্য": "", # jofola (ager borno ditto hobe)
"্র": "r ", # I skipped ref as it is already taken with different letters in conjugation
"্ব": "",
"০": "0 ",
"১": "1 ",
"২": "2 ",
"৩": "3 ",
"৪": "4 ",
"৫": "5 ",
"৬": "6 ",
"৭": "7 ",
"৮": "8 ",
"৯": "9 ",
"।": ". ",
" ়,": ", ", # some commas on prothom alo require this to be
"়": ". " # (dot, bangla) prothom alo
}
# extra space added just to find the letter boundary
# https://bn.wiktionary.org/wiki/%E0%A6%89%E0%A6%87%E0%A6%95%E0%A6%BF%E0%A6%85%E0%A6%AD%E0%A6%BF%E0%A6%A7%E0%A6%BE%E0%A6%A8:%E0%A6%AC%E0%A6%BE%E0%A6%82%E0%A6%B2%E0%A6%BE_%E0%A6%AF%E0%A7%81%E0%A6%95%E0%A7%8D%E0%A6%A4%E0%A6%AC%E0%A6%B0%E0%A7%8D%E0%A6%A3%E0%A7%87%E0%A6%B0_%E0%A6%A4%E0%A6%BE%E0%A6%B2%E0%A6%BF%E0%A6%95%E0%A6%BE
# https://en.wikipedia.org/wiki/Bengali_alphabet
# unique_subs = ['u', 'tt', 'tsh', 'tr', 'tp', 'tn', 'tm', 'tl', 'tkh', 'tk', 'thr', 'thb', 'th', 't', 'str', 'sth', 'st', 'ssh', 'sr', 'spr', 'spl', 'sn', 'sl', 'skr', 'shtr', 'shth', 'sht', 'shr', 'shpr', 'shp', 'shn', 'shm', 'shl', 'shkr', 'shk', 'shf', 'sh', 'sch', 'scch', 's', 'rtsh', 'rtr', 'rtm', 'rth', 'rt', 'rsh', 'rs', 'rp', 'rog', 'rn', 'rm', 'rl', 'rkh', 'rk', 'rjh', 'rj', 'rh', 'rgr', 'rgh', 'rg', 'rf', 'rdh', 'rd', 'rch', 'rcch', 'rbh', 'rb', 'r', 'pt', 'psh', 'pr', 'pp', 'pn', 'pl', 'ph', 'p', 'ou', 'oi', 'o', 'ntr', 'nthr', 'nth', 'nt', 'nn', 'nm', 'nkh', 'nk', 'njh', 'nj', 'nh', 'ngm', 'ngkt', 'ngh', 'ngghr', 'ng', 'ndr', 'ndhr', 'ndh', 'nd', 'nch', 'ncch', 'n', 'mr', 'mpr', 'mph', 'mp', 'mn', 'mm', 'ml', 'mbr', 'mbhr', 'mbh', 'mb', 'm', 'lt', 'lp', 'lm', 'll', 'lk', 'lg', 'lf', 'ld', 'lbh', 'lb', 'l', 'ky', 'ktr', 'kt', 'ksh', 'ks', 'kr', 'km', 'kl', 'kkh', 'kk', 'khr', 'khn', 'kh', 'k', 'jr', 'jjh', 'jj', 'jh', 'j', 'i', 'hn', 'hm', 'hl', 'hb', 'h', 'gr', 'gn', 'gm', 'gl', 'ghr', 'ghn', 'gh', 'gg', 'gdhr', 'gdh', 'gb', 'g', 'fr', 'fl', 'e', 'dr', 'dhr', 'dhn', 'dhm', 'dh', 'dgh', 'dg', 'ddh', 'dd', 'dbhr', 'dbh', 'd', 'ch', 'cchr', 'cch', 'cc', 'br', 'bl', 'bj', 'bhr', 'bh', 'bdh', 'bd', 'bb']
unique_subs = "u tt tsh tr tp tn tm tl tkh tk thr thb th t str sth st ssh sr spr spl sn sl skr shtr shth sht shr shpr shp shn shm shl shkr shk shf sh sch scch s rtsh rtr rtm rth rt rsh rs rp rog rn rm rl rkh rk rjh rj rh rgr rgh rg rf rdh rd rch rcch rbh rb r pt psh pr pp pn pl ph p ou oi o ntr nthr nth nt nn nm nkh nk njh nj nh ngm ngkt ngh ngghr ng ndr ndhr ndh nd nch ncch n mr mpr mph mp mn mm ml mbr mbhr mbh mb m lt lp lm ll lk lg lf ld lbh lb l ky ktr kt ksh ks kr km kl kkh kk khr khn kh k jr jjh jj jh j i hn hm hl hb h gr gn gm gl ghr ghn gh gg gdhr gdh gb g fr fl e dr dhr dhn dhm dh dgh dg ddh dd dbhr dbh d ch cchr cch cc br bl bj bhr bh bdh bd bb b "
# # this list is generated by:
# ######## find all replacements in descending lexico order
# l = []
# for char, sub in substitution_dict.items():
# l.append(sub)
# l = list(set(l))
# l.sort()
# l.reverse()
# print(l)
# for string in l:
# print(string, end = " ")