Update app.py
Browse files
app.py
CHANGED
|
@@ -196,7 +196,7 @@ def _person_of_doc(doc, src_lang: str) -> Optional[str]:
|
|
| 196 |
root = next((t for t in doc if t.dep_=="ROOT"), doc[0])
|
| 197 |
subj = next((t for t in root.children if t.dep_.startswith("nsubj")), None)
|
| 198 |
if subj is None: return None
|
| 199 |
-
plur = ("Number=Plur" in str(subj.morph)) if src_lang=="Español" else (subj.tag_ in ("
|
| 200 |
low = subj.lower_
|
| 201 |
if src_lang=="Español":
|
| 202 |
if low in ("yo",): return "1p" if plur else "1s"
|
|
@@ -633,7 +633,8 @@ def round_trip(text, src, tgt, mode, max_comp_exact):
|
|
| 633 |
|
| 634 |
# ====================== UI simple (pestañas + 3 casillas) ======================
|
| 635 |
|
| 636 |
-
|
|
|
|
| 637 |
## ¿Qué hace esta app? (versión fácil)
|
| 638 |
Convierte frases entre **Español / Inglés** y dos lenguajes inventados (conlangs):
|
| 639 |
- **Minimax-ASCII**: versión compacta con letras normales (ASCII).
|
|
@@ -668,11 +669,54 @@ Convierte frases entre **Español / Inglés** y dos lenguajes inventados (conlan
|
|
| 668 |
- ¿Dudas? Prueba **ida→vuelta**.
|
| 669 |
"""
|
| 670 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
ALL_LANGS = ["Español","English","Minimax-ASCII","Kōmín-CJK"]
|
| 672 |
|
| 673 |
with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as demo:
|
| 674 |
gr.Markdown("# 🌐 Universal Conlang Translator")
|
| 675 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
|
| 677 |
# --- Traducir (universal) ---
|
| 678 |
with gr.Tab("Traducir / Translate"):
|
|
@@ -748,3 +792,4 @@ with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as
|
|
| 748 |
if __name__ == "__main__":
|
| 749 |
demo.launch()
|
| 750 |
|
|
|
|
|
|
| 196 |
root = next((t for t in doc if t.dep_=="ROOT"), doc[0])
|
| 197 |
subj = next((t for t in root.children if t.dep_.startswith("nsubj")), None)
|
| 198 |
if subj is None: return None
|
| 199 |
+
plur = ("Number=Plur" in str(subj.morph)) if src_lang=="Español" else (subj.tag_ in ("NNS","NNPS"))
|
| 200 |
low = subj.lower_
|
| 201 |
if src_lang=="Español":
|
| 202 |
if low in ("yo",): return "1p" if plur else "1s"
|
|
|
|
| 633 |
|
| 634 |
# ====================== UI simple (pestañas + 3 casillas) ======================
|
| 635 |
|
| 636 |
+
# NUEVO: explicación bilingüe con selector ES/EN (no afecta a la lógica)
|
| 637 |
+
EXPLAIN_TOP_ES = """
|
| 638 |
## ¿Qué hace esta app? (versión fácil)
|
| 639 |
Convierte frases entre **Español / Inglés** y dos lenguajes inventados (conlangs):
|
| 640 |
- **Minimax-ASCII**: versión compacta con letras normales (ASCII).
|
|
|
|
| 669 |
- ¿Dudas? Prueba **ida→vuelta**.
|
| 670 |
"""
|
| 671 |
|
| 672 |
+
EXPLAIN_TOP_EN = """
|
| 673 |
+
## What does this app do? (simple)
|
| 674 |
+
It converts sentences between **Spanish / English** and two constructed languages (conlangs):
|
| 675 |
+
- **Minimax-ASCII**: compact, ASCII-only style.
|
| 676 |
+
- **Kōmín-CJK**: compact output with CJK-like symbols.
|
| 677 |
+
|
| 678 |
+
### What is it for?
|
| 679 |
+
- To **shrink** messages while keeping their meaning.
|
| 680 |
+
- To **encode** and later **recover** the exact original text if you want.
|
| 681 |
+
|
| 682 |
+
---
|
| 683 |
+
|
| 684 |
+
## The 4 tabs (buttons)
|
| 685 |
+
1) **Translate** — Convert **any** system to **any** other (ES, EN, Minimax, Kōmín).
|
| 686 |
+
2) **Build (ES/EN → Conlang)** — Take your natural sentence and build its **compact** version (Minimax/Kōmín) with options.
|
| 687 |
+
3) **Decode (Conlang → ES/EN)** — Paste Minimax/Kōmín and get Spanish or English back. If it includes `~...`, you get the **exact original**.
|
| 688 |
+
4) **Round-trip test** — Go to the conlang and back to your language to verify the result.
|
| 689 |
+
|
| 690 |
+
---
|
| 691 |
+
|
| 692 |
+
## The 3 checkboxes (simple options)
|
| 693 |
+
- **Drop articles**: remove “el/la/los/las” or “a/an/the” → often saves ~10–15%.
|
| 694 |
+
- **Zero copula (present affirmative)**: hide “ser/estar/be” where natural → +~5–10%.
|
| 695 |
+
- **Max Exact Compression**: appends `~...` with your **compressed** original text. When decoding, if present, you get the **exact original** back.
|
| 696 |
+
Note: for **very short** texts it might not reduce size because of the `~...` header.
|
| 697 |
+
|
| 698 |
+
---
|
| 699 |
+
|
| 700 |
+
## Quick tips
|
| 701 |
+
- If unsure, use **Translate**.
|
| 702 |
+
- To **compact**, use **Build** and tick what you want.
|
| 703 |
+
- If someone sends you conlang, use **Decode**.
|
| 704 |
+
- Not sure? Try **round-trip**.
|
| 705 |
+
"""
|
| 706 |
+
|
| 707 |
ALL_LANGS = ["Español","English","Minimax-ASCII","Kōmín-CJK"]
|
| 708 |
|
| 709 |
with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft()) as demo:
|
| 710 |
gr.Markdown("# 🌐 Universal Conlang Translator")
|
| 711 |
+
|
| 712 |
+
# Selector de idioma para la explicación (solo UI de texto)
|
| 713 |
+
lang_ui = gr.Radio(choices=["ES", "EN"], value="ES", label="Idioma de la explicación / Explanation language")
|
| 714 |
+
explain_md = gr.Markdown(EXPLAIN_TOP_ES)
|
| 715 |
+
|
| 716 |
+
def _set_explain(lang):
|
| 717 |
+
return gr.update(value=EXPLAIN_TOP_ES if lang == "ES" else EXPLAIN_TOP_EN)
|
| 718 |
+
|
| 719 |
+
lang_ui.change(_set_explain, inputs=[lang_ui], outputs=[explain_md])
|
| 720 |
|
| 721 |
# --- Traducir (universal) ---
|
| 722 |
with gr.Tab("Traducir / Translate"):
|
|
|
|
| 792 |
if __name__ == "__main__":
|
| 793 |
demo.launch()
|
| 794 |
|
| 795 |
+
|