Update app.py
Browse files
app.py
CHANGED
|
@@ -364,7 +364,7 @@ def _es_conj(lemma, tense, person):
|
|
| 364 |
return tab[tense].get(person, tab[tense]["3s"])
|
| 365 |
if lemma=="estar":
|
| 366 |
tab={"Pres":{"1s":"estoy","2s":"estás","3s":"está","1p":"estamos","2p":"estáis","3p":"están"},
|
| 367 |
-
"Past":{"1s":"
|
| 368 |
"Fut":{"1s":"estaré","2s":"estarás","3s":"estará","1p":"estaremos","2p":"estaréis","3p":"estarán"}}
|
| 369 |
return tab[tense].get(person, tab[tense]["3s"])
|
| 370 |
if lemma=="ir":
|
|
@@ -496,59 +496,10 @@ EXPLAIN_CHECKBOX_ES = """
|
|
| 496 |
"""
|
| 497 |
# ¿Qué son los lenguajes?
|
| 498 |
EXPLAIN_CONLANGS_ES = """
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
**
|
| 503 |
-
|
| 504 |
-
---
|
| 505 |
-
|
| 506 |
-
#### 1) Minimax-ASCII (compacto y tecleable)
|
| 507 |
-
- Usa **sólo ASCII**, así que funciona en cualquier sitio (correo, móvil, código).
|
| 508 |
-
- Cada **palabra** se cambia por un **código corto** (por frecuencia, lo común es más corto).
|
| 509 |
-
- Los **verbos** llevan una colita con marcas:
|
| 510 |
-
- **·P / ·T / ·F** → Presente / Pasado / Futuro
|
| 511 |
-
- **1s, 2p, 3s…** → Persona y número (1=yo/nosotros, 2=tú/vosotros, 3=él/ellos; s=singular, p=plural)
|
| 512 |
-
- **N** → negación; **Q** → pregunta
|
| 513 |
-
- **Ejemplo**: “**¿Estás bien?**” → `k·P2sQ` (estar, Presente, 2ª persona, pregunta)
|
| 514 |
-
|
| 515 |
-
**Cuándo usarlo**: si quieres **máxima compatibilidad** y **tamaño pequeño** sin símbolos raros.
|
| 516 |
-
|
| 517 |
-
---
|
| 518 |
-
|
| 519 |
-
#### 2) Kōmín-CJK (visual y ultracorto)
|
| 520 |
-
- Usa ideogramas CJK para **aún más compresión** y un aspecto muy limpio.
|
| 521 |
-
- Añade **partículas**:
|
| 522 |
-
- `ᵖ` marca el **sujeto**, `ᵒ` marca el **objeto**.
|
| 523 |
-
- El verbo lleva un **círculo de tiempo**:
|
| 524 |
-
- **Ⓟ / Ⓣ / Ⓕ** → Presente / Pasado / Futuro
|
| 525 |
-
- Las **preguntas** suelen acabar en **?**.
|
| 526 |
-
- **Ejemplo**: “**Los estudiantes leen libros.**” → `学生ᵖ 书ᵒ 读Ⓟ`
|
| 527 |
-
|
| 528 |
-
**Cuándo usarlo**: si buscas **máxima compresión** y no te importa usar caracteres CJK.
|
| 529 |
-
|
| 530 |
-
---
|
| 531 |
-
|
| 532 |
-
#### ¿Y si falta una palabra?
|
| 533 |
-
- Si una palabra no está en el diccionario, se guarda **de forma reversible**:
|
| 534 |
-
- En **Minimax**: `~A9f...` (base64 propio).
|
| 535 |
-
- En **Kōmín**: `「...」`.
|
| 536 |
-
Así **no se pierde nada**.
|
| 537 |
-
|
| 538 |
-
#### “Compresión exacta” (el `~...`)
|
| 539 |
-
- Opcionalmente se añade un **sidecar** `~...` con el **original comprimido**.
|
| 540 |
-
- Si existe, al decodificar se recupera el **original al 100%** (puntuación, mayúsculas, etc.).
|
| 541 |
-
- En textos largos ahorra mucho, con **ida/vuelta perfecta**.
|
| 542 |
-
|
| 543 |
-
---
|
| 544 |
-
|
| 545 |
-
#### Mini-glosario
|
| 546 |
-
- **Código**: forma corta de una palabra (p. ej., `g` para “que”).
|
| 547 |
-
- **Partícula**: marca de función (sujeto `ᵖ`, objeto `ᵒ`).
|
| 548 |
-
- **Cola verbal** (Minimax): `·P/·T/·F`, persona (`1s`, `3p`), `N`, `Q`.
|
| 549 |
-
- **Sidecar**: `~...` con el original comprimido para **reconstruir exacto**.
|
| 550 |
-
|
| 551 |
-
> Resumen: Minimax-ASCII = **universal y tecleable**. Kōmín-CJK = **más corto y visual**. Ambos son **reversibles** y aceptan **sidecar exacto**.
|
| 552 |
"""
|
| 553 |
|
| 554 |
# EN
|
|
@@ -558,59 +509,10 @@ EXPLAIN_TAB_DECODE_EN = "Converts **Minimax/Kōmín → ES/EN**. If ~... exists,
|
|
| 558 |
EXPLAIN_TAB_ROUNDTRIP_EN = "Runs **(ES/EN→Conlang)→(Conlang→ES/EN)** to verify reversibility; with exact, it’s bit-for-bit."
|
| 559 |
EXPLAIN_CHECKBOX_EN = "Drop articles ~10–15%, Zero copula ~5–10% extra, Remove pronouns variable, Max Exact 40–60% for >100 chars."
|
| 560 |
EXPLAIN_CONLANGS_EN = """
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
**
|
| 565 |
-
|
| 566 |
-
---
|
| 567 |
-
|
| 568 |
-
#### 1) Minimax-ASCII (compact & typeable)
|
| 569 |
-
- Uses **ASCII only**, so it works everywhere (email, phones, code editors).
|
| 570 |
-
- Each **word** becomes a **short code** (high-frequency words get the shortest codes).
|
| 571 |
-
- **Verbs** get a small **tail**:
|
| 572 |
-
- **·P / ·T / ·F** → Present / Past / Future
|
| 573 |
-
- **1s, 2p, 3s…** → Person & number (1=I/we, 2=you, 3=he/they; s=singular, p=plural)
|
| 574 |
-
- **N** → negation; **Q** → question
|
| 575 |
-
- **Example**: “**Are you okay?**” → `k·P2sQ` (be, Present, 2nd person, question)
|
| 576 |
-
|
| 577 |
-
**When to use**: you want **maximum compatibility** and **small size** without special symbols.
|
| 578 |
-
|
| 579 |
-
---
|
| 580 |
-
|
| 581 |
-
#### 2) Kōmín-CJK (visual & ultra-short)
|
| 582 |
-
- Uses CJK ideograms for **even tighter compression** and a clean visual look.
|
| 583 |
-
- Adds **particles**:
|
| 584 |
-
- `ᵖ` marks the **subject**, `ᵒ` marks the **object**.
|
| 585 |
-
- Verb shows a **time bubble**:
|
| 586 |
-
- **Ⓟ / Ⓣ / Ⓕ** → Present / Past / Future
|
| 587 |
-
- **Questions** usually end with **?**.
|
| 588 |
-
- **Example**: “**Students read books.**” → `学生ᵖ 书ᵒ 读Ⓟ`
|
| 589 |
-
|
| 590 |
-
**When to use**: you want **maximum compression** and you’re fine with CJK.
|
| 591 |
-
|
| 592 |
-
---
|
| 593 |
-
|
| 594 |
-
#### Unknown words?
|
| 595 |
-
- If a word isn’t in the lexicon, it’s kept **reversibly**:
|
| 596 |
-
- In **Minimax**: `~A9f...` (custom base64).
|
| 597 |
-
- In **Kōmín**: `「...」`.
|
| 598 |
-
Nothing is lost.
|
| 599 |
-
|
| 600 |
-
#### “Exact compression” (the `~...` sidecar)
|
| 601 |
-
- Optionally appends `~...` with the **compressed original**.
|
| 602 |
-
- If present, decoding reproduces the **exact original** (punctuation, casing, etc.).
|
| 603 |
-
- Great for longer texts: big savings with **perfect round-trip**.
|
| 604 |
-
|
| 605 |
-
---
|
| 606 |
-
|
| 607 |
-
#### Tiny glossary
|
| 608 |
-
- **Code**: short form for a word (e.g., `g` for “that/que”).
|
| 609 |
-
- **Particle**: role marker (subject `ᵖ`, object `ᵒ`).
|
| 610 |
-
- **Verb tail** (Minimax): `·P/·T/·F`, person (`1s`, `3p`), `N`, `Q`.
|
| 611 |
-
- **Sidecar**: `~...` holding the compressed original for **bit-perfect recovery**.
|
| 612 |
-
|
| 613 |
-
> TL;DR: Minimax-ASCII = **universal & typeable**. Kōmín-CJK = **shortest & visual**. Both are **reversible** and support the **exact sidecar**.
|
| 614 |
"""
|
| 615 |
|
| 616 |
# Léxico (amigable)
|
|
@@ -760,31 +662,26 @@ def make_panel_roundtrip(lang="ES"):
|
|
| 760 |
return g
|
| 761 |
|
| 762 |
# ---------- Página (ES/EN), con “modos” como BOTONES (Radio) ----------
|
| 763 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 764 |
|
| 765 |
# --- Descargas diccionarios (PDF) ---
|
| 766 |
-
gr.Markdown("
|
| 767 |
-
# Mini-CSS para reducir visualmente el tamaño de los botones (un nivel menos)
|
| 768 |
-
gr.HTML("""
|
| 769 |
-
<style>
|
| 770 |
-
#btn_pdf_es button, #btn_pdf_en button {
|
| 771 |
-
font-size: 0.9rem;
|
| 772 |
-
padding: 0.5rem 0.9rem;
|
| 773 |
-
}
|
| 774 |
-
</style>
|
| 775 |
-
""")
|
| 776 |
with gr.Row():
|
| 777 |
gr.DownloadButton(
|
| 778 |
label="⬇️ Español >> Minimax-ASCII y Kōmín-CJK (PDF)",
|
| 779 |
value="dictionary_ES_to_Minimax_Komin.pdf",
|
| 780 |
-
|
| 781 |
-
variant="secondary"
|
| 782 |
)
|
| 783 |
gr.DownloadButton(
|
| 784 |
label="⬇️ English >> Minimax-ASCII y Kōmín-CJK (PDF)",
|
| 785 |
value="dictionary_EN_to_Minimax_Komin.pdf",
|
| 786 |
-
|
| 787 |
-
variant="secondary"
|
| 788 |
)
|
| 789 |
|
| 790 |
gr.Markdown("## 🌍 Idioma / Language")
|
|
@@ -937,3 +834,4 @@ if __name__ == "__main__":
|
|
| 937 |
|
| 938 |
|
| 939 |
|
|
|
|
|
|
| 364 |
return tab[tense].get(person, tab[tense]["3s"])
|
| 365 |
if lemma=="estar":
|
| 366 |
tab={"Pres":{"1s":"estoy","2s":"estás","3s":"está","1p":"estamos","2p":"estáis","3p":"están"},
|
| 367 |
+
"Past":{"1s":"estuve","2s":"estuviste","3s":"estuvo","1p":"estuvimos","2p":"estuvisteis","3p":"estuvieron"},
|
| 368 |
"Fut":{"1s":"estaré","2s":"estarás","3s":"estará","1p":"estaremos","2p":"estaréis","3p":"estarán"}}
|
| 369 |
return tab[tense].get(person, tab[tense]["3s"])
|
| 370 |
if lemma=="ir":
|
|
|
|
| 496 |
"""
|
| 497 |
# ¿Qué son los lenguajes?
|
| 498 |
EXPLAIN_CONLANGS_ES = """
|
| 499 |
+
**¿Qué son Minimax-ASCII y Kōmín-CJK?**
|
| 500 |
+
- **Minimax-ASCII**: versión compacta que usa sólo caracteres comunes (ASCII). Añade marcas como ·P/·T/·F, persona (1s,2p…), negación N y pregunta Q.
|
| 501 |
+
- **Kōmín-CJK**: versión visual con partículas (ej.: sujeto ᵖ, objeto ᵒ) y un circulito de tiempo Ⓟ/Ⓣ/Ⓕ. Puede terminar en ?.
|
| 502 |
+
Ambos son “**conlangs**” pensados para **ahorrar espacio** y permitir **decodificación** a ES/EN (exacta si hay ~...).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
"""
|
| 504 |
|
| 505 |
# EN
|
|
|
|
| 509 |
EXPLAIN_TAB_ROUNDTRIP_EN = "Runs **(ES/EN→Conlang)→(Conlang→ES/EN)** to verify reversibility; with exact, it’s bit-for-bit."
|
| 510 |
EXPLAIN_CHECKBOX_EN = "Drop articles ~10–15%, Zero copula ~5–10% extra, Remove pronouns variable, Max Exact 40–60% for >100 chars."
|
| 511 |
EXPLAIN_CONLANGS_EN = """
|
| 512 |
+
**What are Minimax-ASCII and Kōmín-CJK?**
|
| 513 |
+
- **Minimax-ASCII**: compact ASCII codes with ·P/·T/·F, person (1s,2p…), N for negation and Q for question.
|
| 514 |
+
- **Kōmín-CJK**: visual style using particles (subject ᵖ, object ᵒ) and time bubbles Ⓟ/Ⓣ/Ⓕ, may end in ?.
|
| 515 |
+
Both are conlangs for **space-saving** and **decoding** back to ES/EN (bit-perfect when ~... is present).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 516 |
"""
|
| 517 |
|
| 518 |
# Léxico (amigable)
|
|
|
|
| 662 |
return g
|
| 663 |
|
| 664 |
# ---------- Página (ES/EN), con “modos” como BOTONES (Radio) ----------
|
| 665 |
+
custom_css = """
|
| 666 |
+
/* H3 para sección de descargas y botones más pequeños */
|
| 667 |
+
#dict_title_h3 h3 { font-size: 1.25rem !important; margin-bottom: 0.4rem; } /* ≈ h3 */
|
| 668 |
+
.dl-btn-sm button { font-size: 0.9rem !important; padding: 0.4rem 0.75rem !important; }
|
| 669 |
+
"""
|
| 670 |
+
|
| 671 |
+
with gr.Blocks(title="Universal Conlang Translator", theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 672 |
|
| 673 |
# --- Descargas diccionarios (PDF) ---
|
| 674 |
+
gr.Markdown("### 📥 Diccionarios (PDF)", elem_id="dict_title_h3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
with gr.Row():
|
| 676 |
gr.DownloadButton(
|
| 677 |
label="⬇️ Español >> Minimax-ASCII y Kōmín-CJK (PDF)",
|
| 678 |
value="dictionary_ES_to_Minimax_Komin.pdf",
|
| 679 |
+
elem_classes=["dl-btn-sm"]
|
|
|
|
| 680 |
)
|
| 681 |
gr.DownloadButton(
|
| 682 |
label="⬇️ English >> Minimax-ASCII y Kōmín-CJK (PDF)",
|
| 683 |
value="dictionary_EN_to_Minimax_Komin.pdf",
|
| 684 |
+
elem_classes=["dl-btn-sm"]
|
|
|
|
| 685 |
)
|
| 686 |
|
| 687 |
gr.Markdown("## 🌍 Idioma / Language")
|
|
|
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
+
|