-
Notifications
You must be signed in to change notification settings - Fork 0
/
futhark.py
executable file
·190 lines (175 loc) · 3.74 KB
/
futhark.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
#!/usr/bin/env python3
"""
Transliterate between the latin alphabet and some runic alphabets (futharks)
and the latin alphabet. Currently, the following futharcs are supported:
- anglo-saxon
- elder futharc
- younger futharc
- long-branch
- short twig
Sources:
https://en.wikipedia.org/wiki/Runic_(Unicode_block)
https://en.wikipedia.org/wiki/Medieval_runes
https://en.wikipedia.org/wiki/Runes
https://sv.wikipedia.org/wiki/Runor
"""
midevial = {
'a': 'ᛆ',
'b': 'ᛒ',
'c': 'ᛍ',
'd': 'ᛑ',
'Ð': 'ᚧ',
'e': 'ᛂ',
'f': 'ᚠ',
'g': 'ᚵ',
'h': 'ᚼ',
'i': 'ᛁ',
'k': 'ᚴ',
'l': 'ᛚ',
'm': 'ᛘ',
'n': 'ᚿ',
'o': 'ᚮ',
'p': 'ᛔ', # (ᛕ)
'q': 'ᛩ',
'r': 'ᚱ',
's': 'ᛋ', # or ᛌ
't': 'ᛐ',
'u': 'ᚢ',
'v': 'ᚡ', # (ᚢ)
'w': 'ᚥ',
'x': 'ᛪ',
'y': 'ᛦ', # (ᚤ ᛨ)
'z': 'ᛎ',
'Þ': 'ᚦ',
'ä': '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ᚭ',
'r': 'ᚱ',
'k': 'ᚴ',
'h': 'ᚽ',
'n': 'ᚾ',
'i': 'ᛁ',
'a': 'ᚽ',
's': 'ᛌ',
't': 'ᛐ',
'b': 'ᛓ',
'm': 'ᛙ',
'l': 'ᛚ',
'r': 'ᛧ'
}
def to_runes(futhark, text):
''' transliterate alphabet to runes '''
text = text.lower()
for k, v in futhark.items():
text = text.replace(k, v)
return text
def to_text(futhark, text):
''' transliterate runes to alphabet '''
text = text.lower()
for k, v in futhark.items():
text = text.replace(v, k)
return text
def main():
text = input('Enter text: ')
print('\nText to runes')
print('-------------')
print('Elder futhark: ' + to_runes(elder_futhark, text))
print('Anglo-Saxon: ' + to_runes(anglo_saxon, text))
print('Younger futhark long-branch: ' + to_runes(younger_futhark_lb , text))
print('Younger futhark short-twig: ' + to_runes(younger_futhark_st, text))
print('Midevial: ' + to_runes(midevial, text))
print('\nRunes to text')
print('-------------')
print('Elder futhark: ' + to_text(elder_futhark, text))
print('Anglo-Saxon: ' + to_text(anglo_saxon, text))
print('Younger futhark long-branch: ' + to_text(younger_futhark_lb , text))
print('Younger futhark short-twig: ' + to_text(younger_futhark_st, text))
print('Midevial: ' + to_text(midevial, text))
if __name__ == '__main__':
main()