-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtranslates.py
43 lines (37 loc) · 1.07 KB
/
translates.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
import re #正則運算函式 (Regular Expression)
def trans(word): # 重複搜尋
text = word
dic = {
"做得很好,你呢?":"我很好,你呢?",
"主席先生":"先生"
}
for key in dic.keys(): # 讀取字典內的字
text = re.sub(key, dic[key], text)
return text # 傳回修改後的
def trans_e(word): # 重複搜尋
text = word
dic = {
'Mathematics':'math',
}
for key in dic.keys(): # 讀取字典內的字
text = re.sub(key, dic[key], text)
return text # 傳回修改後的
def googletrans(word):
text = word
dic = {
"Chinese ":"zh-TW",
"Japanese":"ja",
"Korean":"ko",
"English ":"en",
}
for key in dic.keys(): # 讀取字典內的字
text = re.sub(key, dic[key], text)
return text # 傳回修改後的
def translate(word):
text = word
dic = {
"chinese":"chinese (traditional)",
}
for key in dic.keys(): # 讀取字典內的字
text = re.sub(key, dic[key], text)
return text # 傳回修改後的