Spaces:
Runtime error
Runtime error
Teddy Xinyuan Chen
commited on
2024-05-10T11-52-05Z
Browse files- .gitignore +1 -0
- main.py +26 -0
- requirements.txt +2 -0
.gitignore
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
# Byte-compiled / optimized / DLL files
|
| 2 |
__pycache__/
|
| 3 |
*.py[cod]
|
|
|
|
| 1 |
+
flagged
|
| 2 |
# Byte-compiled / optimized / DLL files
|
| 3 |
__pycache__/
|
| 4 |
*.py[cod]
|
main.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from taibun import Converter # Assuming the taibun package provides a Converter class
|
| 3 |
+
|
| 4 |
+
def convert_text(text, system, dialect, format, sandhi):
|
| 5 |
+
# Create a converter object with selected options
|
| 6 |
+
converter = Converter(system=system, dialect=dialect, format=format, sandhi=sandhi)
|
| 7 |
+
# Return the converted text
|
| 8 |
+
return converter.get(text)
|
| 9 |
+
|
| 10 |
+
# Define the interface
|
| 11 |
+
interface = gr.Interface(
|
| 12 |
+
fn=convert_text,
|
| 13 |
+
inputs=[
|
| 14 |
+
gr.Textbox(label="Enter Taiwanese Hokkien text"),
|
| 15 |
+
gr.Dropdown(choices=["Tailo", "POJ", "Zhuyin", "TLPA", "Pingyim", "Tongiong", "IPA"], label="System"),
|
| 16 |
+
gr.Dropdown(choices=["south", "north"], label="Dialect"),
|
| 17 |
+
gr.Dropdown(choices=["mark", "number", "strip"], label="Tone Format"),
|
| 18 |
+
gr.Dropdown(choices=["none", "auto", "exc_last", "incl_last"], label="Tone Sandhi"),
|
| 19 |
+
],
|
| 20 |
+
outputs=[gr.Textbox(label="Converted Text")],
|
| 21 |
+
title="Taiwanese Hokkien Transliteration Converter",
|
| 22 |
+
description="Convert Taiwanese Hokkien text between various transliteration systems using the Taibun package."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch the app
|
| 26 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
taibun
|
| 2 |
+
gradio
|