Spaces:
Sleeping
Sleeping
first
Browse files- .gitattributes +1 -0
- config.json +30 -0
- gk_episode_text.json +3 -0
- gradio_ET.py +607 -0
- name.txt +563 -0
- replace.txt +161 -0
- themes.py +54 -0
- utils.py +153 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
gk_episode_text.json filter=lfs diff=lfs merge=lfs -text
|
config.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"moyu_mode": "0",
|
3 |
+
"if_save_id_immediately": "1",
|
4 |
+
"last_edited_id": "1078008122",
|
5 |
+
"target_id": "1077001001",
|
6 |
+
"context_half_length": "100",
|
7 |
+
"file_path": "./gk_episode_text.json",
|
8 |
+
"name_dict_path": "./name.txt",
|
9 |
+
"replace_dict_path": "./replace.txt",
|
10 |
+
"output_txt_path": "./output.txt",
|
11 |
+
"seperator_long": "===============================",
|
12 |
+
"seperator_short": "---------------------",
|
13 |
+
"csv_column_name": {
|
14 |
+
"id": "",
|
15 |
+
"text": "text",
|
16 |
+
"name": "name"
|
17 |
+
},
|
18 |
+
"baidu_api_settings": {
|
19 |
+
"api_id": "20230508001670853",
|
20 |
+
"api_key": "9jyHXPkZlCoVVYtIKgUK",
|
21 |
+
"from_lang": "jp",
|
22 |
+
"to_lang": "zh"
|
23 |
+
},
|
24 |
+
"openai_api_settings": {
|
25 |
+
"openai_api_key": "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",
|
26 |
+
"prompt_prefix": "翻译为中文:",
|
27 |
+
"prompt_postfix": "",
|
28 |
+
"time_limit": "12"
|
29 |
+
}
|
30 |
+
}
|
gk_episode_text.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:229353ea02673a69f39819b7dea3156d475c89afa44a086f193d8197724ee7d8
|
3 |
+
size 71210113
|
gradio_ET.py
ADDED
@@ -0,0 +1,607 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from os import path as osp
|
3 |
+
import json
|
4 |
+
from utils import *
|
5 |
+
from themes import *
|
6 |
+
|
7 |
+
# Initialization
|
8 |
+
# id指代台词的编号,为一个字符串
|
9 |
+
# idx指代顺序排列的序号,0,1,2,...
|
10 |
+
config_path = osp.join(osp.dirname(osp.abspath(__file__)),"./config.json")
|
11 |
+
args = load_config(config_path)
|
12 |
+
if_save_id_immediately = True if int(args["if_save_id_immediately"]) else False
|
13 |
+
moyu_mode = True if int(args["moyu_mode"]) else False
|
14 |
+
path = args["file_path"]
|
15 |
+
abs_path = smart_path(path)
|
16 |
+
replace_dict_path = smart_path(args["replace_dict_path"])
|
17 |
+
name_dict_path = smart_path(args["name_dict_path"])
|
18 |
+
altered_text_finals= set()
|
19 |
+
|
20 |
+
|
21 |
+
if osp.exists(abs_path):
|
22 |
+
with open(abs_path, "r", encoding ="utf8") as json_file:
|
23 |
+
dic = json.load(json_file)
|
24 |
+
id_lis = list(dic.keys())
|
25 |
+
idx_dic = dict()
|
26 |
+
for idx,id_ in enumerate(id_lis):
|
27 |
+
idx_dic[id_] = idx
|
28 |
+
id_idx = 0
|
29 |
+
if args["last_edited_id"] in id_lis:
|
30 |
+
id_idx = idx_dic[args["last_edited_id"]]
|
31 |
+
|
32 |
+
# Dict for replacement
|
33 |
+
replace_dic = {}
|
34 |
+
if osp.exists(replace_dict_path):
|
35 |
+
with open(replace_dict_path, "r", encoding="utf-8") as f:
|
36 |
+
for line in f:
|
37 |
+
if not line:continue
|
38 |
+
item = line.split(" ")
|
39 |
+
item[1] = item[1].replace("\n","")
|
40 |
+
replace_dic[item[0]]=item[1]
|
41 |
+
f.close()
|
42 |
+
|
43 |
+
# Dict for name
|
44 |
+
name_dic = {}
|
45 |
+
if osp.exists(name_dict_path):
|
46 |
+
with open(name_dict_path, "r", encoding="utf-8") as f:
|
47 |
+
for line in f:
|
48 |
+
if not line:continue
|
49 |
+
item = line.split(" ")
|
50 |
+
item[1] = item[1].replace("\n","")
|
51 |
+
name_dic[item[0]]=item[1]
|
52 |
+
|
53 |
+
# Translate
|
54 |
+
def gpt_translate(text,text_id):
|
55 |
+
text = text.replace("\n"," ")
|
56 |
+
prompt = args["openai_api_settings"]["prompt_prefix"]+text+args["openai_api_settings"]["prompt_postfix"]
|
57 |
+
translation, if_succ = get_gpt_completion(prompt, api_key = args["openai_api_settings"]["openai_api_key"])
|
58 |
+
if dic[text_id]["text"].replace("\n"," ") == text and if_succ:
|
59 |
+
dic[text_id]["gpt3"] = translation
|
60 |
+
return translation
|
61 |
+
|
62 |
+
def baidu_translate(text,text_id):
|
63 |
+
text = text.replace("\n"," ")
|
64 |
+
translation = get_baidu_completion(text,
|
65 |
+
api_id = args["baidu_api_settings"]["api_id"],
|
66 |
+
api_key = args["baidu_api_settings"]["api_key"],
|
67 |
+
from_lang=args["baidu_api_settings"]["from_lang"],
|
68 |
+
to_lang=args["baidu_api_settings"]["to_lang"],)
|
69 |
+
if dic[text_id]["text"].replace("\n"," ") == text:
|
70 |
+
dic[text_id]["baidu"] = translation
|
71 |
+
return translation
|
72 |
+
|
73 |
+
def batch_translate(radio, check, text_start_id,text_end_id,progress=gr.Progress()):
|
74 |
+
progress(0, desc="Starting...")
|
75 |
+
if text_start_id not in id_lis or text_end_id not in id_lis or idx_dic[text_start_id] > idx_dic[text_end_id]:
|
76 |
+
gr.Warning("找不到指定序号, 或id前后顺序错误")
|
77 |
+
return
|
78 |
+
start = idx_dic[text_start_id]
|
79 |
+
end = idx_dic[text_end_id] + 1
|
80 |
+
lis = id_lis[start:end]
|
81 |
+
if radio == "Gpt3":
|
82 |
+
for key in progress.tqdm(lis):
|
83 |
+
gpt_translate(dic[key]['text'],key)
|
84 |
+
time.sleep(0.1)
|
85 |
+
if radio == 'Baidu':
|
86 |
+
for key in progress.tqdm(lis):
|
87 |
+
baidu_translate(dic[key]['text'],key)
|
88 |
+
time.sleep(0.1)
|
89 |
+
if check:
|
90 |
+
save_json(show_info=False)
|
91 |
+
gr.Info(f"批量机翻成功, 共完成{end-start}句翻译")
|
92 |
+
return f"已完成{end-start}句翻译"
|
93 |
+
|
94 |
+
# Other actions
|
95 |
+
def last_text():
|
96 |
+
global id_idx
|
97 |
+
if id_idx > 0:
|
98 |
+
id_idx -= 1
|
99 |
+
return id_lis[id_idx]
|
100 |
+
|
101 |
+
def next_text():
|
102 |
+
global id_idx
|
103 |
+
if id_idx < len(id_lis)-1:
|
104 |
+
id_idx += 1
|
105 |
+
return id_lis[id_idx]
|
106 |
+
|
107 |
+
def replace(text_gpt,text_baidu,text_final,text_id, check_file = True):
|
108 |
+
if not text_id:
|
109 |
+
text_id = id_lis[id_idx]
|
110 |
+
if check_file:
|
111 |
+
if osp.exists(replace_dict_path):
|
112 |
+
with open(replace_dict_path, "r", encoding="utf-8") as f:
|
113 |
+
for line in f:
|
114 |
+
item = line.split(" ")
|
115 |
+
item[1] = item[1].replace("\n","")
|
116 |
+
replace_dic[item[0]]=item[1]
|
117 |
+
f.close()
|
118 |
+
for key,value in replace_dic.items():
|
119 |
+
text_gpt = text_gpt.replace(key, value)
|
120 |
+
text_baidu = text_baidu.replace(key, value)
|
121 |
+
text_final = text_final.replace(key, value)
|
122 |
+
dic[text_id]["gpt3"] = text_gpt
|
123 |
+
dic[text_id]["baidu"] = text_baidu
|
124 |
+
dic[text_id]["text_CN"] = text_final
|
125 |
+
return text_gpt,text_baidu,text_final
|
126 |
+
|
127 |
+
def change_id(text_id):
|
128 |
+
if not text_id or text_id not in idx_dic: return args["file_path"],"","","","","",""
|
129 |
+
global id_idx
|
130 |
+
id_idx = idx_dic[text_id]
|
131 |
+
if "gpt3" not in dic[text_id]:
|
132 |
+
dic[text_id]["gpt3"] = ""
|
133 |
+
if "baidu" not in dic[text_id]:
|
134 |
+
dic[text_id]["baidu"] = ""
|
135 |
+
if "text_CN" not in dic[text_id]:
|
136 |
+
dic[text_id]["text_CN"] = ""
|
137 |
+
if dic[text_id]["name"] not in name_dic:
|
138 |
+
name_dic[dic[text_id]["name"]] = dic[text_id]["name"]
|
139 |
+
dic[text_id]["name_CN"] = name_dic[dic[text_id]["name"]]
|
140 |
+
replace(dic[text_id]["gpt3"],dic[text_id]["baidu"],dic[text_id]["text_CN"],text_id,False)
|
141 |
+
if if_save_id_immediately:
|
142 |
+
args["last_edited_id"] = text_id
|
143 |
+
save_config(args,config_path)
|
144 |
+
return args["file_path"],dic[text_id]["text"],dic[text_id]["name"],name_dic[dic[text_id]["name"]],\
|
145 |
+
dic[text_id]["gpt3"],dic[text_id]["baidu"],dic[text_id]["text_CN"]
|
146 |
+
|
147 |
+
def change_final(text,text_id):
|
148 |
+
if not text_id or not text_id in idx_dic: return
|
149 |
+
if text != dic[text_id]["text_CN"]:
|
150 |
+
dic[text_id]["text_CN"] = text
|
151 |
+
altered_text_finals.add(text_id)
|
152 |
+
return
|
153 |
+
|
154 |
+
def change_name(name,name_cn,text_id):
|
155 |
+
if not text_id or not text_id in idx_dic: return
|
156 |
+
name_dic[name] = name_cn
|
157 |
+
dic[text_id]["name_CN"] = name_cn
|
158 |
+
return
|
159 |
+
|
160 |
+
def save_json(show_info = True):
|
161 |
+
global altered_text_finals
|
162 |
+
with open(abs_path, "w", encoding ="utf8") as json_file:
|
163 |
+
json.dump(dic,json_file,indent = 1,ensure_ascii = False)
|
164 |
+
if osp.exists(name_dict_path):
|
165 |
+
with open(name_dict_path,"w",encoding = "utf-8") as f:
|
166 |
+
for key,value in name_dic.items():
|
167 |
+
f.write(f"{key} {value}\n")
|
168 |
+
if show_info:
|
169 |
+
gr.Info(f"JSON保存成功, 共更新{len(altered_text_finals)}句译文")
|
170 |
+
altered_text_finals = set()
|
171 |
+
|
172 |
+
def save_last_position(text_id):
|
173 |
+
args["last_edited_id"] = text_id
|
174 |
+
save_config(args,config_path)
|
175 |
+
return
|
176 |
+
|
177 |
+
def load_last_position(text_path):
|
178 |
+
global id_idx,id_lis,idx_dic,path,dic
|
179 |
+
if not osp.exists(smart_path(text_path)):
|
180 |
+
raise gr.Error("文件不存在")
|
181 |
+
if path != text_path:
|
182 |
+
path = text_path
|
183 |
+
with open(smart_path(text_path), "r", encoding ="utf8") as json_file:
|
184 |
+
dic = json.load(json_file)
|
185 |
+
id_lis = list(dic.keys())
|
186 |
+
idx_dic = dict()
|
187 |
+
for idx,id_ in enumerate(id_lis):
|
188 |
+
idx_dic[id_] = idx
|
189 |
+
id_idx = 0
|
190 |
+
args["file_path"] = path
|
191 |
+
save_config(args,config_path)
|
192 |
+
return args["last_edited_id"]
|
193 |
+
|
194 |
+
def submit_api(baidu_api_id, baidu_api_key, from_lang, to_lang, openai_api_key,prefix,postfix,target_id):
|
195 |
+
global args
|
196 |
+
if baidu_api_id != "":
|
197 |
+
args["baidu_api_settings"]["api_id"] = baidu_api_id
|
198 |
+
if baidu_api_key != "":
|
199 |
+
args["baidu_api_settings"]["api_key"] = baidu_api_key
|
200 |
+
if from_lang != "":
|
201 |
+
args["baidu_api_settings"]["from_lang"] = from_lang
|
202 |
+
if to_lang != "":
|
203 |
+
args["baidu_api_settings"]["to_lang"] = to_lang
|
204 |
+
if openai_api_key != "":
|
205 |
+
args["openai_api_settings"]["openai_api_key"] = openai_api_key
|
206 |
+
args["openai_api_settings"]["prompt_prefix"] = prefix
|
207 |
+
args["openai_api_settings"]["prompt_postfix"] = postfix
|
208 |
+
args["target_id"] = target_id
|
209 |
+
save_config(args,config_path)
|
210 |
+
return
|
211 |
+
|
212 |
+
def refresh_context(refresh_id,length,context_type):
|
213 |
+
if not refresh_id or not refresh_id in idx_dic: return [],id_lis[id_idx]
|
214 |
+
length = int(length)
|
215 |
+
idx = idx_dic[refresh_id]
|
216 |
+
if context_type == "上下文":
|
217 |
+
ids = id_lis[max(idx-length, 0):idx+length+1]
|
218 |
+
elif context_type == "上文":
|
219 |
+
ids = id_lis[max(idx-length, 0):idx+1]
|
220 |
+
elif context_type == "下文":
|
221 |
+
ids = id_lis[idx:idx+length+1]
|
222 |
+
data = []
|
223 |
+
for i in ids:
|
224 |
+
if dic[i]["name"] not in name_dic:
|
225 |
+
name_dic[dic[i]["name"]] = dic[i]["name"]
|
226 |
+
dic[i]["name_CN"] = name_dic[dic[i]["name"]]
|
227 |
+
if 'text_CN' not in dic[i]:
|
228 |
+
dic[i]['text_CN'] = ""
|
229 |
+
row = [i, dic[i]['name'],dic[i]['name_CN'], dic[i]['text'],dic[i]['text_CN']]
|
230 |
+
if i == id_lis[idx]: row[0] = f"**{i}**"
|
231 |
+
if i in altered_text_finals:
|
232 |
+
row[4] = f"*{row[4]}"
|
233 |
+
data.append(row)
|
234 |
+
return data,id_lis[id_idx]
|
235 |
+
|
236 |
+
def save_context(data, refresh_id, if_save = False):
|
237 |
+
altered = 0
|
238 |
+
for i in range(len(data)):
|
239 |
+
text_id = data['id'][i]
|
240 |
+
text_cn = data['text_CN'][i]
|
241 |
+
text_id = text_id.replace("*","")
|
242 |
+
if text_id in altered_text_finals and text_cn and text_cn[0] == "*":
|
243 |
+
text_cn = text_cn[1:]
|
244 |
+
if dic[text_id]['text_CN'] != text_cn:
|
245 |
+
altered += 1
|
246 |
+
altered_text_finals.add(text_id)
|
247 |
+
dic[text_id]['text_CN'] = text_cn
|
248 |
+
gr.Info(f"已修改{altered}条译文")
|
249 |
+
if if_save:
|
250 |
+
save_json()
|
251 |
+
return
|
252 |
+
|
253 |
+
# Derive text
|
254 |
+
def derive_text(radio_type, text_start_id, text_end_id,text_seperator_long,text_seperator_short, output_txt_path):
|
255 |
+
output_txt_path = smart_path(output_txt_path)
|
256 |
+
if output_txt_path[-4:] != ".txt":
|
257 |
+
gr.Warning("输出路径错误")
|
258 |
+
return
|
259 |
+
if text_start_id not in id_lis or text_end_id not in id_lis or idx_dic[text_start_id] > idx_dic[text_end_id]:
|
260 |
+
gr.Warning("找不到指定序号, 或id前后顺序错误")
|
261 |
+
return
|
262 |
+
start = idx_dic[text_start_id]
|
263 |
+
end = idx_dic[text_end_id] + 1
|
264 |
+
lis = id_lis[start:end]
|
265 |
+
if radio_type == "双语|人名文本":
|
266 |
+
with open(output_txt_path,"w",encoding="utf-8") as f:
|
267 |
+
for key in lis:
|
268 |
+
# if key[-3:] == "001":
|
269 |
+
# f.write("【"+key[-4]+"】\n")
|
270 |
+
f.write(text_seperator_long+"\n")
|
271 |
+
f.write(dic[key]["name"]+"\n")
|
272 |
+
f.write("\n")
|
273 |
+
f.write(dic[key]["text"]+"\n")
|
274 |
+
f.write("\n")
|
275 |
+
f.write(text_seperator_short+"\n")
|
276 |
+
f.write(dic[key]["name_CN"]+"\n\n")
|
277 |
+
f.write(dic[key]["text_CN"]+"\n")
|
278 |
+
f.write("\n")
|
279 |
+
return
|
280 |
+
if radio_type == "中文|人名文本":
|
281 |
+
with open(output_txt_path,"w",encoding="utf-8") as f:
|
282 |
+
for key in lis:
|
283 |
+
# if key[-3:] == "001":
|
284 |
+
# f.write("【"+key[-4]+"】\n")
|
285 |
+
f.write(text_seperator_long+"\n")
|
286 |
+
f.write(dic[key]["name_CN"]+"\n\n")
|
287 |
+
f.write(dic[key]["text_CN"]+"\n")
|
288 |
+
f.write("\n")
|
289 |
+
return
|
290 |
+
if radio_type == "中文|单次人名文本":
|
291 |
+
with open(output_txt_path,"w",encoding="utf-8") as f:
|
292 |
+
name_lis = []
|
293 |
+
for key in lis:
|
294 |
+
name = dic[key]["name_CN"]
|
295 |
+
if name not in name_lis:
|
296 |
+
name_lis.append(name)
|
297 |
+
f.write(name + ": "+ dic[key]["text_CN"]+"\n")
|
298 |
+
else:
|
299 |
+
f.write(dic[key]["text_CN"]+"\n")
|
300 |
+
f.write("\n")
|
301 |
+
if radio_type == "中文|纯文本":
|
302 |
+
with open(output_txt_path,"w",encoding="utf-8") as f:
|
303 |
+
for key in lis:
|
304 |
+
f.write(dic[key]["text_CN"]+"\n")
|
305 |
+
f.write("\n")
|
306 |
+
gr.Info(f"Txt导出成功, 共导出{len(lis)}条记录")
|
307 |
+
|
308 |
+
def get_remaining_text_num():
|
309 |
+
if args["target_id"] in id_lis:
|
310 |
+
target_idx= idx_dic[args["target_id"]]
|
311 |
+
rem = target_idx - id_idx
|
312 |
+
label = f"目标剩余{rem}条"
|
313 |
+
else:
|
314 |
+
label = "目标剩余???条"
|
315 |
+
return label
|
316 |
+
|
317 |
+
def merge_json(merged_path,file_merging_json,text_start_id,text_end_id,type):
|
318 |
+
merged_path = smart_path(merged_path)
|
319 |
+
if not osp.exists(merged_path):
|
320 |
+
gr.Warning("路径不存在")
|
321 |
+
return
|
322 |
+
with open(merged_path, "r", encoding ="utf8") as json_file:
|
323 |
+
dic_merge = json.load(json_file)
|
324 |
+
id_lis_merge = list(dic_merge.keys())
|
325 |
+
idx_dic_merge = dict()
|
326 |
+
for idx,id_ in enumerate(id_lis_merge):
|
327 |
+
idx_dic_merge[id_] = idx
|
328 |
+
if text_start_id not in id_lis_merge or text_end_id not in id_lis_merge or idx_dic_merge[text_start_id] > idx_dic_merge[text_end_id]:
|
329 |
+
gr.Warning("找不到指定序号, 或id前后顺序错误")
|
330 |
+
return
|
331 |
+
path = file_merging_json.name
|
332 |
+
with open(path, "r", encoding ="utf8") as json_file:
|
333 |
+
dic_new = json.load(json_file)
|
334 |
+
for idx in range(idx_dic_merge[text_start_id],idx_dic_merge[text_end_id] + 1):
|
335 |
+
if type == "仅人工翻译":
|
336 |
+
dic_merge[id_lis_merge[idx]]['text_CN'] = dic_new[id_lis_merge[idx]]['text_CN']
|
337 |
+
else:
|
338 |
+
dic_merge[id_lis_merge[idx]] = dic_new[id_lis_merge[idx]]
|
339 |
+
with open(merged_path, "w", encoding ="utf8") as json_file:
|
340 |
+
json.dump(dic_merge,json_file,indent = 1,ensure_ascii = False)
|
341 |
+
gr.Info(f"合并成功,共更新{idx_dic_merge[text_end_id] - idx_dic_merge[text_start_id] + 1}条译文")
|
342 |
+
return
|
343 |
+
|
344 |
+
def output_json(merged_path,text_start_id,text_end_id):
|
345 |
+
merged_path = smart_path(merged_path)
|
346 |
+
if not osp.exists(merged_path):
|
347 |
+
gr.Warning("路径不存在")
|
348 |
+
return
|
349 |
+
with open(merged_path, "r", encoding ="utf8") as json_file:
|
350 |
+
dic_merge = json.load(json_file)
|
351 |
+
id_lis_merge = list(dic_merge.keys())
|
352 |
+
idx_dic_merge = dict()
|
353 |
+
for idx,id_ in enumerate(id_lis_merge):
|
354 |
+
idx_dic_merge[id_] = idx
|
355 |
+
if text_start_id not in id_lis_merge or text_end_id not in id_lis_merge or idx_dic_merge[text_start_id] > idx_dic_merge[text_end_id]:
|
356 |
+
gr.Warning("找不到指定序号, 或id前后顺序错误")
|
357 |
+
return
|
358 |
+
dic_new = {}
|
359 |
+
for idx in range(idx_dic_merge[text_start_id],idx_dic_merge[text_end_id] + 1):
|
360 |
+
dic_new[id_lis_merge[idx]] = dic_merge[id_lis_merge[idx]]
|
361 |
+
name = "small_" + osp.basename(path)
|
362 |
+
new_path = osp.join(osp.dirname(merged_path), name)
|
363 |
+
with open(new_path, "w", encoding ="utf8") as json_file:
|
364 |
+
json.dump(dic_new,json_file,indent = 1,ensure_ascii = False)
|
365 |
+
return new_path
|
366 |
+
|
367 |
+
shortcut_js = """
|
368 |
+
<script>
|
369 |
+
function shortcuts(e) {
|
370 |
+
|
371 |
+
if (e.key.toLowerCase() == "s" && e.shiftKey) {
|
372 |
+
document.getElementById("button_save").click();
|
373 |
+
}
|
374 |
+
if (e.key.toLowerCase() == "w" && e.shiftKey) {
|
375 |
+
document.getElementById("button_up").click();
|
376 |
+
}
|
377 |
+
if (e.key.toLowerCase() == "x" && e.shiftKey) {
|
378 |
+
document.getElementById("button_down").click();
|
379 |
+
}
|
380 |
+
if (e.key.toLowerCase() == "r" && e.shiftKey) {
|
381 |
+
document.getElementById("button_replace").click();
|
382 |
+
}
|
383 |
+
if (e.key.toLowerCase() == "g" && e.shiftKey) {
|
384 |
+
document.getElementById("button_translate_gpt").click();
|
385 |
+
}
|
386 |
+
if (e.key.toLowerCase() == "b" && e.shiftKey) {
|
387 |
+
document.getElementById("button_translate_baidu").click();
|
388 |
+
}
|
389 |
+
|
390 |
+
}
|
391 |
+
document.addEventListener('keyup', shortcuts, false);
|
392 |
+
</script>
|
393 |
+
"""
|
394 |
+
|
395 |
+
with gr.Blocks(theme=Theme1(),head=shortcut_js) as demo:
|
396 |
+
gr.Markdown("# <center>EasyTranslator v1.0.6</center> ",visible=True)
|
397 |
+
# 文本编辑页
|
398 |
+
with gr.Tab("文本编辑"):
|
399 |
+
gr.Markdown("## 文本编辑及保存区")
|
400 |
+
with gr.Row():
|
401 |
+
text_file_path = gr.Textbox(label = "File Path", value = args["file_path"])
|
402 |
+
text_id = gr.Textbox(label = "Text id",show_copy_button=True)
|
403 |
+
button_load_pos = gr.Button("LOAD last edited position")
|
404 |
+
if not if_save_id_immediately:
|
405 |
+
button_save_pos = gr.Button("SAVE last edited position")
|
406 |
+
with gr.Row():
|
407 |
+
if not moyu_mode:
|
408 |
+
# 全屏mode
|
409 |
+
with gr.Column():
|
410 |
+
text_name = gr.Textbox(label = "Name")
|
411 |
+
text_text = gr.Textbox(label = "Text", lines=10,show_copy_button=True)
|
412 |
+
button_save = gr.Button("SAVE FILE",scale= 2,elem_id = "button_save")
|
413 |
+
with gr.Column():
|
414 |
+
text_name_cn = gr.Textbox(label = "Name_CN")
|
415 |
+
with gr.Row():
|
416 |
+
text_gpt = gr.Textbox(label = "GPT", lines=3,show_copy_button=True,interactive = True)
|
417 |
+
button_translate_gpt = gr.Button("Translate(GPT)",elem_id = "button_translate_gpt")
|
418 |
+
with gr.Row():
|
419 |
+
text_baidu = gr.Textbox(label = "Baidu", lines=3,show_copy_button=True,interactive = True)
|
420 |
+
button_translate_baidu = gr.Button("Translate(Baidu)",elem_id = "button_translate_baidu")
|
421 |
+
text_final = gr.Textbox(label = "Text_CN", lines=3,show_copy_button=True,interactive = True)
|
422 |
+
with gr.Row():
|
423 |
+
button_up = gr.Button("↑",elem_id = "button_up")
|
424 |
+
button_down = gr.Button("↓",elem_id = "button_down")
|
425 |
+
button_replace = gr.Button("Replace",elem_id = "button_replace")
|
426 |
+
else:
|
427 |
+
# 摸鱼mode
|
428 |
+
with gr.Column():
|
429 |
+
button_save = gr.Button("SAVE FILE",scale= 2)
|
430 |
+
text_name = gr.Textbox(label = "Name")
|
431 |
+
text_name_cn = gr.Textbox(label = "Name_CN")
|
432 |
+
with gr.Column():
|
433 |
+
with gr.Row():
|
434 |
+
text_gpt = gr.Textbox(label = "GPT", lines=3,show_copy_button=True,interactive = True)
|
435 |
+
button_translate_gpt = gr.Button("Translate(GPT)")
|
436 |
+
with gr.Row():
|
437 |
+
text_baidu = gr.Textbox(label = "Baidu", lines=3,show_copy_button=True,interactive = True)
|
438 |
+
button_translate_baidu = gr.Button("Translate(Baidu)")
|
439 |
+
text_text = gr.Textbox(label = "Text", lines=3,show_copy_button=True)
|
440 |
+
text_final = gr.Textbox(label = "Text_CN", lines=3,show_copy_button=True,interactive = True)
|
441 |
+
with gr.Row():
|
442 |
+
button_up = gr.Button("↑")
|
443 |
+
button_down = gr.Button("↓")
|
444 |
+
button_replace = gr.Button("Replace")
|
445 |
+
label_remaining_text = gr.Label(label="进度",value = "目标剩余???条")
|
446 |
+
gr.Markdown("## 批量机翻区")
|
447 |
+
with gr.Row():
|
448 |
+
text_translate_start_id = gr.Textbox(label = "起始句id")
|
449 |
+
text_translate_end_id = gr.Textbox(label = "结束句id")
|
450 |
+
with gr.Row():
|
451 |
+
radio_translator = gr.Radio(choices = ["Baidu","Gpt3"],label = "接口")
|
452 |
+
label_progress = gr.Label(label = "进度条",value="")
|
453 |
+
checkbox_if_save_translation = gr.Checkbox(value= False, label = "翻译完成后直接保存JSON")
|
454 |
+
button_batch_translate = gr.Button("批量翻译")
|
455 |
+
|
456 |
+
tab_context = gr.Tab("文本预览及导出")
|
457 |
+
with tab_context:
|
458 |
+
gr.Markdown("## 上下文预览区")
|
459 |
+
with gr.Row():
|
460 |
+
with gr.Column():
|
461 |
+
with gr.Row():
|
462 |
+
text_refresh_id = gr.Textbox(label = "编号", value = args["last_edited_id"])
|
463 |
+
text_context_length = gr.Textbox(label = "上下文长度", value = args["context_half_length"])
|
464 |
+
radio_context_type = gr.Radio(choices = ["上下文","上文", "下文"], label = "预览模式",value="下文")
|
465 |
+
with gr.Column():
|
466 |
+
with gr.Row():
|
467 |
+
button_refresh = gr.Button("Refresh")
|
468 |
+
button_save_context = gr.Button("Save Changes")
|
469 |
+
checkbox_if_save_context = gr.Checkbox(value= False, label = "修改直接保存JSON")
|
470 |
+
dataframe_context = gr.DataFrame(headers=['id','name','name_CN','text','text_CN'],
|
471 |
+
interactive=True)
|
472 |
+
gr.Markdown("## 文档导出区")
|
473 |
+
radio_type = gr.Radio(choices = ["中文|纯文本","中文|单次人名文本", "中文|人名文本", "双语|人名文本"],label = "导出类型")
|
474 |
+
with gr.Row():
|
475 |
+
text_derive_start_id = gr.Textbox(label = "起始句id")
|
476 |
+
text_derive_end_id = gr.Textbox(label = "结束句id")
|
477 |
+
with gr.Row():
|
478 |
+
text_seperator_long = gr.Textbox(label = "句间分隔符(长)", value = args["seperator_long"])
|
479 |
+
text_seperator_short = gr.Textbox(label = "双语间分隔符(短)", value = args["seperator_short"])
|
480 |
+
text_output_path = gr.Textbox(label = "输出文件路径", value = args["output_txt_path"])
|
481 |
+
button_derive_text = gr.Button("导出文本")
|
482 |
+
|
483 |
+
# 文件转换页
|
484 |
+
with gr.Tab("文件转换"):
|
485 |
+
gr.Markdown("## CSV to JSON(支持批量上传)")
|
486 |
+
gr.Markdown("准备好台词csv文件(至少包含正序排列的台词)并将台词列命名为text,如自带角色名则将此列命名为name,如自带id则将此列命名为id。\
|
487 |
+
在此处上传csv文件,保存生成的json文件,之后在主界面输入json文件路径即可使用。")
|
488 |
+
with gr.Row():
|
489 |
+
with gr.Column():
|
490 |
+
|
491 |
+
file_target_csv = gr.File(file_types=["csv"],file_count = "multiple", label="Input CSV")
|
492 |
+
with gr.Row():
|
493 |
+
text_text_column = gr.Textbox(label="text列名",value = args["csv_column_name"]["text"])
|
494 |
+
text_name_column = gr.Textbox(label="name列名",value = args["csv_column_name"]["name"])
|
495 |
+
text_id_column = gr.Textbox(label="id列名(optional)",value = args["csv_column_name"]["id"],placeholder = "若不指定或找不到指定列,程序会自动编号")
|
496 |
+
button_convert2json = gr.Button("Convert")
|
497 |
+
file_result_json = gr.File(file_types=["json"],label="Output JSON",interactive=False)
|
498 |
+
gr.Markdown("## JSON to CSV(支持批量上传)")
|
499 |
+
with gr.Row():
|
500 |
+
with gr.Column():
|
501 |
+
file_target_json = gr.File(file_types=["json"],file_count = "multiple",label="Input JSON")
|
502 |
+
button_convert2csv = gr.Button("Convert")
|
503 |
+
file_result_csv = gr.File(file_types=["jcsv"],label="Output CSV",interactive=False)
|
504 |
+
# 文件合并页
|
505 |
+
with gr.Tab("文件合并"):
|
506 |
+
gr.Markdown("## 合并JSON文件")
|
507 |
+
gr.Markdown("将两个json文件中的译文合并,方便多人协作。使用方法为上传部分翻译后的json文件,指定起止id。\
|
508 |
+
程序会用【上传文件】中,从起始句id到结束句id的全部内容,覆盖【指定地址】中的json文件从起始句id到结束句id的全部内容。\
|
509 |
+
若起止id顺序颠倒或不存在,按钮不会作用。请仔细检查并做好备份!!")
|
510 |
+
with gr.Column():
|
511 |
+
|
512 |
+
text_merged_path = gr.Textbox(label = "File Path", value = args["file_path"])
|
513 |
+
file_merging_json = gr.File(file_types=["json"],file_count = "single", label="File to be merged")
|
514 |
+
with gr.Row():
|
515 |
+
text_merge_start_id = gr.Textbox(label="起始句id",value = "")
|
516 |
+
text_merge_end_id = gr.Textbox(label="结束句id",value = "")
|
517 |
+
radio_merge_type = gr.Radio(choices = ["仅人工翻译","全部替换"], label = "合并模式",value="仅人工翻译")
|
518 |
+
|
519 |
+
button_merge = gr.Button("Merge")
|
520 |
+
|
521 |
+
# button_output_json = gr.Button("Merge")
|
522 |
+
gr.Markdown("## 导出JSON文件")
|
523 |
+
gr.Markdown("支持导出起止id范围的小型json文件,以减少协作时的传输负担。使用上面File Path的指定地址。")
|
524 |
+
with gr.Row():
|
525 |
+
text_output_start_id = gr.Textbox(label="起始句id",value = "")
|
526 |
+
text_output_end_id = gr.Textbox(label="结束句id",value = "")
|
527 |
+
button_output = gr.Button("Output")
|
528 |
+
file_output_json = gr.File(file_types=["json"],label="Output JSON",interactive=False)
|
529 |
+
|
530 |
+
|
531 |
+
|
532 |
+
# API设置页
|
533 |
+
with gr.Tab("API Settings"):
|
534 |
+
gr.Markdown("## 百度 API")
|
535 |
+
text_baidu_api_id = gr.Textbox(label="Baidu API Id",value = args["baidu_api_settings"]["api_id"])
|
536 |
+
text_baidu_api_key = gr.Textbox(label="Baidu API Key", value = args["baidu_api_settings"]["api_key"])
|
537 |
+
with gr.Row():
|
538 |
+
text_from_lang = gr.Textbox(label="From Lang",value = args["baidu_api_settings"]["from_lang"])
|
539 |
+
text_to_lang = gr.Textbox(label="To Lang",value = args["baidu_api_settings"]["to_lang"])
|
540 |
+
gr.Markdown("## OPENAI API")
|
541 |
+
text_openai_api = gr.Textbox(label="OPENAI API Key",value = args["openai_api_settings"]["openai_api_key"])
|
542 |
+
with gr.Row():
|
543 |
+
text_prefix = gr.Textbox(label="Prompt Prefix",value = args["openai_api_settings"]["prompt_prefix"])
|
544 |
+
text_postfix = gr.Textbox(label="Prompt Postfix",value = args["openai_api_settings"]["prompt_postfix"])
|
545 |
+
gr.Markdown("## 目标id")
|
546 |
+
text_target_id = gr.Textbox(label="Target Id",value = args["target_id"])
|
547 |
+
button_api_submit = gr.Button("Submit")
|
548 |
+
|
549 |
+
|
550 |
+
# 标签页行为
|
551 |
+
tab_context.select(refresh_context, inputs=[text_id,text_context_length,radio_context_type],outputs=[dataframe_context,text_refresh_id])
|
552 |
+
|
553 |
+
# 文本框行为
|
554 |
+
text_id.change(change_id, inputs = [text_id],
|
555 |
+
outputs = [text_file_path,text_text,text_name,text_name_cn,text_gpt,text_baidu,text_final])
|
556 |
+
text_id.change(get_remaining_text_num,inputs = None, outputs= [label_remaining_text])
|
557 |
+
text_final.change(change_final,inputs = [text_final,text_id])
|
558 |
+
text_name_cn.change(change_name,inputs = [text_name,text_name_cn,text_id])
|
559 |
+
|
560 |
+
# 按钮行为
|
561 |
+
# -文本编辑页
|
562 |
+
button_load_pos.click(load_last_position,inputs=text_file_path, outputs = text_id)
|
563 |
+
if not if_save_id_immediately:
|
564 |
+
button_save_pos.click(save_last_position, inputs = [text_id])
|
565 |
+
button_up.click(last_text, outputs = text_id)
|
566 |
+
button_down.click(next_text, outputs = text_id)
|
567 |
+
button_translate_gpt.click(gpt_translate,
|
568 |
+
inputs=[text_text,text_id], outputs=text_gpt)
|
569 |
+
button_translate_baidu.click(baidu_translate,
|
570 |
+
inputs=[text_text,text_id], outputs=text_baidu)
|
571 |
+
button_replace.click(replace,
|
572 |
+
inputs = [text_gpt,text_baidu,text_final,text_id],
|
573 |
+
outputs=[text_gpt,text_baidu,text_final])
|
574 |
+
button_save.click(save_json)
|
575 |
+
|
576 |
+
button_batch_translate.click(batch_translate, inputs = [radio_translator,checkbox_if_save_translation,text_translate_start_id,text_translate_end_id],
|
577 |
+
outputs = [label_progress])
|
578 |
+
|
579 |
+
# -预览及导出页
|
580 |
+
# button_refresh.click(save_context, inputs=[dataframe_context, text_refresh_id, checkbox_if_save_context])
|
581 |
+
button_refresh.click(refresh_context,inputs=[text_refresh_id,text_context_length,radio_context_type], outputs = [dataframe_context,text_id])
|
582 |
+
button_save_context.click(save_context, inputs=[dataframe_context, text_refresh_id, checkbox_if_save_context])
|
583 |
+
button_derive_text.click(derive_text,
|
584 |
+
inputs = [radio_type, text_derive_start_id, text_derive_end_id,
|
585 |
+
text_seperator_long,text_seperator_short,text_output_path])
|
586 |
+
|
587 |
+
# -文件转换页
|
588 |
+
button_convert2json.click(convert_to_json,
|
589 |
+
inputs = [file_target_csv, text_text_column, text_name_column, text_id_column],
|
590 |
+
outputs = file_result_json)
|
591 |
+
button_convert2csv.click(convert_to_csv,
|
592 |
+
inputs = file_target_json,
|
593 |
+
outputs = file_result_csv)
|
594 |
+
|
595 |
+
# -文件合并页
|
596 |
+
button_merge.click(merge_json, inputs=[text_merged_path,file_merging_json,text_merge_start_id,text_merge_end_id,radio_merge_type])
|
597 |
+
button_output.click(output_json, inputs=[text_merged_path,text_output_start_id,text_output_end_id],outputs=file_output_json)
|
598 |
+
|
599 |
+
# -API管理页
|
600 |
+
button_api_submit.click(submit_api,
|
601 |
+
inputs = [text_baidu_api_id,text_baidu_api_key,text_from_lang,text_to_lang,
|
602 |
+
text_openai_api,text_prefix,text_postfix,text_target_id])
|
603 |
+
|
604 |
+
demo.queue()
|
605 |
+
|
606 |
+
if __name__=="__main__":
|
607 |
+
demo.launch(show_error=True)
|
name.txt
ADDED
@@ -0,0 +1,563 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
10��の一同 十几岁的一行人
|
177 |
+
その場の一同 在场的一行人
|
178 |
+
ザガン&モラクス 塞共&莫拉克斯
|
179 |
+
3人 三人
|
180 |
+
闘志を燃やす幻獣 燃起斗志的幻兽
|
181 |
+
ロノウエ 罗诺威
|
182 |
+
レラジェ&シャックス 蕾拉洁&沙克斯
|
183 |
+
ベルさん 贝尔先生
|
184 |
+
ベルフェゴール&ガープ 贝尔菲戈尔&加普
|
185 |
+
オジサン風メギド 大叔风的梅吉德
|
186 |
+
ソロモン&追放メギドたち 所罗门&追放梅吉德们
|
187 |
+
フェルミ 费路米
|
188 |
+
ヒューガル 休加尔
|
189 |
+
フェルミ&ヒューガル 费路米&休加尔
|
190 |
+
バラム&パイモン&イポス 巴拉姆&派蒙&因波斯
|
191 |
+
その場のメギド全員 在场的梅吉德全员
|
192 |
+
エリゴス&モラクス 艾莉戈丝&莫拉克斯
|
193 |
+
女メギド 女梅吉德
|
194 |
+
ウィチセ 维奇瑟
|
195 |
+
ウェパル&メフィスト 维帕尔&梅菲斯特
|
196 |
+
レラジェ&ソロモン 蕾拉洁&所罗门
|
197 |
+
魚 鱼
|
198 |
+
レラジェ&ザガン&ナベリウス 蕾拉洁&塞共&纳贝琉丝
|
199 |
+
不幸な獲物 不幸的猎物
|
200 |
+
少し慌てたメギド 有点慌张的梅吉德
|
201 |
+
寛いでいたメギド 悠闲的梅吉德
|
202 |
+
ハヤイカ 哈亚卡
|
203 |
+
疑問を持ったメギド 有疑问的梅吉德
|
204 |
+
タシード 塔希德
|
205 |
+
クツロギン 库兹罗金
|
206 |
+
カイル 凯尔
|
207 |
+
ソロモン&レラジェ 所罗门&蕾拉洁
|
208 |
+
ソロモン&転生メギドたち 所罗门&转生梅吉德们
|
209 |
+
レラジェ&ザガン 蕾拉洁&塞共
|
210 |
+
パイモン&サレオス 派蒙&萨雷奥斯
|
211 |
+
ソロモン&ベルフェゴール 所罗门&贝尔菲戈尔
|
212 |
+
カイル&ベルフェゴール 凯尔&贝尔菲戈尔
|
213 |
+
ウィチセ&ジニマル 维奇瑟&基尼玛尔
|
214 |
+
仲間のメギド 同伴梅吉德
|
215 |
+
先遣隊メギド 先遣队梅吉德
|
216 |
+
追放メギドたち 追放梅吉德们
|
217 |
+
敵のメギド 敌方梅吉德
|
218 |
+
敵のメギドたち 敌方梅吉德们
|
219 |
+
威勢のいいメギド 威风凛凛的梅吉德
|
220 |
+
敵のメギド一同 敌方全体梅吉德
|
221 |
+
敵の配下のメギド 敌方的属下梅吉德
|
222 |
+
古いメギドたち 古老的梅吉德们
|
223 |
+
気圧されるメギド 相形见绌的梅吉德
|
224 |
+
ソロモンたち一行 所罗门一行
|
225 |
+
ソロモン&カイル 所罗门&凯尔
|
226 |
+
敵の幻獣 敌方幻兽
|
227 |
+
罵美優蛇のメギドたち 骂美优蛇的梅吉德们
|
228 |
+
その場の全員 在场的全员
|
229 |
+
カイル&ウィチセ 凯尔&维奇瑟
|
230 |
+
同盟相手のメギドたち 同盟伙伴梅吉德们
|
231 |
+
バルバトス&メフィスト 巴巴托斯&梅菲斯特
|
232 |
+
メフィスト&ウェパル 梅菲斯特&维帕尔
|
233 |
+
困惑したような一同 困惑的一行人
|
234 |
+
ソロモン&ブネ 所罗门&布涅
|
235 |
+
ホルン 荷鲁恩
|
236 |
+
野戦軍議の一同 野战军议的全体成员
|
237 |
+
メギド72のメギドたち 梅吉德72的梅吉德们
|
238 |
+
倒されたメギド 被打倒的梅吉德
|
239 |
+
ウィチセ&カイル 维奇瑟&凯尔
|
240 |
+
周囲の敵メギド 周围的敌方梅吉德
|
241 |
+
集まってきた敵メギド 聚集的敌方梅吉德
|
242 |
+
変身した敵メギド 变身的敌方梅吉德
|
243 |
+
パニックになる敵メギド 恐慌的敌方梅吉德
|
244 |
+
ソロモン&ロノウェ 所罗门&罗诺威
|
245 |
+
全員 全员
|
246 |
+
ロノウェ&カイル 罗诺威&凯尔
|
247 |
+
ソロモン&全メギド 所罗门&全梅吉德
|
248 |
+
ソロモン&ウェパル 所罗门&维帕尔
|
249 |
+
バルパイモン 巴尔派蒙
|
250 |
+
狡猾そうなメギド 看起来狡猾的梅吉德
|
251 |
+
アッキピテル 阿基皮特尔
|
252 |
+
アッキピテル&狡猾そうなメギド 阿基皮特尔&看起来狡猾的梅吉德
|
253 |
+
浮島のメギドたち 浮岛的梅吉德们
|
254 |
+
必死の敵メギド 拼命的敌方梅吉德
|
255 |
+
挑発された敵メギド 被挑衅的敌方梅吉德
|
256 |
+
武器を振りかざす敵メギド 挥舞武器的敌方梅吉德
|
257 |
+
タシード&ハヤイカ 塔希德&哈亚卡
|
258 |
+
奮戦する敵メギド 奋战的敌方梅吉德
|
259 |
+
焦る敵メギド 焦急的敌方梅吉德
|
260 |
+
メギド72 梅吉德72
|
261 |
+
次々と死ぬ敵メギド 不断死去的敌方梅吉德
|
262 |
+
バナルマ明けの敵メギド 青年敌方梅吉德
|
263 |
+
パニックになった幻獣 恐慌的幻兽
|
264 |
+
偉そうな敵メギド 摆架子的敌方梅吉德
|
265 |
+
ハイになった敵メギド 情绪高涨的敌方梅吉德
|
266 |
+
不意を突かれた敵メギド 被突然袭击的敌方梅吉德
|
267 |
+
殺意を向ける敵メギド 充满杀意的敌方梅吉德
|
268 |
+
助かりたい敵メギド 求救的敌方梅吉德
|
269 |
+
泣き叫ぶ敵メギド 哭泣的敌方梅吉德
|
270 |
+
覚悟した敵メギド 觉悟的敌方梅吉德
|
271 |
+
がんばった幻獣 努力的幻兽
|
272 |
+
絶望した敵メギド 绝望的敌方梅吉德
|
273 |
+
ボロボロのメギド 破破烂烂的梅吉德
|
274 |
+
瀕死のメギド 濒死的梅吉德
|
275 |
+
死にゆく2人のメギド 垂死的两个梅吉德
|
276 |
+
海を眺める者 眺望大海的人
|
277 |
+
海を守る者 守护大海的人
|
278 |
+
イヌーン 伊努恩
|
279 |
+
避難中の女性 避难中的女性
|
280 |
+
ショーン 肖恩
|
281 |
+
避難民を誘導する騎士 引导难民的骑士
|
282 |
+
维帕尔 维帕尔
|
283 |
+
格雷莫利 格雷莫利
|
284 |
+
めそめそした子供 抽泣的孩子
|
285 |
+
怯えている老人 害怕的老人
|
286 |
+
若い女性 年轻的女性
|
287 |
+
行動力のある男 有行动力的男人
|
288 |
+
隠れてた男 躲藏的男人
|
289 |
+
社交性のある女 擅于���交的女人
|
290 |
+
普通の男 普通的男人
|
291 |
+
ジージョ 吉乔
|
292 |
+
必死の女性 拼命的女性
|
293 |
+
虫のような幻獣 像虫一样的幻兽
|
294 |
+
アンチャーター 反宪章
|
295 |
+
災厄の幻獣 灾厄幻兽
|
296 |
+
阿德拉马雷克 阿德拉马雷克
|
297 |
+
潜伏メギド 潜伏梅吉德
|
298 |
+
ラレール 拉莱尔
|
299 |
+
王都の騎士 王都的骑士
|
300 |
+
騎士団員 骑士团员
|
301 |
+
騎士団隊長 骑士团队员
|
302 |
+
組織の男 组织的男人
|
303 |
+
王都在住の群众 住在王都的群众
|
304 |
+
興奮した群众 兴奋的群众
|
305 |
+
城門前の騎士 城门前的骑士
|
306 |
+
軍団長セメルーゼ 军团长赛梅尔泽
|
307 |
+
軍団副官サブブカ 军团副官撒布布加
|
308 |
+
侵略魔兵ツギガル 侵略魔兵兹基加
|
309 |
+
侵略魔兵アキレテス 侵略魔兵阿基雷特斯
|
310 |
+
侵略魔兵メンドーサ 侵略魔兵门多萨
|
311 |
+
副官メギド 副官梅吉德
|
312 |
+
集まった群衆 聚集的群众
|
313 |
+
そこのヴィータ 那里的维塔
|
314 |
+
騎士団の密偵 骑士团的密探
|
315 |
+
メギドたち 梅吉德们
|
316 |
+
クロケル 库洛塞尔
|
317 |
+
ドン引きしてる少年 受惊的少年
|
318 |
+
バラム&ブネ 巴拉姆&布涅
|
319 |
+
野良猫 野猫
|
320 |
+
マスター 老板
|
321 |
+
ラフネル 拉芙妮尔
|
322 |
+
伏目がちの男 沮丧的男人
|
323 |
+
生き残ってた女の子 活下来的女孩子
|
324 |
+
中にいた全員 其中的所有人
|
325 |
+
慌てた男 慌张的男人
|
326 |
+
不安げな群衆 不安的群众
|
327 |
+
興奮した群衆 兴奋的群众
|
328 |
+
群衆 群众
|
329 |
+
騎士団 骑士团
|
330 |
+
侵略魔兵ボヤーク 侵略魔兵波亚克
|
331 |
+
ブネ&モラクス 布涅&莫拉克斯
|
332 |
+
侵略魔兵ナランゾン 侵略魔兵纳兰宗
|
333 |
+
侵略魔兵ケイカ 侵略魔兵克卡
|
334 |
+
ピンとこない梅吉德们 没反应过来的梅吉德们
|
335 |
+
その場の一行人 在场的一行人
|
336 |
+
襲われていた女性 被袭击的女性
|
337 |
+
襲われていた男の子 被袭击的男孩
|
338 |
+
襲われていた女の子 被袭击的女孩
|
339 |
+
襲われていた男性 被袭击的男性
|
340 |
+
辺境から流れてきた群众 边境流亡而来的群众
|
341 |
+
禁忌の地から来た群众 从禁忌之地来的群众
|
342 |
+
イタンダ 伊坦达
|
343 |
+
理解しかけた群众 接近理解的群众
|
344 |
+
組織の男&沮丧的男人 组织的男人&沮丧的男人
|
345 |
+
生き残った女の子 活下来的女孩子
|
346 |
+
考える群众 思考中的群众
|
347 |
+
考えさせられた群众 被迫思考的群众
|
348 |
+
副官サブブカ 副官撒布布加
|
349 |
+
ツギガル&アキレテス 兹基加&阿基雷特斯
|
350 |
+
理解した群衆の男 理解了的群众中的男人
|
351 |
+
理解した群衆の女 理解了的群众中的女人
|
352 |
+
猫好きのお姉さん 喜欢猫的小姐
|
353 |
+
黒猫 黑猫
|
354 |
+
野良猫? 野猫?
|
355 |
+
野次馬になった群众 变成局外人的群众
|
356 |
+
猫師匠 猫师傅
|
357 |
+
黒猫??? 黑猫
|
358 |
+
驚愕してる群众 惊愕的群众
|
359 |
+
改造メギド体 改造梅吉德体
|
360 |
+
防衛側のメギド一行人 防御方的梅吉德一行人
|
361 |
+
伝言獣ミュトス 传言兽缪托斯
|
362 |
+
セメルーゼ&ケイカ 赛梅尔泽&克卡
|
363 |
+
巨大な幻獣 巨大的幻兽
|
364 |
+
王都の民 王都的民众
|
365 |
+
王都の子供たち 王都的孩子们
|
366 |
+
言葉にならない梅吉德们 说不出话的梅吉德们
|
367 |
+
王都のおばあさん 王都的大妈
|
368 |
+
空を見守る群众 看着天空的群众
|
369 |
+
パン屋のおじさん 面包房的大叔
|
370 |
+
ケーキ屋のお姉さん 蛋糕房的姐姐
|
371 |
+
器用なお兄さん 能干的小哥
|
372 |
+
王都の男の子 王都的男孩子
|
373 |
+
市場の老人 市场的老人
|
374 |
+
市場のご婦人 市场的妇人
|
375 |
+
次元獣アナーケン 次元兽阿纳肯
|
376 |
+
ハーフェン 哈芬
|
377 |
+
魚屋さん 鱼店老板
|
378 |
+
王都の女の子 王都的女孩子
|
379 |
+
気絶してた幻獣 断气的幻兽
|
380 |
+
メギドに変身した男 变成梅吉德的男人
|
381 |
+
巨大な怪物 巨大的怪物
|
382 |
+
不安げな少年 不安的少年
|
383 |
+
おどおどした子供 战战兢兢的孩子
|
384 |
+
子供たち 孩子们
|
385 |
+
ビクビクした子供 颤抖的孩子们
|
386 |
+
街の住民 城中住民
|
387 |
+
港町の男 港口城市的男人
|
388 |
+
群衆の女 路人女
|
389 |
+
群衆のおばさん 路人大妈
|
390 |
+
ラウム&シャックス 拉乌姆&沙克斯
|
391 |
+
ネーサ 奈萨
|
392 |
+
ニック 尼克
|
393 |
+
パイン 派因
|
394 |
+
マナイ 玛奈
|
395 |
+
叫ぶ男 叫喊的男人
|
396 |
+
幻獣の餌 幻兽的食物
|
397 |
+
絶望する老人 绝望的老人
|
398 |
+
漁師 渔夫
|
399 |
+
ベルゼブフ 别西卜
|
400 |
+
サタン 撒旦
|
401 |
+
プルトン 普露通
|
402 |
+
森に潜むメギド 潜藏在森林中的梅吉德
|
403 |
+
サタン&ベルゼブフ 撒旦&别西卜
|
404 |
+
マーグラ 玛格拉
|
405 |
+
ダムロック 达姆洛克
|
406 |
+
マーグラ&パイモン 玛格拉&派蒙
|
407 |
+
踊り子 舞女
|
408 |
+
盛り上がった客 兴奋的客人
|
409 |
+
働く男の子 打工的男孩
|
410 |
+
ダムロック&マーグラ 达姆洛克&玛格拉
|
411 |
+
男の声 男人的声音
|
412 |
+
バトン 巴通
|
413 |
+
盗み見する男の子 偷看的男孩
|
414 |
+
聞き耳立てる男の子 竖起耳朵的男孩
|
415 |
+
酒場の客 酒馆的客人
|
416 |
+
こき使われる男の子 被使唤的男孩
|
417 |
+
凶悪そうな男 相貌凶恶的男人
|
418 |
+
乱暴そうな男 相貌粗鲁的男人
|
419 |
+
突き飛ばされる男の子 被撞倒的男孩
|
420 |
+
逃げる男 逃跑的男人
|
421 |
+
ラチルス 拉吉斯
|
422 |
+
カマセイン 卡马塞因
|
423 |
+
ボス 老大
|
424 |
+
手下2人 两个手下
|
425 |
+
黒い犬 黑犬
|
426 |
+
ヴェルドレ&ダムロック 维尔德蕾&达姆洛克
|
427 |
+
物陰の気配 阴沉的气息
|
428 |
+
こっそり見てた男の子 悄悄看着的男孩
|
429 |
+
ご機嫌なおじさん 高兴的大叔
|
430 |
+
ビラ配りの男の子 发传单的男孩
|
431 |
+
腹黒い男の子 腹黑的男孩
|
432 |
+
逃げる女 逃跑的女人
|
433 |
+
ボスの声 老大的声音
|
434 |
+
クロースルー 克罗斯尔
|
435 |
+
ラチルス&カマセイン 拉吉斯&卡马塞因
|
436 |
+
パイモン&バラム 派蒙&巴拉姆
|
437 |
+
クロースルーたち 克罗斯尔等人
|
438 |
+
宿の支配人 旅馆经理
|
439 |
+
ダムロック&パイモン 达姆洛克&派蒙
|
440 |
+
男の子の声 男孩的声音
|
441 |
+
お使いする男の子 佣人男孩
|
442 |
+
カマセイン&ラチルス 卡马塞因&拉吉斯
|
443 |
+
幻獣 幻兽
|
444 |
+
とあるメギド 某个梅吉德
|
445 |
+
さ迷うメギド 迷路的梅吉德
|
446 |
+
殺し合ってるメギドたち 互相残杀的梅吉德们
|
447 |
+
親衛隊 亲卫队
|
448 |
+
興奮した男 兴奋的男人
|
449 |
+
謎の巨漢 神秘的巨汉
|
450 |
+
謎の群衆 神秘的群众
|
451 |
+
謎の巨漢&群衆 神秘的巨汉&群众
|
452 |
+
雑談メギド 闲谈梅吉德
|
453 |
+
勧誘メギド 劝诱梅吉德
|
454 |
+
死にそうな巨漢 濒死的大汉
|
455 |
+
中央の使者 中央的使者
|
456 |
+
アロケル&モラクス 安洛先&莫拉克斯
|
457 |
+
野生の幻獣 野生幻兽
|
458 |
+
襲い掛かってきた幻獣 袭击而来的幻兽
|
459 |
+
やられた幻獣 被打败的幻兽
|
460 |
+
白い犬 白狗
|
461 |
+
興奮した幻獣 兴奋起来的幻兽
|
462 |
+
メギドらしき男 像是梅吉德的男人
|
463 |
+
漲ってる幻獣 活力满满的幻兽
|
464 |
+
興奮した幻獣&漲ってる幻獣 兴奋起来的幻兽&活力满满的幻兽
|
465 |
+
メギドらしき者 像梅吉德一样的人
|
466 |
+
異様な身体のメギド 身体异常的梅吉德
|
467 |
+
洞窟からの声 洞窟传来的声音
|
468 |
+
生まれたてのメギド 刚出生的梅吉德
|
469 |
+
仲間のメギドたち 同伴梅吉德们
|
470 |
+
成り損ない 失败品
|
471 |
+
まつろわぬ民 不服从中央之人
|
472 |
+
リコレッキ 莉可蕾琪
|
473 |
+
モラクス&リコレッキ 莫拉克斯&莉可蕾琪
|
474 |
+
母なる白き妖蛆 白色母妖蛆
|
475 |
+
|
476 |
+
走る男 奔跑的男人
|
477 |
+
怒りの巨漢 愤怒的巨汉
|
478 |
+
ソロモン&ヒュトギン 所罗门&休特金
|
479 |
+
間の悪い獣人 坏脾气的兽人
|
480 |
+
ブネ&ロノウェ 布涅&罗诺威
|
481 |
+
ぞろぞろ出てきたアジト組 接连出现的基地组
|
482 |
+
手下の獣人 手下的兽人
|
483 |
+
バラム&ヒュトギン 巴拉姆&休托金
|
484 |
+
ソロモン&バルバトス 所罗门&巴巴托斯
|
485 |
+
周囲の軍勢 周围的军队
|
486 |
+
謎の巨漢&周囲の軍勢 神秘的巨汉&周围的军队
|
487 |
+
交渉チーム 谈判组
|
488 |
+
ドカグイ 多卡圭
|
489 |
+
後方隊 后队
|
490 |
+
取り残された一同 被留下的一行人
|
491 |
+
出遅れた獣人 迟到的兽人
|
492 |
+
ゆっくり移動中の巨漢 缓慢移动中的巨汉
|
493 |
+
ウゴカーズ 乌可卡兹
|
494 |
+
やられた獣人 被打败的兽人
|
495 |
+
乱戦中の獣人 混战中的兽人
|
496 |
+
サイゼン 赛森
|
497 |
+
ヤブレカブレ 亚布雷卡布雷
|
498 |
+
ドコカーノ軍団のメギド 都可卡诺军团的梅吉德
|
499 |
+
キノコデウス 蘑菇德乌斯
|
500 |
+
懲罰局のメギド 惩罚局的梅吉德
|
501 |
+
カルコス 卡尔科斯
|
502 |
+
ソロモン王 所罗门王
|
503 |
+
サタン&ソロモン王 撒旦&所罗门王
|
504 |
+
教団宣教長 教团传教长
|
505 |
+
F・F・Pの軍勢 F・F・Pの军队
|
506 |
+
立ち止まった獣人 停下来的兽人
|
507 |
+
気付いた獣人 发觉什么的兽人
|
508 |
+
戸惑ってる獣人 困惑的兽人
|
509 |
+
ブタトン 布塔顿
|
510 |
+
アロケル&ロノウェ 安洛先&罗诺威
|
511 |
+
起き抜けの巨漢 刚起床的巨汉
|
512 |
+
ネテバッカ 内特巴卡
|
513 |
+
ドカグイ&ネテバッカ 多卡圭&内特巴卡
|
514 |
+
三巨頭 三巨头
|
515 |
+
若い男 年轻的男子
|
516 |
+
ツルムガ 兹尔姆加
|
517 |
+
通りすがりの商人 路过的商人
|
518 |
+
コレッキ 可蕾琪
|
519 |
+
レッキ 蕾琪
|
520 |
+
キ 琪
|
521 |
+
聴衆 听众
|
522 |
+
聴衆の1人 听众之一
|
523 |
+
険しい顔の男 面色严峻的男人
|
524 |
+
オーセル 奥赛尔
|
525 |
+
若者 年轻人
|
526 |
+
村の人々 村人们
|
527 |
+
老人 老人
|
528 |
+
女の子 女孩子
|
529 |
+
村長 村长
|
530 |
+
カトルス教信者たち 卡特卢斯教信者们
|
531 |
+
戸惑う一部の村人 一部分困惑的村人
|
532 |
+
村人たち 村人们
|
533 |
+
外の騒ぎ 外面的骚动
|
534 |
+
カトルス教信者 卡特卢斯教信徒
|
535 |
+
グレモリー&ビフロンス 格雷莫利&毕弗隆斯
|
536 |
+
男の子 男孩子
|
537 |
+
男の子&女の子 男孩子&女孩子
|
538 |
+
どこか遠くの寂しげな牛 遥远某处寂寞的牛
|
539 |
+
ボッチキス 波奇基斯
|
540 |
+
追いつかれた男 被追上的男人
|
541 |
+
鎮魂騎士団の男 镇魂骑士团的男人
|
542 |
+
村の大人 村里的大人
|
543 |
+
周囲の大人たち 周围的大人们
|
544 |
+
元自警団員 原自警团员
|
545 |
+
元自警団員たち 原自警团员们
|
546 |
+
フォカロル&ウヴァル 弗卡洛尔%乌法尔
|
547 |
+
守備隊の男 守卫队的男人
|
548 |
+
ブエル&守備隊の男 布耶尔&守卫队的男人
|
549 |
+
捕縛隊一同 抓捕队全员
|
550 |
+
グラシャラボラス&ゼパル 格拉夏拉波拉斯&洁芭尔
|
551 |
+
オロバス&フォラス 俄洛巴斯&佛拉士
|
552 |
+
焦燥した女 焦燥的女人
|
553 |
+
プルクラ 普露库拉
|
554 |
+
物乞いの老婆 行乞的老太太
|
555 |
+
乱暴な女 粗鲁的女人
|
556 |
+
盗み見る人々 偷看的人们
|
557 |
+
若きフォルネウス 年轻的佛钮司
|
558 |
+
医者の話し声 医生的声音
|
559 |
+
子供の声 孩子��声音
|
560 |
+
物乞いだった老婆 曾是乞丐的老太太
|
561 |
+
やさしい顔の老婆 面色温和的老太太
|
562 |
+
幸せを求める老婆 寻求幸福的老太太
|
563 |
+
消えゆく声 逐渐消失的声音
|
replace.txt
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
megidoraru 梅吉德拉尔
|
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 |
+
Livaiasan 利维坦
|
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 |
+
magido 梅吉德
|
140 |
+
西巴女王 示巴女王
|
141 |
+
丹塔里昂 但他林
|
142 |
+
安包车 反宪章
|
143 |
+
贝尔塞夫 别西卜
|
144 |
+
阿拉斯托尔 亚拉丝特尔
|
145 |
+
巴勒姆 巴拉姆
|
146 |
+
不供奉的人 不供奉中央之人
|
147 |
+
阿罗克尔 安洛先
|
148 |
+
母亲白色妖蛆 白色母妖蛆
|
149 |
+
普兰西 布兰希
|
150 |
+
埃尔普夏福特 埃尔普夏福特
|
151 |
+
” 」
|
152 |
+
“ 「
|
153 |
+
· ・
|
154 |
+
米吉多拉尔 梅吉德拉尔
|
155 |
+
成为母亲的白妖蛆 白色母妖蛆
|
156 |
+
身为母亲的白妖蛆 白色母妖蛆
|
157 |
+
后续队 后继队
|
158 |
+
卡特鲁斯 卡特卢斯
|
159 |
+
格雷莫里 吉莫利
|
160 |
+
送葬骑士团 葬送骑士团
|
161 |
+
卡托尔斯 卡特卢斯
|
themes.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
import gradio as gr
|
4 |
+
from gradio.themes.base import Base
|
5 |
+
from gradio.themes.default import Default
|
6 |
+
from gradio.themes.utils import colors, fonts, sizes
|
7 |
+
import time
|
8 |
+
|
9 |
+
|
10 |
+
class Theme1(Base):
|
11 |
+
def __init__(
|
12 |
+
self,
|
13 |
+
*,
|
14 |
+
primary_hue: colors.Color | str = colors.emerald,
|
15 |
+
secondary_hue: colors.Color | str = colors.blue,
|
16 |
+
neutral_hue: colors.Color | str = colors.gray,
|
17 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
18 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
19 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
20 |
+
font: fonts.Font
|
21 |
+
| str
|
22 |
+
| Iterable[fonts.Font | str] = (
|
23 |
+
fonts.GoogleFont("Quicksand"),
|
24 |
+
"ui-sans-serif",
|
25 |
+
"sans-serif",
|
26 |
+
),
|
27 |
+
font_mono: fonts.Font
|
28 |
+
| str
|
29 |
+
| Iterable[fonts.Font | str] = (
|
30 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
31 |
+
"ui-monospace",
|
32 |
+
"monospace",
|
33 |
+
),
|
34 |
+
):
|
35 |
+
super().__init__(
|
36 |
+
primary_hue=primary_hue,
|
37 |
+
secondary_hue=secondary_hue,
|
38 |
+
neutral_hue=neutral_hue,
|
39 |
+
spacing_size=spacing_size,
|
40 |
+
radius_size=radius_size,
|
41 |
+
text_size=text_size,
|
42 |
+
font=font,
|
43 |
+
font_mono=font_mono,
|
44 |
+
|
45 |
+
)
|
46 |
+
super().set(
|
47 |
+
input_background_fill="*neutral_100",
|
48 |
+
block_title_text_weight="600",
|
49 |
+
button_shadow_active="*neutral_400 0px 0px 2px 2px",
|
50 |
+
block_border_width="3px",
|
51 |
+
button_large_padding="32px",
|
52 |
+
button_secondary_background_fill_hover="*neutral_300"
|
53 |
+
)
|
54 |
+
|
utils.py
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import requests
|
3 |
+
import random
|
4 |
+
import json
|
5 |
+
from hashlib import md5
|
6 |
+
from os import path as osp
|
7 |
+
import csv
|
8 |
+
import threading
|
9 |
+
|
10 |
+
def load_config(filepath):
|
11 |
+
with open(filepath, "r", encoding="utf-8") as file:
|
12 |
+
args = json.load(file)
|
13 |
+
return args
|
14 |
+
|
15 |
+
def save_config(args,filepath):
|
16 |
+
with open(filepath, "w", encoding ="utf8") as json_file:
|
17 |
+
json.dump(args,json_file,indent = 1,ensure_ascii = False)
|
18 |
+
return
|
19 |
+
|
20 |
+
def smart_path(path):
|
21 |
+
file_dir = osp.dirname(osp.abspath(__file__))
|
22 |
+
if osp.isabs(path):
|
23 |
+
return path
|
24 |
+
else:
|
25 |
+
return osp.join(file_dir,path)
|
26 |
+
args = load_config(smart_path("./config.json"))
|
27 |
+
|
28 |
+
# Baidu preparation
|
29 |
+
endpoint = "http://api.fanyi.baidu.com"
|
30 |
+
path = "/api/trans/vip/translate"
|
31 |
+
url = endpoint + path
|
32 |
+
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
33 |
+
# Generate salt and sign
|
34 |
+
def make_md5(s, encoding="utf-8"):
|
35 |
+
return md5(s.encode(encoding)).hexdigest()
|
36 |
+
|
37 |
+
def get_baidu_completion(text,api_id,api_key,from_lang,to_lang):
|
38 |
+
salt = random.randint(32768, 65536)
|
39 |
+
sign = make_md5(api_id + text + str(salt) + api_key)
|
40 |
+
payload = {"appid": api_id, "q": text, "from": from_lang, "to": to_lang, "salt": salt, "sign": sign}
|
41 |
+
r = requests.post(url, params=payload, headers=headers)
|
42 |
+
result = r.json()
|
43 |
+
return result["trans_result"][0]["dst"]
|
44 |
+
|
45 |
+
# OPENAI preparation
|
46 |
+
openai_api_key = args["openai_api_settings"]["openai_api_key"]
|
47 |
+
time_limit = float(args["openai_api_settings"]["time_limit"])
|
48 |
+
client = openai.OpenAI(api_key = openai_api_key)
|
49 |
+
class GPTThread(threading.Thread):
|
50 |
+
def __init__(self, model, messages, temperature):
|
51 |
+
super().__init__()
|
52 |
+
self.model = model
|
53 |
+
self.messages = messages
|
54 |
+
self.temperature = temperature
|
55 |
+
self.result = ""
|
56 |
+
def terminate(self):
|
57 |
+
self._running = False
|
58 |
+
def run(self):
|
59 |
+
response = client.chat.completions.create(
|
60 |
+
model=self.model,
|
61 |
+
messages=self.messages,
|
62 |
+
temperature=self.temperature,
|
63 |
+
)
|
64 |
+
self.result = response.choices[0].message.content
|
65 |
+
|
66 |
+
def get_gpt_completion(prompt, model="gpt-3.5-turbo",api_key = openai_api_key):
|
67 |
+
messages = [{"role": "user", "content": prompt}]
|
68 |
+
temperature = random.uniform(0,1)
|
69 |
+
thread = GPTThread(model, messages,temperature)
|
70 |
+
thread.start()
|
71 |
+
thread.join(10)
|
72 |
+
if thread.is_alive():
|
73 |
+
thread.terminate()
|
74 |
+
print("请求超时")
|
75 |
+
return "TimeoutError", False
|
76 |
+
else:
|
77 |
+
return thread.result, True
|
78 |
+
|
79 |
+
def left_pad_zero(number, digit):
|
80 |
+
number_str = str(number)
|
81 |
+
padding_count = digit - len(number_str)
|
82 |
+
padded_number_str = "0" * padding_count + number_str
|
83 |
+
return padded_number_str
|
84 |
+
|
85 |
+
def generate_ids(num: int):
|
86 |
+
length = len(str(num))+1
|
87 |
+
ids = []
|
88 |
+
for i in range(num):
|
89 |
+
ids.append(left_pad_zero(i,length))
|
90 |
+
return ids
|
91 |
+
|
92 |
+
def convert_to_json(files, text_col, name_col, id_col):
|
93 |
+
out_files = []
|
94 |
+
for file_target in files:
|
95 |
+
dic = {}
|
96 |
+
path = file_target.name
|
97 |
+
dir = osp.dirname(path)
|
98 |
+
base_name = osp.basename(path)
|
99 |
+
new_name = base_name[:-4]+".json"
|
100 |
+
new_path = osp.join(dir,new_name)
|
101 |
+
with open(path,"r",encoding="utf-8") as f:
|
102 |
+
reader = csv.DictReader(f)
|
103 |
+
line_num = sum(1 for _ in open(path,"r",encoding="utf-8"))
|
104 |
+
fieldnames = reader.fieldnames
|
105 |
+
if id_col not in fieldnames:
|
106 |
+
ids = generate_ids(line_num)
|
107 |
+
i = 0
|
108 |
+
for row in reader:
|
109 |
+
dic[ids[i]]={"name":row[name_col],"text":row[text_col]}
|
110 |
+
for field in fieldnames:
|
111 |
+
if field not in (name_col,text_col):
|
112 |
+
dic[ids[i]][field] = row[field]
|
113 |
+
i += 1
|
114 |
+
else:
|
115 |
+
for row in reader:
|
116 |
+
dic[row[id_col]]={"name":row[name_col],"text":row[text_col]}
|
117 |
+
for field in fieldnames:
|
118 |
+
if field not in (name_col,text_col,id_col):
|
119 |
+
dic[row[id_col]][field] = row[field]
|
120 |
+
|
121 |
+
f.close()
|
122 |
+
with open(new_path, "w", encoding= "utf-8") as f2:
|
123 |
+
json.dump(dic,f2,indent=1,ensure_ascii=False)
|
124 |
+
out_files.append(new_path)
|
125 |
+
return out_files
|
126 |
+
|
127 |
+
def convert_to_csv(files):
|
128 |
+
out_files = []
|
129 |
+
for file_target in files:
|
130 |
+
path = file_target.name
|
131 |
+
dir = osp.dirname(path)
|
132 |
+
base_name = osp.basename(path)
|
133 |
+
new_name = base_name[:-4]+".csv"
|
134 |
+
new_path = osp.join(dir,new_name)
|
135 |
+
with open(path, "r", encoding= "utf-8") as f:
|
136 |
+
dic = json.load(f)
|
137 |
+
field_names = []
|
138 |
+
for value in dic.values():
|
139 |
+
for field in value.keys():
|
140 |
+
if field not in field_names: field_names.append(field)
|
141 |
+
for key in dic.keys():
|
142 |
+
dic[key]["id"] = key
|
143 |
+
for field in field_names:
|
144 |
+
if field not in dic[key]:
|
145 |
+
dic[key][field] = ""
|
146 |
+
field_names.insert(0,"id")
|
147 |
+
with open(new_path, "w", encoding= "utf-8",newline="") as f2:
|
148 |
+
writer = csv.DictWriter(f2,fieldnames=field_names)
|
149 |
+
writer.writeheader()
|
150 |
+
writer.writerows(list(dic.values()))
|
151 |
+
out_files.append(new_path)
|
152 |
+
return out_files
|
153 |
+
|