-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathg2p-cas.grm
384 lines (317 loc) · 19.9 KB
/
g2p-cas.grm
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
import 'common.grm' as common;
######## G2P-rules for ... ################################################
#
# * input string is one token
# * input should be normalized (no digits, punctuation or other symbols, etc. are handled in this grammar)
# * compounds might not be entirely correctly transcribed, so decompounding is a good step to perform beforehand
# * exceptional cases are not handled, these should be listed in a manually edited pronunciation dictionary
#
# FSTs written as upper case are steps listed in the final export statement.
#
# This grammar was developed and tested using Version 1.3.3 of Thrax (http://www.openfst.org/twiki/bin/view/GRM/Thrax)
# and OpenFst 1.7.7 (http://www.openfst.org/twiki/bin/view/FST/WebHome)
#
# To compile and test this grammar from the command line:
#
# $thraxmakedep g2p.grm
# $make
# $thraxrewrite-tester --far=g2p.far --rules=G2P --input_mode=utf8 --output_mode=utf8
#
#############################################################################################################
# all possible input and output symbols
sigma_star = common.whole_alphabet*;
#### PREPARE INPUT ##########################################################################################
#
# We need to take into account that input and output symbol tables overlap, and thus, without some preprocessing,
# output of earlier stages could be handled as input symbols at later stages. We prevent this by adding a '+'
# in front of each input symbol.
#
# Insert a '+' before each character, and then join diphthongs (au, ei, ey):
# 'hlaupa' becomes '+h+l+au+p+a'
#
#############################################################################################################
separate_alpha = CDRewrite["".utf8 : "+".utf8, "".utf8, common.alphabet, sigma_star];
reunite_diphthongs_1 = CDRewrite["+".utf8 : "".utf8, "e".utf8, "i".utf8 | "y".utf8, sigma_star];
reunite_diphthongs_2 = CDRewrite["+".utf8 : "".utf8, "a".utf8, "u".utf8, sigma_star];
reunite_diphthongs = Optimize[reunite_diphthongs_1 @ reunite_diphthongs_2];
export ALIGN_GRAPHEMES = Optimize[separate_alpha @ reunite_diphthongs];
#### G2P-RULES ##############################################################################################
#
#############################################################################################################
# 'x' is pronounced 'k s'
# Need to do this replacement already here, because vowel length differs depending on the number of following
# consonants. If we did this at the end together with the general default replacements, we would e.g. get
# 'lax' - 'l a: k s' instead of 'l a k s'.
# TODO check words like 'laks', 'baks' etc. (genetive from 'lak', 'bak') - we do have a long 'a' there. Is there a
# final list for words having 'ks' in the stem (like lax and baks (from baksa))?
x_ks = CDRewrite["+x".utf8 : " k s".utf8, "", "", sigma_star];
X_KS_FST = Optimize[x_ks];
# examples: 'hugi', 'bogi' 'súginn' 'laugin'
# (except for 'fljúgi', 'sjúgi', 'ljúgi', etc., where 'g' is omitted.)
vowel_gi = ("+a+g+i".utf8 : " ai j I".utf8) | ("+æ+g+j".utf8 : " ai j".utf8)
| ("+e+g+i".utf8 : " ei j I".utf8) | ("+u+g+i".utf8 : " Yi j I".utf8)
| ("+o+g+i".utf8 : " Oi j I".utf8) | ("+j+ú+g+i".utf8 : " j u I")
| ("+ú+g+i".utf8 : " u j I".utf8) | ("+í+u".utf8 : " i j Y".utf8)
| ("+í+a".utf8 : " i j a".utf8) | ("+au+g+i".utf8 : " 9i j I".utf8) | ("+y+g+i".utf8 : " i j I".utf8);
vowel_gi_rule_1 = CDRewrite[vowel_gi, "", "", sigma_star];
# examples: 'g' pronounced ' j' in 'skóginn' but not 'ógirnilegt'
vowel_gi_rule_2 = CDRewrite[("+á+g+i".utf8 : " au j I".utf8) | ("+ó+g+i".utf8 : " ou j I".utf8), common.consonant, "", sigma_star];
export VOWEL_GI_FST = Optimize[vowel_gi_rule_1 @ vowel_gi_rule_2];
#####################################
#
# NG-NK
#
#####################################
# in standard pronunciation a, e, i, o, u and ö become 'au' 'ei' 'i' 'ou' 'u' and '9i' before ng and nk
# keep 'ei' as input as well to deal with words like 'einkunn'
diphthongize = ("+a".utf8 : " au".utf8) | ("+e".utf8 : " ei".utf8)
| ("+ei".utf8 : " ei".utf8) | ("+i".utf8 : " i".utf8) | ("+y".utf8 : " i".utf8)
| ("+o".utf8 : " ou".utf8) | ("+u".utf8 : " u".utf8) | ("+ö".utf8 : " 9i".utf8);
ng_nk_rule = CDRewrite[diphthongize, "", "+n+g" | "+n+k", sigma_star];
ng_nk_fst = Optimize[ng_nk_rule];
# in standard pronunciation 'ng' becomes 'Jc' and 'nk' becomes 'J_0c' in a front-vowel environment
nasal_clusters_front = ("+n+g".utf8: " J c".utf8) | ("+n+k".utf8 : " J_0 c");
nasal_clusters_front_rule = CDRewrite[nasal_clusters_front, "", common.plus common.front_vowel, sigma_star];
nasals_fronting = Optimize[nasal_clusters_front_rule];
# in standard pronunciation 'ng' becomes 'Nk' and 'nk' becomes 'N_0k' in a back-vowel environment
nasal_clusters_back = ("+n+g".utf8 : " N k".utf8) | ("+n+k".utf8 : " N_0 k".utf8);
nasal_clusters_back_rule = CDRewrite[nasal_clusters_back, "", common.plus_or_space* (common.back_vowel | common.liquid | "[EOS]"), sigma_star];
nasals_back = Optimize[nasal_clusters_back_rule];
export NG_NK = Optimize[ng_nk_fst @ nasals_fronting @ nasals_back];
#########################################
#
# LONG VOWELS
#
#########################################
# vowels are long in a first syllable before one consonant, one consonant+liquid or before end-of-string
# examples: 'aka' - 'a: k a', 'kú' - 'k u:', 'í - 'i:' 'tekja' - 't_h E: c a'
long_vowels = CDRewrite[
common.long_vowels_map,
"[BOS]" common.space* (common.plus common.consonant)*,
"[EOS]" | (common.plus_or_space common.consonant (common.plus_or_space common.vowel | "[EOS]")) | (common.plus common.plosive common.plus common.liquid) | (common.plus common.vowel), sigma_star];
export LONG_VOWELS = Optimize[long_vowels];
########################################
#
# ASPIRATION
#
########################################
post_aspir = ("+k" : " k_h") | ("+p" : " p_h") | ("+t" : " t_h");
post_aspir_rule = CDRewrite[post_aspir, "[BOS]", common.plus_or_space (common.vowel | common.liquid | common.lateral), sigma_star];
insert_post_aspir = Optimize[post_aspir_rule];
pre_aspir = ("+k+k".utf8 : " h k".utf8) | ("+p+p".utf8 : " h p".utf8) | ("+t+t".utf8 : " h t".utf8)
| ("+p+l".utf8 : " h p l".utf8) | ("+p+n".utf8 : " h p n".utf8) | ("+t+l".utf8 : " h t l".utf8)
| ("+t+m".utf8 : "+h+t+m".utf8) | ("+t+n".utf8 common.plus_or_space : " h t n+".utf8) | ("+k+l".utf8 : " h k l".utf8) | ("+k+n".utf8 : " h k n".utf8);
pre_aspir_rule = CDRewrite[pre_aspir, common.vowel, "", sigma_star];
gt_pre_aspir = CDRewrite[("+á+g+t".utf8 : " au h t".utf8), "", "", sigma_star];
# need to devoice 'r' before 'k' at this place, in case fronting becomes necessary (in which case we loose distinction between 'k' and 'g')
rk_pre_aspir = (("+r+k+t".utf8 : " r_0 t".utf8) | ("+r+k".utf8 : " r_0+k".utf8));
rk_pre_aspir_rule = CDRewrite[rk_pre_aspir, "", "", sigma_star];
insert_pre_aspir = Optimize[pre_aspir_rule @ gt_pre_aspir @ rk_pre_aspir_rule];
export ASPIRATION = Optimize[insert_post_aspir @ insert_pre_aspir];
#######################################
#
# FRONTING
#
#######################################
# example: 'kíkja' 'eggi'
fronting_kj = ("+g+g+j".utf8 : " c".utf8) | ("+g+j".utf8 : " c".utf8) | ("+k+j".utf8 : " c".utf8) | (" k_h j".utf8 : "c_h".utf8);
fronting_kj_rule = CDRewrite[fronting_kj, "", "", sigma_star];
fronting = ("+s+t+k".utf8 : " s c") | (common.plus_or_space "k".utf8 : " c".utf8) | (" k_h".utf8 : " c_h".utf8) | ("+g+g".utf8 : " c".utf8) | ("+g".utf8 : " c".utf8);
fronting_rule = CDRewrite[fronting, "", common.plus_or_space common.front_vowel, sigma_star];
export FRONT = Optimize[fronting_kj_rule @ fronting_rule];
#######################################
#
# SOFTEN
#
#######################################
# In casual allegro speech, 'f' and 'g' can be dropped completely after 'á/ó/ú'
# Examples: 'rófa', 'mágur', 'bjúga'.
soften_cons_1 = ("+f".utf8 : "".utf8) | ("+g".utf8 : "".utf8);
soften_cons_rule_1 = CDRewrite[soften_cons_1,
("+á".utf8 | "+ú".utf8 | "+ó".utf8 | " au:".utf8 | " ou:".utf8 | " u:".utf8), common.plus common.vowel, sigma_star];
# examples: 'sofa', 'saga', 'sagði'
soften_cons_2 = ("+f".utf8 : " v".utf8) | ("+g".utf8 : " G".utf8);
soften_cons_rule_2 = CDRewrite[soften_cons_2,
(common.vowel | ":".utf8), common.plus (common.vowel | "b".utf8 | "ð".utf8 | "m".utf8 | "r".utf8), sigma_star];
# examples: 'horfa' but NOT 'horfðum' -> 'hOrvDYm' but 'hOrDYm'
soften_cons_3 = ("+r+f".utf8 : " r v".utf8);
soften_cons_rule_3 = CDRewrite[soften_cons_3,
(common.vowel | ":".utf8), common.plus common.vowel, sigma_star];
export SOFTEN = Optimize[soften_cons_rule_1 @ soften_cons_rule_2 @ soften_cons_rule_3];
####### VARIATION ###################
#
# These rules are dependent on dialect/variation
#
#####################################
delete_k = CDRewrite[("+k+n+t".utf8 : " n_0 t".utf8), "", "", sigma_star];
DELETE_K = Optimize[delete_k];
replace_hv = ("+h+v".utf8 : " k_h v".utf8);
replace_hv_rule = CDRewrite[replace_hv, "", "", sigma_star];
REPLACE_HV = Optimize[replace_hv_rule];
# example: 'þorsks' in casual speech
delete_sk = ("+r+s+k+s".utf8 : " r_0 s".utf8);
delete_sk_rule = CDRewrite[delete_sk, "", "", sigma_star];
DELETE_SK = Optimize[delete_sk_rule];
clusters_cas =
("+f+l+d".utf8 : " l t".utf8) | ("+f+n+s".utf8 : " f s".utf8) | ("+g+n+s".utf8 : " x s".utf8) | ("+f+t+s".utf8 : " f s".utf8)
| ("+g+t+s".utf8 : " x s".utf8) | ("+k+k+t+s".utf8 : " x s".utf8) | ("+k+t+s".utf8 : " x s".utf8)
| ("+l+f+r".utf8 : " l r".utf8) | ("+l+k+s".utf8 : " l s".utf8) | ("+l+p+s".utf8 : " l s".utf8) | ("+l+d+s".utf8 : " l s".utf8) |
("+l+l+d+s".utf8 : " l s".utf8) |
("+l+f+s".utf8 : " l s".utf8) | ("+l+s+k+s".utf8 : " l s".utf8)
| ("+l+t+s".utf8 | "+l+l+t+s".utf8 : " l_0 s")
| ("+m+d+s".utf8 : " m s".utf8) | ("+m+m+d+s".utf8 : " m s".utf8) | ("+m+p+s".utf8 : " m s".utf8)
| ("+n+g+d+s".utf8 : " N s".utf8) | ("+n+g+n".utf8 : " n".utf8) | ("+n+k+s".utf8 : " N_0 s".utf8) | ("+n+d+s".utf8 : " n s".utf8) |
("+n+n+d+s".utf8 : " n s".utf8) | ("+n+s+k+s".utf8 : " n s".utf8) |
("+n+n+s+k+s".utf8 : " n s".utf8)
| ("+n+n+s+k+t".utf8|"+n+s+k+t" : " n s t".utf8) | ("+p+p+t+s".utf8|"+p+t+s".utf8 : " f s".utf8) | ("+r+f+s".utf8 : " r s".utf8)
| ("+r+f+s+t".utf8 : " s t".utf8) | ("+r+g+s".utf8 : " r s".utf8) |("+r+k+s".utf8 : " r_0 s".utf8) | ("+r+k+s+t".utf8 : " s t".utf8)
| ("+r+k+t+s".utf8 : " r_0 s".utf8) | ("+r+l+s".utf8 : " l s".utf8) | ("+r+m+d".utf8 : " m t".utf8) | ("+r+m+s".utf8 : " m s".utf8) | ("+r+m+t".utf8 : " m_0 t".utf8)
| ("+r+n+d".utf8 : " n t".utf8) | ("+r+n+s+k".utf8 : " n s k".utf8) |("+r+p+s".utf8 : " r_0 s".utf8) | ("+r+p+s+t".utf8 : " s t".utf8)
| ("+r+p+t+s".utf8 : " r_0 s".utf8)
| ("+r+s+k+t".utf8 : " s t".utf8) | ("+r+s+k".utf8 : " s k".utf8) |
("+r+s+t".utf8 : " s t".utf8) | ("+r+r+s+t".utf8 : " s t".utf8) |
("+r+s+t+s".utf8 : " s".utf8) | ("+r+s+n".utf8 : " s t n".utf8)
| ("+r+t+s".utf8 : " r_0 s".utf8) | ("+r+r+t+s".utf8 : " r_0 s".utf8)
| ("+s+k+s".utf8 : " s".utf8) | ("+s+p+s".utf8 : " s".utf8)
| ("+s+k+t".utf8 : " s t".utf8) | ("+s+t+s".utf8 : " s".utf8);
clusters_cas_rule = CDRewrite[clusters_cas, "", "", sigma_star];
CLUSTERS_CAS = Optimize[clusters_cas_rule];
export VARIATION = Optimize[DELETE_SK @ DELETE_K @ REPLACE_HV @ CLUSTERS_CAS];
###### VARIOUS REPLACEMENTS AND DELETIONS #######################################################################
#
#################################################################################################################
# examples: 'sagt', 'blakta'
k2x = ("+k+k".utf8 : " x".utf8) | ("+k".utf8 : " x".utf8) | ("+g+g".utf8 : " x".utf8) | ("+g".utf8 : " x".utf8);
k2x_rule = CDRewrite[k2x, common.vowel, ("+t".utf8 | "+f".utf8), sigma_star];
g2x_rule = CDRewrite["+g".utf8 : " x".utf8, common.vowel, "+s".utf8, sigma_star];
K2X_FST = Optimize[k2x_rule @ g2x_rule];
# insert 't' in words containing 'einn' ('einn', 'einnig')
einn_pattern = ("+n+n".utf8 : " t n".utf8);
einn_rule = CDRewrite[einn_pattern, common.vowels2tn, "", sigma_star];
# words like 'spánni', 'skránni' do not follow this pattern, only before EOS ('Spánn')
einn_rule_2 = CDRewrite[("+á+n+n".utf8 : "+á t n".utf8), "", "[EOS]", sigma_star];
EINN = Optimize[einn_rule @ einn_rule_2];
replace_D_rule = CDRewrite[("ð".utf8 : "t".utf8), "r" common.space*, common.space* ("l"|"n"), sigma_star];
REPLACE_D = Optimize[replace_D_rule];
replace_f = ("+f+l".utf8 : " p l".utf8) | ("+f+n".utf8 : " p n".utf8) | ("+r+f+l".utf8 : " r t l".utf8) | ("+r+f+n".utf8 : " r t n".utf8);
replace_f_rule = CDRewrite[replace_f, common.alphabet, common.plus_or_space common.vowel, sigma_star];
REPLACE_F = Optimize[replace_f_rule];
replace_g = CDRewrite[("+g".utf8 : " G".utf8), (common.vowel | ":".utf8) common.plus_or_space*, common.space* "[EOS]", sigma_star];
REPLACE_G = Optimize[replace_g];
replace_p = ("+p+p+t".utf8 : "+f+t".utf8) | ("+p+t".utf8 : "+f+t".utf8);
replace_p_rule = CDRewrite[replace_p, "", "", sigma_star];
REPLACE_P = Optimize[replace_p_rule];
#ng reduction - kringla, englar, tungna, skyggndist
ng_reduction = ("+n+g+l".utf8 : " N l".utf8) | ("+n+g+n".utf8 : " n".utf8) | (" N k s".utf8 : " N s".utf8) | ("+g+g+n+d".utf8 : " N t");
ngl_rule = CDRewrite[ng_reduction, "", "", sigma_star];
NGL = Optimize[ngl_rule];
# needs to be performed before simplifying double consonants
export REPLACEMENTS = Optimize[K2X_FST @ EINN @ REPLACE_D @ REPLACE_F @ REPLACE_G @ REPLACE_P @ NGL];
#############################################
#
# SIMPLIFY
#
#############################################
# 'll' rules: note that words pronounced with 'l' instaed of 'tl' will need to be hard-coded in a dictionary
# since the pronunciation has to do with origin of the word rather than phonetic characteristics (loan words,
# and pet names tend to be pronounced 'l' whereas the regular pronunciation is 'tl'. Example: 'villa')
double_l_1 = CDRewrite[("+l+l".utf8 : " l".utf8), "", ("+d".utf8 | "+s".utf8), sigma_star];
double_l_2 = CDRewrite[("+l+l+t".utf8 : " l_0 t".utf8), "", "", sigma_star];
double_l_3 = CDRewrite[("+l+l".utf8 : " t l".utf8), "", "", sigma_star];
export DOUBLE_L = Optimize[double_l_1 @ double_l_2 @ double_l_3 ];
simplify_double = ("+b+b".utf8 : " p".utf8) | ("+d+d".utf8 : " t".utf8)
| ("+f+f".utf8 : " f".utf8) | ("+g+g".utf8 : " k".utf8)
| ("+k+k".utf8 : " k".utf8) | ("+l+l".utf8 : " l".utf8)
| ("+m+m".utf8 : " m".utf8) | ("+n+n".utf8 : " n".utf8)
| ("+p+p".utf8 : " p".utf8) | ("+r+r".utf8 : " r".utf8)
| (common.plus_or_space "s+s".utf8 : "+s".utf8) | (common.plus_or_space "t+t".utf8 : " t".utf8);
simplify_double_rule = CDRewrite[simplify_double, "", "", sigma_star];
export SIMPLIFY_DOUBLE = Optimize[simplify_double_rule];
export SIMPLIFY = Optimize[DOUBLE_L @ SIMPLIFY_DOUBLE];
#############################################
#
# DEVOICING
#
#############################################
# necessary transitions before devoicing
rn = CDRewrite[("+r+n".utf8 : " t n".utf8), "", "", sigma_star];
RN = Optimize[rn];
# example: 'hjóla' 'hnútur' 'hrjúfur'
h_voiceless = ("+h" common.plus_or_space "j".utf8 : "C".utf8)
| ("+h+n".utf8 : " n_0".utf8)
| ("+h+r".utf8 : " r_0".utf8)
| ("+h+l".utf8 : " l_0".utf8);
h_voiceless_rule = CDRewrite[h_voiceless, "", "", sigma_star];
H_DEVOICING = Optimize[h_voiceless_rule];
pn_devoicing = CDRewrite["+f+n".utf8 : " p n_0".utf8, "", common.space* "[EOS]", sigma_star];
PN_DEVOICING = Optimize[pn_devoicing];
gn_devoicing = ("+g+n+s+t".utf8 : " N_0 s t".utf8) | (common.plus_or_space "g+n+t".utf8 : " N_0 t".utf8);
gn_devoicing_rule = CDRewrite[gn_devoicing, "", "", sigma_star];
GN_DEVOICING = Optimize[gn_devoicing_rule];
end_devoicing = ("+g+n".utf8 : " k n_0".utf8)| ("+k+n".utf8 : " k n_0".utf8) | ("+t+n".utf8 | " t n".utf8 : " t n_0".utf8);
end_devoicing_rule = CDRewrite[end_devoicing, "", (common.plus common.consonant) | "[EOS]", sigma_star];
END_DEVOICING = Optimize[end_devoicing_rule];
export DEVOICING = Optimize[RN @ H_DEVOICING @ PN_DEVOICING @ GN_DEVOICING @ END_DEVOICING];
#### FINAL STEPS ################################################################################################
#
#################################################################################################################
# need to convert those before replacing the clusters
basic_replacements = ("+i".utf8 : " I".utf8) | ("+u".utf8 : " Y".utf8) | (common.plus_or_space "n+g+s".utf8 : " N s".utf8)
| ("r r_0".utf8 : "r_0".utf8) | (" p+b".utf8 : " p".utf8) | (common.plus_or_space "k k_h".utf8 : " k_h".utf8);
basic_replacementes_rule = CDRewrite[basic_replacements, "", "", sigma_star];
export BASIC_REPLACEMENTS = Optimize[basic_replacementes_rule];
default_clusters_1 = ("r+n+s".utf8 : "r_0 s".utf8) | ("+r+n+t".utf8 : " n_0 t".utf8) | ("c+j".utf8 : "c".utf8) | ("g x".utf8 : "x".utf8);
default_clusters_1_rule = CDRewrite[default_clusters_1, "", "", sigma_star];
export BASIC_G2P_CLUSTERS_1 = Optimize[default_clusters_1_rule];
default_clusters = ("+ð+k".utf8 : " T k".utf8) | ("+f+l+t".utf8 : " l_0 t".utf8) | ("+f+n+d".utf8 : " m t")
| ("+f+n+t".utf8 : " m_0 t".utf8) | (" k+l+d".utf8 : " l t".utf8) | ("+g+l+d".utf8 : " l t".utf8)
| ("+g+g+t".utf8 : " x t".utf8)
| ("+g+l+t".utf8 : " l_0 t") | ("+g+n+d".utf8 : " N t".utf8) | ("+g+g+n+s+t".utf8 : " N_0 s t".utf8)
| ("+l+t".utf8 : " l_0 t".utf8)
| ("+l+k+t".utf8 : " l_0 t".utf8) | ("+l+f+d".utf8 : " l t".utf8) | ("+l+f+t".utf8 : " l_0 t".utf8)
| ("+l+g+d".utf8 : " l t".utf8) | ("+l+g+t".utf8 : " l_0 t".utf8) | ("+l+g+n".utf8 : " l n".utf8)
| ("+l+k".utf8 : " l_0 k".utf8) | ("+l c".utf8 : " l_0 c".utf8) | ("+l+p".utf8 : " l_0 p".utf8)
| (common.plus_or_space "l+t".utf8 : " l_0 t".utf8)
| ("+m+b+d".utf8 : " m t".utf8) | ("+m+b+s".utf8 : " m s".utf8) | ("+m+p".utf8 : " m_0 p".utf8)
| ("+m+k".utf8 : " m_0 k".utf8) | (("m+t".utf8 | "m+b+t".utf8) : "m_0 t".utf8) | ("+n+g+d".utf8 : " N t".utf8)
| ("+n+g+t".utf8 : " N_0 t".utf8) | ("+n+k+t".utf8 : " n_0 t".utf8)
| ("+n+k".utf8 : " n_0 k".utf8) | ("+r+f+t".utf8 : " r_0 t".utf8) | ("+r+p+t".utf8 : " r_0 t".utf8)
| ("+n+t".utf8 : " n_0 t".utf8) | ("+ey".utf8 : " ei".utf8) | ("+r+f+ð".utf8 : " r D".utf8)
| ("+r+k+t".utf8 : " r_0 t".utf8) | ("+r+l".utf8 : " r t l".utf8)
| ("+r+g+ð".utf8 : " r D".utf8) | ("+r+g+n".utf8 : " r t n".utf8) | ("+r+g+t".utf8 : " r_0 t".utf8)
| ("+r+s+l".utf8 common.plus_or_space : " s t l ".utf8) | ("s+t+k".utf8 : "s k".utf8)
| (common.plus_or_space "s+l".utf8 common.plus_or_space : " s t l+".utf8) | ("s+n".utf8 : "s t n".utf8) | ("+t+n+s".utf8 : " s".utf8)
| (" h t n_0+s".utf8 : " s".utf8)
| ("+æ+t+l".utf8 : " ai h t l".utf8) | ("+r+k".utf8 : " r_0 k".utf8) | ("+r+s".utf8 : " r_0 s".utf8)
| ("+r+t".utf8 : " r_0 t".utf8) | ("+r+p".utf8 : " r_0 p".utf8) | ("+r+ð+n".utf8 : " r t n".utf8);
default_clusters_rule = CDRewrite[default_clusters, "", "", sigma_star];
export BASIC_G2P_CLUSTERS = Optimize[default_clusters_rule];
default_g2p =
("+b".utf8 : " p".utf8)
| ("+d".utf8 : " t".utf8)
| ("+ð".utf8 : " D")
| ("+ei".utf8 : " ei".utf8)
| ("+e".utf8 : " E".utf8)
| ("+é".utf8 : " j E".utf8)
| ("+y".utf8 : " I".utf8)
| ("+í".utf8 : " i".utf8)
| ("+ý".utf8 : " i".utf8)
| ("+g".utf8 : " k".utf8)
| ("+o".utf8 : " O".utf8)
| ("+ó".utf8 : " ou".utf8)
| ("+ú".utf8 : " u".utf8)
| ("+þ".utf8 : " T".utf8)
| ("+æ".utf8 : " ai".utf8)
| (common.plus_or_space "ö".utf8 : " 9".utf8)
| (common.plus_or_space "á".utf8 : " au".utf8)
| ("+au".utf8 : " 9i".utf8)
| ("+t+h".utf8 : "+t_h".utf8);
default_g2p_rule = CDRewrite[default_g2p, "", "", sigma_star];
export BASIC_G2P = Optimize[default_g2p_rule];
delete_plus_symbol = CDRewrite["+".utf8 : " ", "", "", sigma_star];
DELETE_PLUS = Optimize[delete_plus_symbol];
export STEP_1 = Optimize[ALIGN_GRAPHEMES];
export STEP_2 = Optimize[X_KS_FST @ VOWEL_GI_FST @ NG_NK @ LONG_VOWELS @ VARIATION @ REPLACEMENTS @ ASPIRATION @ FRONT @ SOFTEN];
export STEP_3 = Optimize[SIMPLIFY @ DEVOICING];
export STEP_4 = Optimize[BASIC_REPLACEMENTS @ BASIC_G2P_CLUSTERS_1 @ BASIC_G2P_CLUSTERS @ BASIC_G2P @ DELETE_PLUS];
export G2P = Optimize[STEP_1 @ STEP_2 @ STEP_3 @ STEP_4];