Bikatr7 commited on
Commit
c4fccbf
1 Parent(s): 0be51e4
jsons/cote_replacements.json CHANGED
@@ -1,4 +1,3 @@
1
-
2
  {
3
  "honorifics": {
4
  "ちゃん": "chan",
@@ -72,6 +71,7 @@
72
  "single_names": {
73
  "Akiyama": ["秋山"],
74
  "Anzai": ["安在"],
 
75
  "Ijūin": ["伊集院"],
76
  "Iki": ["井木"],
77
  "Ishida": ["石田"],
@@ -87,6 +87,7 @@
87
  "Mika": ["美香"],
88
  "Minamikawa": ["南川"],
89
  "Namekawa": ["滑川"],
 
90
  "Ōba": ["大場"],
91
  "Obokata": ["小保方"],
92
  "Onizuka": ["鬼塚"],
@@ -96,17 +97,20 @@
96
  "Sonezaki": ["曽根崎"],
97
  "Sōya": ["宗谷"],
98
  "Sugio": ["杉尾"],
 
99
  "Tatebayashi":["舘林"],
100
  "Tomose":["トモセ"],
101
  "Toyohashi": ["豊橋"],
 
102
  "Yano": ["矢野"],
103
  "king": ["Wan-sama"]
104
- },
105
 
106
  "full_names": {
107
  "Amasawa Ichika": ["天沢","一夏"],
108
  "Amikura Mako": ["網倉","麻子"],
109
  "Andō Sayo" : ["安藤","紗代"],
 
110
  "Asahina Nazuna": ["朝比奈","なずな"],
111
  "Asama Hisashi": ["浅間","久"],
112
  "Ayanokōji Atsuomi": ["綾小路","篤臣"],
@@ -115,12 +119,15 @@
115
  "Chabashira Sae": ["茶柱","佐枝"],
116
  "Eikura Mami": ["榮倉","まみ"],
117
  "Enoshima Midoriko":["榎嶋","翠子"],
 
118
  "Fukuchi Hinano": ["福地陽","菜乃"],
 
119
  "Hamaguchi Tetsuya": ["浜口","哲也"],
120
  "Hagiwara Chihaya": ["萩原","千颯"],
121
  "Hasebe Haruka": ["長谷部","波瑠加"],
122
  "Hashimoto Masayoshi": ["橋本","正義"],
123
  "Hatsukawa Maho": ["初川","舞峰"],
 
124
  "Himeno Yuki":["姫野","ユキ"],
125
  "Hirata Yōsuke": ["平田","洋介"],
126
  "Hondō Ryōtarō": ["本堂","遼太郎"],
@@ -132,11 +139,15 @@
132
  "Iguchi Yuri": ["井口","由里"],
133
  "Ike Kanji": ["池","寛治"],
134
  "Inogashira Kokoro": ["井の頭","心"],
 
135
  "Ishigami Kyō" : ["石上" , "京"],
 
136
  "Ishizaki Daichi": ["石崎","大地"],
137
  "Isomaru Yōkō": ["磯丸","容幸"],
 
138
  "Kamogawa Toshizō": ["鴨川","俊三"],
139
  "Kamuro Masumi": ["神室","真澄"],
 
140
  "Kanzaki Ryūji": ["神崎","隆二"],
141
  "Karuizawa Kei": ["軽井沢","恵"],
142
  "Katsuragi Kōhei": ["葛城","康平"],
@@ -147,52 +158,77 @@
147
  "Kitō Hayato": ["鬼頭","隼"],
148
  "Kobashi Yume": ["小橋","夢"],
149
  "Komiya Kyōgo": ["小宮","叶吾"],
150
- "Kondō Reo": ["近藤","玲音"],
151
  "Kōenji Rokusuke": ["高円寺","六助"],
152
  "Kōji Machida": ["浩二","町田"],
153
  "Kusuda Yukitsu": ["楠田","ゆきつ"],
 
 
154
  "Manabe Shiho": ["真鍋","志保"],
155
  "Mashima Tomonari": ["真嶋","智也"],
156
  "Matsushita Chiaki": ["松下","千秋"],
 
157
  "Miyake Akito": ["三宅","明人"],
158
  "Miyamoto Sōshi":["宮本","蒼士"],
159
- "Mori Nene": ["","寧々"],
160
  "Morishita Ai": ["森下","藍"],
 
 
 
 
161
  "Nagumo Miyabi": ["南雲","雅"],
 
 
162
  "Nanase Tsubasa": ["七瀬","翼"],
163
  "Naoe Jinnosuke": ["直江","仁之助"],
164
  "Nishimura Ryūko": ["西村","龍子"],
165
  "Nishino Takeko" : ["西野","武子"],
 
166
  "Norihito Watanabe": ["渡辺","紀仁"],
 
 
167
  "Okitani Kyōsuke": ["沖谷","京介"],
168
  "Onodera Kayano": ["小野寺","かや乃"],
 
169
  "Ryūen Kakeru": ["龍園","翔"],
170
  "Sakagami Kazuma": ["坂上","数馬"],
171
  "Sakayanagi Arisu": ["坂柳","有栖"],
172
  "Sakayanagi Narimori": ["坂柳","成守"],
173
  "Sakura Airi": ["佐倉","愛里"],
174
  "Satō Maya": ["佐藤","麻耶"],
 
175
  "Sanada Kousei": ["真田","康生"],
176
  "Sawada Yasumi": ["沢田","恭美"],
177
  "Shiba Katsunori": ["司馬","克典"],
178
  "Shibata Sō" : ["柴田","颯"],
 
179
  "Shiina Hiyori": ["椎名","ひより"],
180
  "Shinohara Satsuki": ["篠原","さつき"],
181
  "Shintoku Tarō": ["新徳","太郎"],
182
  "Shiranami Chihiro": ["白波","千尋"],
 
 
183
  "Sotomura Hideo": ["外村","秀雄"],
184
  "Suchi Moeka": ["須知","萌香"],
185
  "Sudō Ken": ["須藤","健"],
 
 
 
 
186
  "Suzukake Tanji": ["鈴懸","鍛治"],
187
  "Tachibana Akane": ["橘","茜"],
188
  "Tachibana Kento": ["立花","賢人"],
189
  "Takahashi Osamu":["高橋","修"],
 
 
 
190
  "Tokitō Hiroya": ["時任","裕也"],
191
- "Tatewaki Aoi": ["帯刀","碧"],
192
  "Totsuka Yahiko": ["戸塚","弥彦"],
193
- "Tōdō Rin": ["藤堂","凛"],
194
  "Tsubaki Sakurako": ["椿","桜子"],
 
 
195
  "Tsukishiro Tokinari": ["月城","常成"],
 
196
  "Utomiya Riku": ["宇都宮","陸"],
197
  "Wan Mei-Yui": ["王","美雨"],
198
  "Yabu Nanami" : ["藪","菜々美"],
@@ -200,16 +236,21 @@
200
  "Yamada Albert": ["山田","アルベルト"],
201
  "Yamamura Miki": ["山村","美紀"],
202
  "Yamanaka Ikuko": ["山中","郁子"],
203
- "Yamashita Saki" : ["鈴代","紗弓"],
204
  "Yamashita Naohisa" :[ "山下","直久"],
 
205
  "Yamauchi Haruki": ["山内","春樹"],
206
  "Yanagi Yasuhisa": ["柳","安久"],
207
- "Yukimura Teruhiko": ["幸村","輝彦"]
 
 
 
 
 
 
208
  },
209
 
210
  "enhanced_check_whitelist": {
211
  "Hoshinomiya Chie": ["星之宮","知恵"],
212
  "Kijima": ["鬼島"]
213
  }
214
-
215
  }
 
 
1
  {
2
  "honorifics": {
3
  "ちゃん": "chan",
 
71
  "single_names": {
72
  "Akiyama": ["秋山"],
73
  "Anzai": ["安在"],
74
+ "Hoashi": ["帆足"],
75
  "Ijūin": ["伊集院"],
76
  "Iki": ["井木"],
77
  "Ishida": ["石田"],
 
87
  "Mika": ["美香"],
88
  "Minamikawa": ["南川"],
89
  "Namekawa": ["滑川"],
90
+ "Niiura": ["新浦"],
91
  "Ōba": ["大場"],
92
  "Obokata": ["小保方"],
93
  "Onizuka": ["鬼塚"],
 
97
  "Sonezaki": ["曽根崎"],
98
  "Sōya": ["宗谷"],
99
  "Sugio": ["杉尾"],
100
+ "Tanihara": ["谷原"],
101
  "Tatebayashi":["舘林"],
102
  "Tomose":["トモセ"],
103
  "Toyohashi": ["豊橋"],
104
+ "Yamawaki": ["山脇"],
105
  "Yano": ["矢野"],
106
  "king": ["Wan-sama"]
107
+ },
108
 
109
  "full_names": {
110
  "Amasawa Ichika": ["天沢","一夏"],
111
  "Amikura Mako": ["網倉","麻子"],
112
  "Andō Sayo" : ["安藤","紗代"],
113
+ "Asagaya Mai": ["阿佐ヶ谷","舞"],
114
  "Asahina Nazuna": ["朝比奈","なずな"],
115
  "Asama Hisashi": ["浅間","久"],
116
  "Ayanokōji Atsuomi": ["綾小路","篤臣"],
 
119
  "Chabashira Sae": ["茶柱","佐枝"],
120
  "Eikura Mami": ["榮倉","まみ"],
121
  "Enoshima Midoriko":["榎嶋","翠子"],
122
+ "Fujisaki Rinna": ["藤崎","稟菜"],
123
  "Fukuchi Hinano": ["福地陽","菜乃"],
124
+ "Fukuyama Shinobu": ["福山","しのぶ"],
125
  "Hamaguchi Tetsuya": ["浜口","哲也"],
126
  "Hagiwara Chihaya": ["萩原","千颯"],
127
  "Hasebe Haruka": ["長谷部","波瑠加"],
128
  "Hashimoto Masayoshi": ["橋本","正義"],
129
  "Hatsukawa Maho": ["初川","舞峰"],
130
+ "Hatate Kaoru": ["旗手","薫"],
131
  "Himeno Yuki":["姫野","ユキ"],
132
  "Hirata Yōsuke": ["平田","洋介"],
133
  "Hondō Ryōtarō": ["本堂","遼太郎"],
 
139
  "Iguchi Yuri": ["井口","由里"],
140
  "Ike Kanji": ["池","寛治"],
141
  "Inogashira Kokoro": ["井の頭","心"],
142
+ "Inoue Toa": ["井上","都亞"],
143
  "Ishigami Kyō" : ["石上" , "京"],
144
+ "Ishida Yūsuke": ["石田","優介"],
145
  "Ishizaki Daichi": ["石崎","大地"],
146
  "Isomaru Yōkō": ["磯丸","容幸"],
147
+ "Isoyama Nagisa": ["磯山","渚沙"],
148
  "Kamogawa Toshizō": ["鴨川","俊三"],
149
  "Kamuro Masumi": ["神室","真澄"],
150
+ "Kaneda Satoru": ["金田","悟"],
151
  "Kanzaki Ryūji": ["神崎","隆二"],
152
  "Karuizawa Kei": ["軽井沢","恵"],
153
  "Katsuragi Kōhei": ["葛城","康平"],
 
158
  "Kitō Hayato": ["鬼頭","隼"],
159
  "Kobashi Yume": ["小橋","夢"],
160
  "Komiya Kyōgo": ["小宮","叶吾"],
161
+ "Kondō Reon": ["近藤","玲音"],
162
  "Kōenji Rokusuke": ["高円寺","六助"],
163
  "Kōji Machida": ["浩二","町田"],
164
  "Kusuda Yukitsu": ["楠田","ゆきつ"],
165
+ "Machida Kōji": ["町田","浩二"],
166
+ "Makita Susumu": ["牧田","進"],
167
  "Manabe Shiho": ["真鍋","志保"],
168
  "Mashima Tomonari": ["真嶋","智也"],
169
  "Matsushita Chiaki": ["松下","千秋"],
170
+ "Minami Hakuo": ["南伯夫"],
171
  "Miyake Akito": ["三宅","明人"],
172
  "Miyamoto Sōshi":["宮本","蒼士"],
173
+ "Morishige Takurō": ["森重","卓郎"],
174
  "Morishita Ai": ["森下","藍"],
175
+ "Morofuji Rika": ["諸藤","リカ"],
176
+ "Moriyama Susumu": ["森山","進"],
177
+ "Mori Nene": ["森","寧々"],
178
+ "Motodoi Chikako": ["元土肥","千佳子"],
179
  "Nagumo Miyabi": ["南雲","雅"],
180
+ "Nakaizumi Shōhei": ["中泉","昌平"],
181
+ "Nakanishi Jirō": ["中西","次郎"],
182
  "Nanase Tsubasa": ["七瀬","翼"],
183
  "Naoe Jinnosuke": ["直江","仁之助"],
184
  "Nishimura Ryūko": ["西村","龍子"],
185
  "Nishino Takeko" : ["西野","武子"],
186
+ "Nomura Yūji": ["野村","雄二"],
187
  "Norihito Watanabe": ["渡辺","紀仁"],
188
+ "Oda Takumi": ["小田","拓海"],
189
+ "Okabe Fuyu": ["岡部","ふゆ"],
190
  "Okitani Kyōsuke": ["沖谷","京介"],
191
  "Onodera Kayano": ["小野寺","かや乃"],
192
+ "Rokkaku Momoe": ["六角","百恵"],
193
  "Ryūen Kakeru": ["龍園","翔"],
194
  "Sakagami Kazuma": ["坂上","数馬"],
195
  "Sakayanagi Arisu": ["坂柳","有栖"],
196
  "Sakayanagi Narimori": ["坂柳","成守"],
197
  "Sakura Airi": ["佐倉","愛里"],
198
  "Satō Maya": ["佐藤","麻耶"],
199
+ "Satonaka Satoru": ["里中","聡"],
200
  "Sanada Kousei": ["真田","康生"],
201
  "Sawada Yasumi": ["沢田","恭美"],
202
  "Shiba Katsunori": ["司馬","克典"],
203
  "Shibata Sō" : ["柴田","颯"],
204
+ "Shimizu Naoki": ["清水","直樹"],
205
  "Shiina Hiyori": ["椎名","ひより"],
206
  "Shinohara Satsuki": ["篠原","さつき"],
207
  "Shintoku Tarō": ["新徳","太郎"],
208
  "Shiranami Chihiro": ["白波","千尋"],
209
+ "Shimazaki Ikkei": ["島崎","いっけい"],
210
+ "Sonoda Masashi": ["園田","正志"],
211
  "Sotomura Hideo": ["外村","秀雄"],
212
  "Suchi Moeka": ["須知","萌香"],
213
  "Sudō Ken": ["須藤","健"],
214
+ "Sugio Hiroshi": ["杉尾","大"],
215
+ "Suminokura Mami": ["角倉","真美"],
216
+ "Suzuki Hidetoshi": ["鈴木","英俊"],
217
+ "Suzuhira Miu": ["鈴平","美羽"],
218
  "Suzukake Tanji": ["鈴懸","鍛治"],
219
  "Tachibana Akane": ["橘","茜"],
220
  "Tachibana Kento": ["立花","賢人"],
221
  "Takahashi Osamu":["高橋","修"],
222
+ "Takarajima Miko": ["宝島","みこ"],
223
+ "Tanihara Mao": ["谷原","真緒"],
224
+ "Tamiya Emi": ["田宮","江美"],
225
  "Tokitō Hiroya": ["時任","裕也"],
 
226
  "Totsuka Yahiko": ["戸塚","弥彦"],
 
227
  "Tsubaki Sakurako": ["椿","桜子"],
228
+ "Tsukaji Shihori": ["塚地","しほり"],
229
+ "Tsukasaki Taiga": ["司城","大河"],
230
  "Tsukishiro Tokinari": ["月城","常成"],
231
+ "Takanashi Kō": ["小鳥遊","コウ"],
232
  "Utomiya Riku": ["宇都宮","陸"],
233
  "Wan Mei-Yui": ["王","美雨"],
234
  "Yabu Nanami" : ["藪","菜々美"],
 
236
  "Yamada Albert": ["山田","アルベルト"],
237
  "Yamamura Miki": ["山村","美紀"],
238
  "Yamanaka Ikuko": ["山中","郁子"],
 
239
  "Yamashita Naohisa" :[ "山下","直久"],
240
+ "Yamashita Saki" : ["山下","沙希"],
241
  "Yamauchi Haruki": ["山内","春樹"],
242
  "Yanagi Yasuhisa": ["柳","安久"],
243
+ "Yanagibashi Motofumi": ["柳橋","元史"],
244
+ "Yano Koharu": ["矢野","小春"],
245
+ "Yajima Mariko": ["矢島","麻里子"],
246
+ "Yoshida Kenta": ["吉田","健太"],
247
+ "Yoshimoto Kōsetsu": ["吉本","功節"],
248
+ "Yonezu Haruto": ["米津","春斗"],
249
+ "Yūbe Yoshika": ["夕部","よしか"]
250
  },
251
 
252
  "enhanced_check_whitelist": {
253
  "Hoshinomiya Chie": ["星之宮","知恵"],
254
  "Kijima": ["鬼島"]
255
  }
 
256
  }
lib/gui/save_to_zip.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (...texts) =>
2
+ {
3
+ console.log("Starting save_to_zip function");
4
+
5
+ const sectionNames = [
6
+ "Indexed Text", "Indexing Results", "Indexing Debug Log",
7
+ "Preprocessed Text", "Preprocessing Results", "Preprocessing Debug Log",
8
+ "Translated Text", "JE Check Text", "Translator Debug Log",
9
+ "Overall Debug Log", "Error Log"
10
+ ];
11
+
12
+ texts.forEach((text, index) =>
13
+ {
14
+ console.log(`Processing section: ${sectionNames[index]}`);
15
+ const fileName = `${sectionNames[index].replace(/ /g, '_').toLowerCase()}.txt`;
16
+ const blob = new Blob([text], { type: 'text/plain' });
17
+ const url = URL.createObjectURL(blob);
18
+ console.log("URL created:", url);
19
+
20
+ const a = document.createElement('a');
21
+ a.href = url;
22
+ a.download = fileName;
23
+ console.log("Download link created for", fileName);
24
+
25
+ a.click();
26
+ console.log("Download initiated for", fileName);
27
+
28
+ URL.revokeObjectURL(url);
29
+ console.log("URL revoked for", fileName);
30
+ });
31
+
32
+ console.log("save_to_zip function completed");
33
+ }
modules/common/file_ensurer.py CHANGED
@@ -74,8 +74,9 @@ class FileEnsurer():
74
  ## favicon
75
  favicon_path = os.path.join(gui_lib, "Kudasai_Logo.png")
76
 
77
- ## js save to file
78
  js_save_to_file_path = os.path.join(gui_lib, "save_to_file.js")
 
79
 
80
  ## translation settings description
81
  translation_settings_description_path = os.path.join(common_lib, "translation_settings_description.txt")
 
74
  ## favicon
75
  favicon_path = os.path.join(gui_lib, "Kudasai_Logo.png")
76
 
77
+ ## js
78
  js_save_to_file_path = os.path.join(gui_lib, "save_to_file.js")
79
+ js_save_to_zip_path = os.path.join(gui_lib, "save_to_zip.js")
80
 
81
  ## translation settings description
82
  translation_settings_description_path = os.path.join(common_lib, "translation_settings_description.txt")
modules/common/toolkit.py CHANGED
@@ -15,7 +15,7 @@ class Toolkit():
15
 
16
  """
17
 
18
- CURRENT_VERSION = "v3.4.10"
19
 
20
  ##-------------------start-of-clear_console()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21
 
 
15
 
16
  """
17
 
18
+ CURRENT_VERSION = "v3.4.11"
19
 
20
  ##-------------------start-of-clear_console()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21
 
modules/common/translator.py CHANGED
@@ -217,7 +217,7 @@ class Translator:
217
  else:
218
  method = Translator.TRANSLATION_METHOD
219
 
220
- Translator.TRANSLATION_METHOD, api_key_path = translation_methods.get(method, ("deepl", FileEnsurer.deepl_api_key_path)) #type: ignore
221
 
222
  if(Translator.pre_provided_api_key != ""):
223
  if(Translator.TRANSLATION_METHOD == "google translate"):
 
217
  else:
218
  method = Translator.TRANSLATION_METHOD
219
 
220
+ Translator.TRANSLATION_METHOD, api_key_path = translation_methods.get(method, ("deepl", FileEnsurer.deepl_api_key_path)) # type: ignore
221
 
222
  if(Translator.pre_provided_api_key != ""):
223
  if(Translator.TRANSLATION_METHOD == "google translate"):
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  backoff==2.2.1
2
- gradio==4.20.0
3
  kairyou==1.6.5
4
- easytl==0.4.6
5
  ja_core_news_lg @ https://github.com/explosion/spacy-models/releases/download/ja_core_news_lg-3.7.0/ja_core_news_lg-3.7.0-py3-none-any.whl#sha256=f08eecb4d40523045c9478ce59a67564fd71edd215f32c076fa91dc1f05cc7fd
 
1
  backoff==2.2.1
2
+ gradio==4.44.0
3
  kairyou==1.6.5
4
+ easytl==0.4.10
5
  ja_core_news_lg @ https://github.com/explosion/spacy-models/releases/download/ja_core_news_lg-3.7.0/ja_core_news_lg-3.7.0-py3-none-any.whl#sha256=f08eecb4d40523045c9478ce59a67564fd71edd215f32c076fa91dc1f05cc7fd
webgui.py CHANGED
@@ -2,6 +2,7 @@
2
  import typing
3
  import base64
4
  import asyncio
 
5
  import os
6
  import json
7
 
@@ -42,6 +43,9 @@ class KudasaiGUI:
42
  with open(FileEnsurer.js_save_to_file_path, 'r', encoding='utf-8') as f:
43
  js_save_to_file = f.read()
44
 
 
 
 
45
  ## used for whether the debug log tab for Translator should be actively refreshing based of Logger.current_batch
46
  is_translation_ongoing = False
47
 
@@ -89,6 +93,9 @@ class KudasaiGUI:
89
  "deepl_formality": lines[81-1].strip(),
90
  }
91
 
 
 
 
92
  ##-------------------start-of-build_gui()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
93
 
94
  def build_gui(self) -> None:
@@ -99,8 +106,7 @@ class KudasaiGUI:
99
 
100
  """
101
 
102
- with gr.Blocks(title="Kudasai", delete_cache=(300, 300)) as self.gui:
103
-
104
  ##-------------------start-of-Utility-Functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
105
 
106
  ##-------------------start-of-fetch_log_content()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -772,6 +778,11 @@ class KudasaiGUI:
772
  with gr.Row():
773
  self.logging_clear_logs_button = gr.Button('Clear Logs', variant='stop')
774
 
 
 
 
 
 
775
  ##-------------------start-of-Listener-Functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
776
 
777
  def webgui_update_check() -> None:
@@ -2076,7 +2087,42 @@ class KudasaiGUI:
2076
  outputs=[],
2077
 
2078
  ## javascript code that allows us to save textbox contents to a file
2079
- js=(self.js_save_to_file).replace("downloaded_text.txt", "error_log.txt")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2080
  )
2081
 
2082
  ##-------------------start-of-send_to_x_click()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -2088,6 +2134,58 @@ class KudasaiGUI:
2088
  self.send_to_translator_button.click(fn=send_to_translator_button,
2089
  inputs=[self.preprocessing_output_field],
2090
  outputs=[self.input_text_translator])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2091
 
2092
  ##-------------------start-of-launch()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2093
 
 
2
  import typing
3
  import base64
4
  import asyncio
5
+ import time
6
  import os
7
  import json
8
 
 
43
  with open(FileEnsurer.js_save_to_file_path, 'r', encoding='utf-8') as f:
44
  js_save_to_file = f.read()
45
 
46
+ with open(FileEnsurer.js_save_to_zip_path, 'r', encoding='utf-8') as f:
47
+ js_save_to_zip = f.read()
48
+
49
  ## used for whether the debug log tab for Translator should be actively refreshing based of Logger.current_batch
50
  is_translation_ongoing = False
51
 
 
93
  "deepl_formality": lines[81-1].strip(),
94
  }
95
 
96
+ last_text_change = 0
97
+ debounce_delay = 2 ## 2 seconds
98
+
99
  ##-------------------start-of-build_gui()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
100
 
101
  def build_gui(self) -> None:
 
106
 
107
  """
108
 
109
+ with gr.Blocks(title="Kudasai", delete_cache=(300, 300), analytics_enabled=False) as self.gui:
 
110
  ##-------------------start-of-Utility-Functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
111
 
112
  ##-------------------start-of-fetch_log_content()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
778
  with gr.Row():
779
  self.logging_clear_logs_button = gr.Button('Clear Logs', variant='stop')
780
 
781
+ with gr.Tab("Output"):
782
+
783
+ with gr.Row():
784
+ self.download_all_outputs_button = gr.Button('Download All Outputs', elem_id="download-all-outputs-button")
785
+
786
  ##-------------------start-of-Listener-Functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
787
 
788
  def webgui_update_check() -> None:
 
2087
  outputs=[],
2088
 
2089
  ## javascript code that allows us to save textbox contents to a file
2090
+ js=(self.js_save_to_zip).replace("downloaded_text.txt", "error_log.txt")
2091
+ )
2092
+
2093
+ ##-------------------start-of-download_all_outputs_click()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2094
+
2095
+ self.download_all_outputs_button.click(
2096
+ lambda indexed_text, indexing_results, indexing_debug,
2097
+ preprocessed_text, preprocessing_results, preprocessing_debug,
2098
+ translated_text, je_check_text, translator_debug,
2099
+ logging_debug, logging_error:
2100
+ f"Indexed Text:\n{indexed_text}\n\n"
2101
+ f"Indexing Results:\n{indexing_results}\n\n"
2102
+ f"Indexing Debug Log:\n{indexing_debug}\n\n"
2103
+ f"Preprocessed Text:\n{preprocessed_text}\n\n"
2104
+ f"Preprocessing Results:\n{preprocessing_results}\n\n"
2105
+ f"Preprocessing Debug Log:\n{preprocessing_debug}\n\n"
2106
+ f"Translated Text:\n{translated_text}\n\n"
2107
+ f"JE Check Text:\n{je_check_text}\n\n"
2108
+ f"Translator Debug Log:\n{translator_debug}\n\n"
2109
+ f"Overall Debug Log:\n{logging_debug}\n\n"
2110
+ f"Error Log:\n{logging_error}",
2111
+ inputs=[
2112
+ self.indexing_output_field,
2113
+ self.indexing_results_output_field,
2114
+ self.debug_log_output_field_indexing_tab,
2115
+ self.preprocessing_output_field,
2116
+ self.preprocessing_results_output_field,
2117
+ self.debug_log_output_field_preprocess_tab,
2118
+ self.translator_translated_text_output_field,
2119
+ self.translator_je_check_text_output_field,
2120
+ self.translator_debug_log_output_field,
2121
+ self.logging_tab_debug_log_output_field,
2122
+ self.logging_tab_error_log_output_field
2123
+ ],
2124
+ outputs=[],
2125
+ js=(self.js_save_to_zip)
2126
  )
2127
 
2128
  ##-------------------start-of-send_to_x_click()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
2134
  self.send_to_translator_button.click(fn=send_to_translator_button,
2135
  inputs=[self.preprocessing_output_field],
2136
  outputs=[self.input_text_translator])
2137
+
2138
+ ##-------------------start-of-toggle_inputs()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2139
+
2140
+ def toggle_knowledge_base_inputs(file_input, dir_input):
2141
+ return gr.update(interactive=not bool(file_input)), gr.update(interactive=not bool(dir_input))
2142
+
2143
+ self.input_knowledge_base_file.change(
2144
+ toggle_knowledge_base_inputs,
2145
+ inputs=[self.input_knowledge_base_file, self.input_knowledge_base_directory],
2146
+ outputs=[self.input_knowledge_base_directory, self.input_knowledge_base_file]
2147
+ )
2148
+
2149
+ self.input_knowledge_base_directory.change(
2150
+ toggle_knowledge_base_inputs,
2151
+ inputs=[self.input_knowledge_base_file, self.input_knowledge_base_directory],
2152
+ outputs=[self.input_knowledge_base_directory, self.input_knowledge_base_file]
2153
+ )
2154
+
2155
+ def toggle_text_inputs(file_input, text_input):
2156
+ current_time = time.time()
2157
+ if current_time - KudasaiGUI.last_text_change < KudasaiGUI.debounce_delay:
2158
+ # If it's a text change and we're within the debounce period, don't update
2159
+ return gr.update(), gr.update()
2160
+ self.last_text_change = current_time
2161
+ return gr.update(placeholder=""), gr.update(interactive=not bool(file_input)), gr.update(interactive=not bool(text_input))
2162
+
2163
+
2164
+ ## For preprocessor
2165
+ self.input_txt_file_preprocessing.change(
2166
+ toggle_text_inputs,
2167
+ inputs=[self.input_txt_file_preprocessing, self.input_text_kairyou],
2168
+ outputs=[self.input_text_kairyou, self.input_txt_file_preprocessing]
2169
+ )
2170
+
2171
+ self.input_text_kairyou.change(
2172
+ toggle_text_inputs,
2173
+ inputs=[self.input_txt_file_preprocessing, self.input_text_kairyou],
2174
+ outputs=[self.input_text_kairyou, self.input_txt_file_preprocessing]
2175
+ )
2176
+
2177
+ ## For translator
2178
+ self.input_txt_file_translator.change(
2179
+ toggle_text_inputs,
2180
+ inputs=[self.input_txt_file_translator, self.input_text_translator],
2181
+ outputs=[self.input_text_translator, self.input_txt_file_translator]
2182
+ )
2183
+
2184
+ self.input_text_translator.change(
2185
+ toggle_text_inputs,
2186
+ inputs=[self.input_txt_file_translator, self.input_text_translator],
2187
+ outputs=[self.input_text_translator, self.input_txt_file_translator]
2188
+ )
2189
 
2190
  ##-------------------start-of-launch()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2191