Spaces:
Runtime error
Runtime error
Teddy Xinyuan Chen
commited on
2024-05-10T12-11-18Z
Browse files
app.py
CHANGED
@@ -1,12 +1,20 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from taibun import Converter
|
3 |
|
4 |
|
5 |
def convert_text(text, system="Tailo", dialect="south", format="mark", sandhi="none"):
|
6 |
# Create a converter object with selected options
|
7 |
converter = Converter(system=system, dialect=dialect, format=format, sandhi=sandhi)
|
8 |
-
#
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
# Define the interface
|
@@ -29,7 +37,11 @@ interface = gr.Interface(
|
|
29 |
value="none",
|
30 |
),
|
31 |
],
|
32 |
-
outputs=[
|
|
|
|
|
|
|
|
|
33 |
title="Hokkien Transliteration Converter",
|
34 |
description="Convert Hokkien text between various transliteration systems using the <a href='https://github.com/andreihar/taibun' target='_blank'>taibun</a> package. Made by <a href='https://teddysc.me'>Teddy</a>.",
|
35 |
)
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
|
3 |
import gradio as gr
|
4 |
+
from taibun import Converter, to_simplified, to_traditional
|
5 |
|
6 |
|
7 |
def convert_text(text, system="Tailo", dialect="south", format="mark", sandhi="none"):
|
8 |
# Create a converter object with selected options
|
9 |
converter = Converter(system=system, dialect=dialect, format=format, sandhi=sandhi)
|
10 |
+
# Convert the text using the specified transliteration system
|
11 |
+
converted_text = converter.get(text)
|
12 |
+
# Convert to simplified Chinese characters
|
13 |
+
simplified_text = to_simplified(converted_text)
|
14 |
+
# Convert to traditional Chinese characters
|
15 |
+
traditional_text = to_traditional(converted_text)
|
16 |
+
# Return the tuple containing all conversion results
|
17 |
+
return converted_text, simplified_text, traditional_text
|
18 |
|
19 |
|
20 |
# Define the interface
|
|
|
37 |
value="none",
|
38 |
),
|
39 |
],
|
40 |
+
outputs=[
|
41 |
+
gr.Textbox(label="Converted Text"),
|
42 |
+
gr.Textbox(label="Simplified Chinese"),
|
43 |
+
gr.Textbox(label="Traditional Chinese"),
|
44 |
+
],
|
45 |
title="Hokkien Transliteration Converter",
|
46 |
description="Convert Hokkien text between various transliteration systems using the <a href='https://github.com/andreihar/taibun' target='_blank'>taibun</a> package. Made by <a href='https://teddysc.me'>Teddy</a>.",
|
47 |
)
|