-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathtranslate.py
195 lines (157 loc) · 4.53 KB
/
translate.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
import unicodedata
from utils import match_case
mc = match_case
digits = {
"0": "Zero",
"1": "One",
"2": "Two",
"3": "Three",
"4": "Four",
"5": "Five",
"6": "Six",
"7": "Seven",
"8": "Eight",
"9": "Nine",
}
def uwu(s):
"""Sources:
https://github.com/QuazzyWazzy/UwU-fy
https://github.com/mackyclemen/uwu-cpp
https://github.com/mackyclemen/uwu-android
"""
# Rs & Ls to Ws
tmp = ""
for i, c in enumerate(s):
if c.lower() in ["r", "l"]:
c = mc("w", c)
tmp += c
s = tmp
# Japanize?
trans = [
[["wove"], "wuv"],
[["wewcome"], "youkoso"],
[["is that so"], "naruhodo"],
[["that's why", "thats why"], "dakara"],
[["what"], "nani"],
[["when"], "itsu"],
[["the"], "za"],
[["wowwd"], "warudo"],
[["good morning"], "ohayou"],
[["good aftewnoon"], "konnichiwa"],
[["good night"], "oyasumi"],
[["thank you", "thanks", "tnx", "ty"], "arigatou"],
[["bye bye", "bye", "goodbye"], "sayonara"],
[["sowwy", "apowogies"], "gomenasai"],
[["my bad"], "warukatta"],
[["excuse me"], "sumimasen"],
[["wife"], "waifu"],
[["husband"], "hasubando"],
[["cute"], "kawaii"],
[["nice"], "suteki"],
[["bad"], "warui"],
[["coow"], "sugoi"],
[["handsome"], "kakkoi"],
[["idiot"], "baka"],
[["dumb", "dumbass"], "aho"],
[["undewstand"], "wakarimasu"],
[["undewstood"], "wakatta"],
[["dead"], "deddo"],
[["shut up", "shut the fuck up", "stfu", "shutup", "shattap"], "urusai"],
[["fuck"], "fack"],
[["fucked"], "facked"],
[["fucking"], "facking"],
[["this is bad", "oh no", "that's bad", "thats bad"], "yabai"],
[["name"], "namae"],
[["sistew"], "oneesan"],
[["bwothew"], "oniichan"],
[["wittwe sistew"], "imouto"],
[["wittwe bwothew"], "otouto"],
[["fwiends"], "fwends"],
[["fwiend"], "fwend"],
[["awwy", "awwies", "comnrade", "comrades"], "nakama"],
[["enemy", "enemies", "nemesis"], "teki"],
[["see you", "see ya"], "mata ne"],
[["good wuck", "goodwuck", "do your best", "you got this"], "ganbatte"],
[["dog"], "inu"],
[["cat"], "neko"],
[["with"], "wid"],
[["without"], "widout"],
]
trans_d = {}
for t in trans:
for w in t[0]:
trans_d[w] = t[1]
s = " ".join([mc(trans_d[w.lower()], w) if w.lower() in trans_d else w for w in s.split(" ")])
replacements = {
"no": "nyo",
"mo": "myo",
"No": "Nyo",
"Mo": "Myo",
"NO": "NYO",
"MO": "MYO",
"hu": "hoo",
"Hu": "Hoo",
"HU": "HOO",
"th": "d",
"Th": "D",
"TH": "D",
}
for r, rv in replacements.items():
s = s.replace(r, rv)
return s
def small_caps(s):
new_s = ""
for c in s:
if c.islower():
try:
new_s += unicodedata.lookup("LATIN LETTER SMALL CAPITAL " + c)
except KeyError:
new_s += c
else:
new_s += c
return new_s
def mathematical_unicode(mode, s):
new_s = ""
for c in s:
nc = c
case = "Capital"
if c.islower():
case = "Small"
try:
int(c)
except ValueError:
pass
else:
case = "Digit"
nc = digits[c]
try:
new_s += unicodedata.lookup("Mathematical {} {} {}".format(mode, case, nc))
except KeyError:
new_s += c
return new_s
def bold(s):
return mathematical_unicode("Bold", s)
def italic(s):
return mathematical_unicode("Italic", s)
def bolditalic(s):
return mathematical_unicode("Bold Italic", s)
def script(s):
return mathematical_unicode("Script", s)
def boldscript(s):
return mathematical_unicode("Bold Script", s)
def fraktur(s):
return mathematical_unicode("Fraktur", s)
def boldfraktur(s):
return mathematical_unicode("Bold Fraktur", s)
def double(s):
return mathematical_unicode("Double-Struck", s)
def sans(s):
return mathematical_unicode("Sans-Serif", s)
def boldsans(s):
return mathematical_unicode("Sans-Serif Bold", s)
def italicsans(s):
return mathematical_unicode("Sans-Serif Italic", s)
def bolditalicsans(s):
return mathematical_unicode("Sans-Serif Bold Italic", s)
def mono(s):
return mathematical_unicode("Monospace", s)