Spaces:
Running
Running
feat: deploy latest SNAP Gradio SDK demo connected to snap_cpp
Browse files
app.py
CHANGED
|
@@ -136,7 +136,7 @@ def run_inference(text: str, lang: str):
|
|
| 136 |
err = f"Inference Error: {str(e)}"
|
| 137 |
return err, err, err
|
| 138 |
|
| 139 |
-
# Clean
|
| 140 |
CSS = """
|
| 141 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 142 |
|
|
@@ -193,6 +193,18 @@ body, .gradio-container {
|
|
| 193 |
background: #388bfd !important;
|
| 194 |
}
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
.mono-output textarea {
|
| 197 |
font-family: 'JetBrains Mono', monospace !important;
|
| 198 |
background: #0d1117 !important;
|
|
@@ -209,7 +221,7 @@ body, .gradio-container {
|
|
| 209 |
text-align: left !important;
|
| 210 |
font-size: 12px !important;
|
| 211 |
padding: 8px 10px !important;
|
| 212 |
-
margin-bottom:
|
| 213 |
width: 100% !important;
|
| 214 |
}
|
| 215 |
|
|
@@ -285,32 +297,34 @@ with gr.Blocks(css=CSS, title="SNAP Semantic Text Normalization Live Demo") as d
|
|
| 285 |
show_copy_button=True
|
| 286 |
)
|
| 287 |
|
| 288 |
-
# Bottom Full-Width Panel: Quick Test Cases
|
| 289 |
with gr.Column(elem_classes=["section-card"]):
|
| 290 |
-
gr.Markdown("### 💡 Quick Test Cases")
|
| 291 |
|
| 292 |
with gr.Row():
|
| 293 |
-
#
|
| 294 |
with gr.Column(scale=1):
|
| 295 |
gr.Markdown("**🇰🇷 한국어 (KO)**")
|
| 296 |
ex_k1 = gr.Button("• 100달러를 환전하고 3.5km를 걸었습니다.", elem_classes=["example-btn"])
|
| 297 |
-
ex_k2 = gr.Button("•
|
| 298 |
-
ex_k3 = gr.Button("•
|
| 299 |
-
ex_k4 = gr.Button("•
|
| 300 |
-
|
| 301 |
-
# Column 2: English
|
| 302 |
-
with gr.Column(scale=1):
|
| 303 |
-
gr.Markdown("**🇺🇸 영어 (EN)**")
|
| 304 |
-
ex_e1 = gr.Button("• It costs $50.75 for 3 items on Jan 15th, 2025.", elem_classes=["example-btn"])
|
| 305 |
-
ex_e2 = gr.Button("• Flight AA123 arrives at 10:45 AM on Gate B12.", elem_classes=["example-btn"])
|
| 306 |
-
ex_e3 = gr.Button("• The temperature dropped to -5.5°C with 80% humidity.", elem_classes=["example-btn"])
|
| 307 |
-
ex_e4 = gr.Button("• Call us at +1 (555) 019-2834 or visit room 404.", elem_classes=["example-btn"])
|
| 308 |
|
| 309 |
-
#
|
| 310 |
with gr.Column(scale=1):
|
| 311 |
gr.Markdown("**🇯🇵 일본어 (JA)**")
|
| 312 |
ex_j1 = gr.Button("• 昭和58年4月15日, 東京ディズニーランドが開業した。", elem_classes=["example-btn"])
|
| 313 |
-
ex_j2 = gr.Button("•
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
|
| 315 |
# Event Handlers
|
| 316 |
btn_submit.click(
|
|
@@ -321,17 +335,19 @@ with gr.Blocks(css=CSS, title="SNAP Semantic Text Normalization Live Demo") as d
|
|
| 321 |
|
| 322 |
# Test Case Wire-up
|
| 323 |
ex_k1.click(lambda: ("100달러를 환전하고 3.5km를 걸었습니다.", "ko"), outputs=[input_text, language])
|
| 324 |
-
ex_k2.click(lambda: ("
|
| 325 |
-
ex_k3.click(lambda: ("
|
| 326 |
-
ex_k4.click(lambda: ("
|
| 327 |
|
| 328 |
-
ex_e1.click(lambda: ("It costs $50.75 for 3 items on Jan 15th, 2025.", "en"), outputs=[input_text, language])
|
| 329 |
-
ex_e2.click(lambda: ("Flight AA123 arrives at 10:45 AM on Gate B12.", "en"), outputs=[input_text, language])
|
| 330 |
-
ex_e3.click(lambda: ("The temperature dropped to -5.5°C with 80% humidity.", "en"), outputs=[input_text, language])
|
| 331 |
-
ex_e4.click(lambda: ("Call us at +1 (555) 019-2834 or visit room 404.", "en"), outputs=[input_text, language])
|
| 332 |
-
|
| 333 |
ex_j1.click(lambda: ("昭和58年4月15日, 東京ディズニーランドが開業した。", "ja"), outputs=[input_text, language])
|
| 334 |
-
ex_j2.click(lambda: ("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
# Footer
|
| 337 |
gr.HTML("""
|
|
|
|
| 136 |
err = f"Inference Error: {str(e)}"
|
| 137 |
return err, err, err
|
| 138 |
|
| 139 |
+
# Clean Blue-themed Custom CSS
|
| 140 |
CSS = """
|
| 141 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 142 |
|
|
|
|
| 193 |
background: #388bfd !important;
|
| 194 |
}
|
| 195 |
|
| 196 |
+
/* Radio button active/selected state in Blue theme */
|
| 197 |
+
.gradio-container input[type="radio"]:checked,
|
| 198 |
+
.gradio-container label.selected {
|
| 199 |
+
background-color: rgba(31, 111, 235, 0.2) !important;
|
| 200 |
+
border-color: #388bfd !important;
|
| 201 |
+
color: #58a6ff !important;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
.gradio-container label input[type="radio"]:checked {
|
| 205 |
+
accent-color: #1f6feb !important;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
.mono-output textarea {
|
| 209 |
font-family: 'JetBrains Mono', monospace !important;
|
| 210 |
background: #0d1117 !important;
|
|
|
|
| 221 |
text-align: left !important;
|
| 222 |
font-size: 12px !important;
|
| 223 |
padding: 8px 10px !important;
|
| 224 |
+
margin-bottom: 6px !important;
|
| 225 |
width: 100% !important;
|
| 226 |
}
|
| 227 |
|
|
|
|
| 297 |
show_copy_button=True
|
| 298 |
)
|
| 299 |
|
| 300 |
+
# Bottom Full-Width Panel: Quick Test Cases Split 3-Columns (KO / JA / EN)
|
| 301 |
with gr.Column(elem_classes=["section-card"]):
|
| 302 |
+
gr.Markdown("### 💡 Quick Test Cases (Semantic Context & Heteronym Examples)")
|
| 303 |
|
| 304 |
with gr.Row():
|
| 305 |
+
# 1. Korean Column
|
| 306 |
with gr.Column(scale=1):
|
| 307 |
gr.Markdown("**🇰🇷 한국어 (KO)**")
|
| 308 |
ex_k1 = gr.Button("• 100달러를 환전하고 3.5km를 걸었습니다.", elem_classes=["example-btn"])
|
| 309 |
+
ex_k2 = gr.Button("• 2월 2일 2시에 2번 출구에서 2명과 만남.", elem_classes=["example-btn"])
|
| 310 |
+
ex_k3 = gr.Button("• 사과 3개와 차 2대를 사서 101호로 갔다.", elem_classes=["example-btn"])
|
| 311 |
+
ex_k4 = gr.Button("• 길가에 피어난 꽃을 보고 눈물을 흘렸다.", elem_classes=["example-btn"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
+
# 2. Japanese Column
|
| 314 |
with gr.Column(scale=1):
|
| 315 |
gr.Markdown("**🇯🇵 일본어 (JA)**")
|
| 316 |
ex_j1 = gr.Button("• 昭和58年4月15日, 東京ディズニーランドが開業した。", elem_classes=["example-btn"])
|
| 317 |
+
ex_j2 = gr.Button("• 1日と2日に1人で9日間旅行した。", elem_classes=["example-btn"])
|
| 318 |
+
ex_j3 = gr.Button("• 角を曲がると角が生えた鬼がいた。", elem_classes=["example-btn"])
|
| 319 |
+
ex_j4 = gr.Button("• 午後7時30分に渋谷駅ハチ公前で会いましょう。", elem_classes=["example-btn"])
|
| 320 |
+
|
| 321 |
+
# 3. English Column
|
| 322 |
+
with gr.Column(scale=1):
|
| 323 |
+
gr.Markdown("**🇺🇸 영어 (EN)**")
|
| 324 |
+
ex_e1 = gr.Button("• I read the book yesterday and read it again today.", elem_classes=["example-btn"])
|
| 325 |
+
ex_e2 = gr.Button("• The lead pipe was used to lead the team.", elem_classes=["example-btn"])
|
| 326 |
+
ex_e3 = gr.Button("• It costs $50.75 for 3 items on Jan 15th, 2025.", elem_classes=["example-btn"])
|
| 327 |
+
ex_e4 = gr.Button("• Flight AA123 arrives at 10:45 AM on Gate B12.", elem_classes=["example-btn"])
|
| 328 |
|
| 329 |
# Event Handlers
|
| 330 |
btn_submit.click(
|
|
|
|
| 335 |
|
| 336 |
# Test Case Wire-up
|
| 337 |
ex_k1.click(lambda: ("100달러를 환전하고 3.5km를 걸었습니다.", "ko"), outputs=[input_text, language])
|
| 338 |
+
ex_k2.click(lambda: ("2월 2일 2시에 2번 출구에서 2명과 만남.", "ko"), outputs=[input_text, language])
|
| 339 |
+
ex_k3.click(lambda: ("사과 3개와 차 2대를 사서 101호로 갔다.", "ko"), outputs=[input_text, language])
|
| 340 |
+
ex_k4.click(lambda: ("길가에 피어난 꽃을 보고 눈물을 흘렸다.", "ko"), outputs=[input_text, language])
|
| 341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
ex_j1.click(lambda: ("昭和58年4月15日, 東京ディズニーランドが開業した。", "ja"), outputs=[input_text, language])
|
| 343 |
+
ex_j2.click(lambda: ("1日と2日に1人で9日間旅行した。", "ja"), outputs=[input_text, language])
|
| 344 |
+
ex_j3.click(lambda: ("角を曲がると角が生えた鬼がいた。", "ja"), outputs=[input_text, language])
|
| 345 |
+
ex_j4.click(lambda: ("午後7時30分に渋谷駅ハチ公前で会いましょう。", "ja"), outputs=[input_text, language])
|
| 346 |
+
|
| 347 |
+
ex_e1.click(lambda: ("I read the book yesterday and read it again today.", "en"), outputs=[input_text, language])
|
| 348 |
+
ex_e2.click(lambda: ("The lead pipe was used to lead the team.", "en"), outputs=[input_text, language])
|
| 349 |
+
ex_e3.click(lambda: ("It costs $50.75 for 3 items on Jan 15th, 2025.", "en"), outputs=[input_text, language])
|
| 350 |
+
ex_e4.click(lambda: ("Flight AA123 arrives at 10:45 AM on Gate B12.", "en"), outputs=[input_text, language])
|
| 351 |
|
| 352 |
# Footer
|
| 353 |
gr.HTML("""
|