Update app.py
Browse files
app.py
CHANGED
|
@@ -466,6 +466,38 @@ EXPLAIN_TAB_ROUNDTRIP_EN = "Runs **(ES/EN→Conlang)→(Conlang→ES/EN)** to ve
|
|
| 466 |
EXPLAIN_CHECKBOX_EN = "Drop articles ~10–15%, Zero copula ~5–10% extra, Remove pronouns variable, Max Exact 40–60% for >100 chars."
|
| 467 |
LEXICON_FRIENDLY_EN = "We use **WordNet (OMW)**, pair ES words with EN, clean & sort by frequency, assign short **codes** (Minimax/Kōmín), and save three JSONs so the app can encode/decode compactly."
|
| 468 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
# ---------- Utilidades de compactación y vista previa ----------
|
| 470 |
def _pct_comp(original: str, result: str) -> float:
|
| 471 |
if not original: return 0.0
|
|
@@ -605,6 +637,14 @@ with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as
|
|
| 605 |
gr.Markdown("## 🌍 Idioma / Language")
|
| 606 |
lang = gr.Radio(["ES","EN"], value="ES", label="Selecciona / Select")
|
| 607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
# Acordeones intro + léxico (mismo nivel)
|
| 609 |
acc_intro_es = gr.Accordion("☑️ Opciones y compactación — guía rápida (ES)", open=False, visible=True)
|
| 610 |
with acc_intro_es: gr.Markdown(EXPLAIN_CHECKBOX_ES)
|
|
@@ -656,6 +696,7 @@ with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as
|
|
| 656 |
# Accordions ES/EN
|
| 657 |
vis_es = not is_en; vis_en = is_en
|
| 658 |
updates = [
|
|
|
|
| 659 |
_vis(vis_es), _vis(vis_en), # intro accordions
|
| 660 |
_vis(vis_es), _vis(vis_en), # lexicon accordions
|
| 661 |
]
|
|
@@ -675,6 +716,7 @@ with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as
|
|
| 675 |
switch_everything,
|
| 676 |
[lang, cb_tr, cb_bu, cb_de, cb_rt],
|
| 677 |
[
|
|
|
|
| 678 |
acc_intro_es, acc_intro_en, acc_lex_es, acc_lex_en,
|
| 679 |
panel_tr_es, panel_bu_es, panel_de_es, panel_rt_es,
|
| 680 |
panel_tr_en, panel_bu_en, panel_de_en, panel_rt_en,
|
|
@@ -687,6 +729,7 @@ with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as
|
|
| 687 |
switch_everything,
|
| 688 |
[lang, cb_tr, cb_bu, cb_de, cb_rt],
|
| 689 |
[
|
|
|
|
| 690 |
acc_intro_es, acc_intro_en, acc_lex_es, acc_lex_en,
|
| 691 |
panel_tr_es, panel_bu_es, panel_de_es, panel_rt_es,
|
| 692 |
panel_tr_en, panel_bu_en, panel_de_en, panel_rt_en,
|
|
@@ -704,3 +747,4 @@ if __name__ == "__main__":
|
|
| 704 |
|
| 705 |
|
| 706 |
|
|
|
|
|
|
| 466 |
EXPLAIN_CHECKBOX_EN = "Drop articles ~10–15%, Zero copula ~5–10% extra, Remove pronouns variable, Max Exact 40–60% for >100 chars."
|
| 467 |
LEXICON_FRIENDLY_EN = "We use **WordNet (OMW)**, pair ES words with EN, clean & sort by frequency, assign short **codes** (Minimax/Kōmín), and save three JSONs so the app can encode/decode compactly."
|
| 468 |
|
| 469 |
+
# >>> NUEVO <<< ——— Explicación directa de los “botones / modos” (ES/EN)
|
| 470 |
+
EXPLAIN_MODES_ES = """
|
| 471 |
+
**¿Qué hace cada botón / modo?** *(Marca uno en “🧭 Modo de uso”)*
|
| 472 |
+
|
| 473 |
+
- **🔁 Traducir**: Convierte lo que escribes en **Texto** al **Destino** que elijas (ES/EN/Minimax/Kōmín).
|
| 474 |
+
Si el **Destino** es conlang, puedes activar **Omitir artículos**, **Cópula cero**, **Quitar pronombres** y **Máx. Compresión Exacta**.
|
| 475 |
+
Abajo verás el **% de compactación** “base” (sin casillas) y “con tus opciones”.
|
| 476 |
+
|
| 477 |
+
- **🛠️ Construir (ES/EN → Conlang)**: Obliga a que la salida sea **Minimax** o **Kōmín** (desde Español o Inglés).
|
| 478 |
+
Aplica **reglas del conlang** (orden/partículas) y las **opciones de compactación**.
|
| 479 |
+
|
| 480 |
+
- **🗝️ Decodificar (Conlang → ES/EN)**: Pega texto en **Minimax/Kōmín** y obtén **Español** o **Inglés**.
|
| 481 |
+
Si el texto trae **`~...`**, se devuelve el **original exacto**. Sin `~...`, se reconstruye de forma **semi-lossless**.
|
| 482 |
+
|
| 483 |
+
- **🔄 Prueba ida→vuelta**: Hace **(ES/EN → Conlang) → (Conlang → ES/EN)** para comprobar la **reversibilidad**.
|
| 484 |
+
Con **Máx. Compresión Exacta**, la vuelta coincide **bit a bit**.
|
| 485 |
+
"""
|
| 486 |
+
EXPLAIN_MODES_EN = """
|
| 487 |
+
**What does each button / mode do?** *(Tick one in “🧭 Mode”)*
|
| 488 |
+
|
| 489 |
+
- **🔁 Translate**: Converts **Text** to your **Target** (ES/EN/Minimax/Kōmín).
|
| 490 |
+
If the **Target** is a conlang, you can enable **Drop articles**, **Zero copula**, **Remove pronouns**, and **Max Exact Compression**.
|
| 491 |
+
Below you’ll see **compaction %** for the **base** (no options) and **your options**.
|
| 492 |
+
|
| 493 |
+
- **🛠️ Build (ES/EN → Conlang)**: Forces output in **Minimax** or **Kōmín** (from ES/EN), applying conlang phrasing and **compaction** options.
|
| 494 |
+
|
| 495 |
+
- **🗝️ Decode (Conlang → ES/EN)**: Paste **Minimax/Kōmín** and get **Spanish** or **English**.
|
| 496 |
+
If it ends with **`~...`**, you get the **bit-perfect original**. Otherwise, it reconstructs **semi-losslessly**.
|
| 497 |
+
|
| 498 |
+
- **🔄 Round-trip**: Runs **(ES/EN → Conlang) → (Conlang → ES/EN)** to check **reversibility**. With **Max Exact**, it’s bit-for-bit.
|
| 499 |
+
"""
|
| 500 |
+
|
| 501 |
# ---------- Utilidades de compactación y vista previa ----------
|
| 502 |
def _pct_comp(original: str, result: str) -> float:
|
| 503 |
if not original: return 0.0
|
|
|
|
| 637 |
gr.Markdown("## 🌍 Idioma / Language")
|
| 638 |
lang = gr.Radio(["ES","EN"], value="ES", label="Selecciona / Select")
|
| 639 |
|
| 640 |
+
# >>> NUEVO <<< — Acordeones con explicación de los botones/modos (mismo nivel)
|
| 641 |
+
acc_modes_es = gr.Accordion("📖 ¿Qué hace cada botón / modo? (ES)", open=False, visible=True)
|
| 642 |
+
with acc_modes_es:
|
| 643 |
+
gr.Markdown(EXPLAIN_MODES_ES)
|
| 644 |
+
acc_modes_en = gr.Accordion("📖 What does each button / mode do? (EN)", open=False, visible=False)
|
| 645 |
+
with acc_modes_en:
|
| 646 |
+
gr.Markdown(EXPLAIN_MODES_EN)
|
| 647 |
+
|
| 648 |
# Acordeones intro + léxico (mismo nivel)
|
| 649 |
acc_intro_es = gr.Accordion("☑️ Opciones y compactación — guía rápida (ES)", open=False, visible=True)
|
| 650 |
with acc_intro_es: gr.Markdown(EXPLAIN_CHECKBOX_ES)
|
|
|
|
| 696 |
# Accordions ES/EN
|
| 697 |
vis_es = not is_en; vis_en = is_en
|
| 698 |
updates = [
|
| 699 |
+
_vis(vis_es), _vis(vis_en), # >>> NUEVO <<< acc_modes_es, acc_modes_en
|
| 700 |
_vis(vis_es), _vis(vis_en), # intro accordions
|
| 701 |
_vis(vis_es), _vis(vis_en), # lexicon accordions
|
| 702 |
]
|
|
|
|
| 716 |
switch_everything,
|
| 717 |
[lang, cb_tr, cb_bu, cb_de, cb_rt],
|
| 718 |
[
|
| 719 |
+
acc_modes_es, acc_modes_en, # >>> NUEVO <<<
|
| 720 |
acc_intro_es, acc_intro_en, acc_lex_es, acc_lex_en,
|
| 721 |
panel_tr_es, panel_bu_es, panel_de_es, panel_rt_es,
|
| 722 |
panel_tr_en, panel_bu_en, panel_de_en, panel_rt_en,
|
|
|
|
| 729 |
switch_everything,
|
| 730 |
[lang, cb_tr, cb_bu, cb_de, cb_rt],
|
| 731 |
[
|
| 732 |
+
acc_modes_es, acc_modes_en, # >>> NUEVO <<<
|
| 733 |
acc_intro_es, acc_intro_en, acc_lex_es, acc_lex_en,
|
| 734 |
panel_tr_es, panel_bu_es, panel_de_es, panel_rt_es,
|
| 735 |
panel_tr_en, panel_bu_en, panel_de_en, panel_rt_en,
|
|
|
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
+
|