Spaces:
Sleeping
Sleeping
Reduce Frequently Init Conveter
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from opencc import OpenCC
|
|
6 |
with open("config.json", "rt", encoding="UTF-8") as fp:
|
7 |
config: dict = json.load(fp)
|
8 |
|
9 |
-
rev_config = {f"{v} ({k})": k for k, v in config.items()}
|
10 |
rev_config_keys = list(rev_config.keys())
|
11 |
|
12 |
title = "簡繁轉換小工具 OpenCC Converter"
|
@@ -31,8 +31,7 @@ with gr.Blocks(title=title, theme=theme) as app:
|
|
31 |
gr.Markdown("Powered By [OpenCC](https://github.com/BYVoid/OpenCC)")
|
32 |
|
33 |
def convert(inn, opt):
|
34 |
-
|
35 |
-
return conv.convert(inn)
|
36 |
|
37 |
args = (convert, [inn_text, options], [out_text])
|
38 |
kwargs = {"show_progress": "hidden", "queue": False}
|
|
|
6 |
with open("config.json", "rt", encoding="UTF-8") as fp:
|
7 |
config: dict = json.load(fp)
|
8 |
|
9 |
+
rev_config = {f"{v} ({k})": OpenCC(k) for k, v in config.items()}
|
10 |
rev_config_keys = list(rev_config.keys())
|
11 |
|
12 |
title = "簡繁轉換小工具 OpenCC Converter"
|
|
|
31 |
gr.Markdown("Powered By [OpenCC](https://github.com/BYVoid/OpenCC)")
|
32 |
|
33 |
def convert(inn, opt):
|
34 |
+
return rev_config[opt].convert(inn)
|
|
|
35 |
|
36 |
args = (convert, [inn_text, options], [out_text])
|
37 |
kwargs = {"show_progress": "hidden", "queue": False}
|