-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLatinToOSL.py
More file actions
65 lines (62 loc) · 1.26 KB
/
Copy pathLatinToOSL.py
File metadata and controls
65 lines (62 loc) · 1.26 KB
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
def latinToOSL(word, mapping):
word = word.lower()
OSL_word = ''
i = 0
while i < len(word):
if word[i].isdigit():
if i < len(word) - 1 and (word[i+1].isdigit() or word[i+1] == ' '):
OSL_word += word[i]
i += 1
else:
OSL_word += mapping[word[i]]
i += 1
if word[i:i+2] == 'ch':
OSL_word += mapping['ch']
i += 2
elif word[i:i+2] == 'gh':
OSL_word += mapping['gh']
i += 2
elif word[i] in mapping:
OSL_word += mapping[word[i]]
i += 1
else:
OSL_word += word[i]
i += 1
return OSL_word
mapping = {
'a': 'A',
'b': 'b',
't': 't',
#'T': 'T',
'j': 'j',
'7': 'H',
'5': 'X',
'd': 'd',
'r': 'r',
'z': 'z',
's': 's',
'ch': '$',
#'sh': 'X',
#'S': 'S',
#'D': 'D',
#'T': 'T',
#'D': 'D',
'3': 'E',
'gh': 'G',
'f': 'f',
'q': 'q',
'l': 'l',
'm': 'm',
'n': 'n',
'h': 'h',
'w': 'w',
'y': 'y',
'2': '^',
'a': 'a',
'o': 'o',
'i': 'i',
}
latin_word = 'bghito ndiro ftor m3a al3a2ila'
#bGiyto ndiyro fTowr mEa AlEaA^ila
OSL_word = latinToOSL(latin_word, mapping)
print(OSL_word)