ToOrdinal builds compound ordinals with cardinal tens, as in English

Aperta
#998 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
73/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, yaml

Direzione di ricerca

Read hundreds_to_words in src/xpath_functions.rs and the definitions in Rules/Languages/es/definitions.yaml. Check how ToOrdinal selects words for compound numbers, then add the OrdinalCompound behavior described in the issue while preserving the default English output. Done when Spanish compound ordinals use ordinal words for each part and the existing English behavior remains unchanged; the issue does not name a test file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

ToOrdinal builds 21–99 as cardinal + ordinal, which is right for English ("twenty first") but not for Spanish, where every part is an ordinal:

n Spanish today expected
21 veinte primero vigésimo primero
45 cuarenta quinto cuadragésimo quinto
99 noventa noveno nonagésimo noveno

The cardinal words come from NumbersTens and NumbersHundreds in hundreds_to_words (src/xpath_functions.rs); the Spanish ordinal lists themselves are fine now (fixed in the es-ordinals PR).

Proposed patch: a new definition, OrdinalCompound: ["ordinal"], that a language can set so hundreds_to_words uses the ordinal lists for every part. Languages that don't set it keep today's behavior, so English doesn't change.

-            let mut hundreds = definitions.get_vec("NumbersHundreds")?[number[0]].clone();
+            // in some languages (e.g., Spanish) every part of a compound ordinal is an ordinal ("vigésimo primero"),
+            // not a cardinal followed by an ordinal ("twenty first")
+            let all_ordinal = definitions.get_vec("OrdinalCompound")
+                .is_some_and(|v| v.first().is_some_and(|s| s == "ordinal"));
+            let mut hundreds = if all_ordinal {
+                words[0][number[0]].clone()
+            } else {
+                definitions.get_vec("NumbersHundreds")?[number[0]].clone()
+            };
@@
-                return Some(hundreds + &definitions.get_vec("NumbersTens")?[number[1]] + " " + &words[2][number[2]]);
+                let tens = if all_ordinal {
+                    words[1][number[1]].clone()
+                } else {
+                    definitions.get_vec("NumbersTens")?[number[1]].clone()
+                };
+                return Some(hundreds + &tens + " " + &words[2][number[2]]);

and in Rules/Languages/es/definitions.yaml:

- OrdinalCompound: ["ordinal"]

Spanish doesn't call ToOrdinal for this today: the es-ordinals PR #999 uses two small maps of its own, because of this problem. With the fix, that rule could use ToOrdinal and drop them (the feminine "primera" and the apocope "primer" are built in the rule from the masculine word).

Lingua principale
Rust
Stelle
131
Fork
97
Merge medio
21h 45m
PR unite (30g)
95

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di daisy/MathCAT

Tutte le issue di daisy/MathCAT

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.