-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenfeatures.py
49 lines (38 loc) · 1.06 KB
/
genfeatures.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
digit_to_glyph = {
'0': 'zero',
'1': 'one',
'2': 'two',
'3': 'three',
'4': 'four',
'5': 'five',
'6': 'six',
'7': 'seven',
'8': 'eight',
'9': 'nine',
'T': 'T',
'E': 'E'
}
def base10_to_base12digit(base10):
if base10 == '10':
return 'T'
if base10 == '11':
return 'E'
return str(base10)
def digitstring_to_glyphstring(digits):
return ' '.join(digit_to_glyph[d] for d in digits)
print('@digit = [zero one two three four five six seven eight nine];')
for glyph in digit_to_glyph.values():
print(f'lookup to_{glyph} {{ substitute @digit by {glyph}; }} to_{glyph};')
print('''
feature calt {
''')
for n10 in range(10, 100):
s10 = str(n10)
msd10 = digit_to_glyph[s10[0]]
lsd10 = digit_to_glyph[s10[1]]
msd12 = digit_to_glyph[base10_to_base12digit(str(n10 // 12))]
lsd12 = digit_to_glyph[base10_to_base12digit(str(n10 % 12))]
print(f" substitute {msd10}' lookup to_{msd12} {lsd10}' lookup to_{lsd12} ;")
print('''
} calt;
''')