ToOrdinal builds compound ordinals with cardinal tens, as in English

Đang mở
#998 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
73/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, yaml
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).

Ngôn ngữ chính
Rust
Star
131
Fork
97
Merge trung bình
21 giờ 45 phút
Pull request đã merge (30 ngày)
95

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của daisy/MathCAT

Tất cả issue của daisy/MathCAT

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.