1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
//! Port of `lang_EN_AERO.py`'s `Num2Word_EN_AERO_US_Army` (ICAO/aviation
//! English, US Army profile — registry key `en_Aero_US_Army`).
//!
//! Shape: **self-contained** for `to_cardinal`/`to_year`, but *delegating*
//! for `to_ordinal`. `Num2Word_EN_AERO` subclasses `Num2Word_EN`, so the full
//! EN engine (cards/merge/MAXVAL, built via `lang_EUR` → `Num2Word_Base`) is
//! inherited and still present on the instance — but `to_cardinal` is
//! overridden outright with a digit-by-digit reader that never consults
//! `self.cards`. Hence `cards`/`maxval`/`merge` stay at their trait defaults
//! here and there is **no OverflowError path** on the cardinal side: the
//! inherited EN `MAXVAL` (10^306) is unreachable because `splitnum` is never
//! called. `to_cardinal(10**400)` happily emits 401 digit words.
//!
//! # The `_english` sibling instance — why this file uses `LangEn`
//!
//! `Num2Word_EN_AERO.__init__` stashes a *separate* plain-English converter:
//!
//! ```python
//! self._english = Num2Word_EN()
//! ```
//!
//! and `to_ordinal` forwards to it rather than to `super()`. This is
//! deliberate (the docstring spells it out): routing ordinals through the
//! inherited EN `to_ordinal` would let the digit-by-digit cardinal leak into
//! the ordinal builder and produce "treeth" instead of "third", because EN's
//! `to_ordinal` is built as `to_cardinal(value)` + suffix-fixup on the last
//! word. Forwarding to a pristine `Num2Word_EN` sidesteps the override.
//!
//! This port mirrors that structure exactly by holding a `crate::lang_en::LangEn`
//! field. It is a *read* of a sibling language module, not an edit — the
//! `_english` handshake is load-bearing and reimplementing the EN engine here
//! would be a rewrite, not a port.
//!
//! # Modes (all four in scope, and where each comes from)
//!
//! | mode | defined in | behaviour |
//! |---------------|--------------------|--------------------------------------------|
//! | `to_cardinal` | `Num2Word_EN_AERO` | digit-by-digit ICAO respelling |
//! | `to_year` | `Num2Word_EN_AERO` | `return self.to_cardinal(value)` — verbatim |
//! | `to_ordinal` | `Num2Word_EN_AERO` | `self._english.to_ordinal(value)` — plain EN |
//! | `to_ordinal_num` | `Num2Word_EN_AERO` | `verify_ordinal` then `str(int(value))` |
//! | `to_currency` | `Num2Word_EN_AERO` | `self._english.to_currency(*a, **kw)` — plain EN |
//! | `to_cheque` | `Num2Word_EN_AERO` | `self._english.to_cheque(*a, **kw)` — plain EN |
//!
//! # Currency: the whole surface is a forward to `_english`
//!
//! ```python
//! def to_currency(self, *args, **kwargs):
//! return self._english.to_currency(*args, **kwargs)
//!
//! def to_cheque(self, *args, **kwargs):
//! return self._english.to_cheque(*args, **kwargs)
//! ```
//!
//! Same rationale as `to_ordinal`, and the corpus pins it hard: `to_cardinal`
//! of 1234 is "wun too tree fower", but `currency:EUR` of 1234.56 is "one
//! thousand, two hundred and thirty-four euros, fifty-six cents". Money is
//! read as composite English, not digit-by-digit — because `_money_verbose` /
//! `_cents_verbose` resolve on the *pristine `Num2Word_EN` instance*, whose
//! `to_cardinal` was never overridden. All 117 `en_Aero_US_Army`
//! currency+cheque corpus rows are byte-identical to the plain `en` rows for
//! the same `(to, arg)`, and none of them raise.
//!
//! So this file overrides exactly the two hooks Python overrides and forwards
//! them. It deliberately does **not** define `currency_forms`,
//! `currency_precision`, `pluralize`, `money_verbose`, `cents_verbose` or
//! `cents_terse` on `LangEnAeroUsArmy`:
//!
//! * There is no table to build here. `CURRENCY_FORMS` / `CURRENCY_PRECISION`
//! do exist on the Python AERO instance (`super().__init__()` runs EN's
//! `__init__`, which populates them), but they are **dead** — nothing on the
//! class ever reads them, because both entry points hand off to `_english`
//! first. Mirroring them here would be a second copy of EN's ~30-entry table
//! that no code path can reach: pure drift risk.
//! * The table *is* still built once, in `LangEn::new()`, which this struct
//! calls once from its own `new()` and stores. No per-call construction.
//! * Overriding `currency_forms` + `pluralize` on `self` and letting
//! `default_to_currency` run against `self` would be actively **wrong**: the
//! default `money_verbose` calls `self.to_cardinal`, which here is the
//! digit-by-digit reader — it would emit "wun too tree fower euros".
//!
//! One quirk falls out of the forward for free: the NotImplementedError for an
//! unknown code names **`Num2Word_EN`**, not `Num2Word_EN_AERO_US_Army`, since
//! Python formats `self.__class__.__name__` on the `_english` instance that
//! actually raises. Delegating reproduces that, as long as `LangEn::lang_name`
//! reports `"Num2Word_EN"`. No corpus row exercises it (every AERO currency row
//! succeeds), so it is unverified here — see the report's `concerns`.
//!
//! # Behaviour worth flagging (faithfully reproduced, not "fixed")
//!
//! 1. **`to_year` drops the BC suffix.** EN's `to_year` maps negative years to
//! an `abs()` value plus a "BC" suffix and applies century phrasing
//! ("nineteen eighty-four"). AERO overrides `to_year` with a bare
//! `to_cardinal` call, so *all* of that is discarded: `to_year(-500)` is
//! "minus fife zero zero", **not** "fife zero zero BC", and `to_year(1984)`
//! is "wun niner ait fower", not century-paired. Corpus-confirmed.
//! 2. **`to_ordinal_num` returns a bare number, no suffix.** AERO overrides
//! EN's `"%s%s" % (value, self.to_ordinal(value)[-2:])` with plain
//! `str(int(value))`, so `to_ordinal_num(3)` is `"3"`, **not** `"3rd"`.
//! That looks like an oversight (the ICAO rationale for bypassing ordinals
//! doesn't apply to a numeric suffix), but it is exactly what Python emits
//! and the corpus pins it for every value tested. Preserved verbatim.
//! 3. **Mixed registers.** `to_cardinal(3)` is "tree" while `to_ordinal(3)` is
//! "third" — the two modes speak different dialects by design.
//! 4. **The `profile` parameter is inert.** `_PROFILES` maps all five keys
//! (ICAO/FAA/USN/US_ARMY/NATO) to the *same* `_ICAO_DIGITS` table, so this
//! class is byte-for-byte identical to `Num2Word_EN_AERO` and its three
//! siblings today. The `ValueError` for an unknown profile is unreachable
//! from the registry (`PROFILE = "US_ARMY"` is a valid key), so `new()` is
//! infallible. Modelled as a plain constructor rather than a checked one.
use crate;
use crateCurrencyValue;
use crateFloatValue;
use crateLangEn;
use crate;
use crateParsedNumber;
use BigDecimal;
use ;
use Signed;
/// `_ICAO_DIGITS` — the per-profile digit respelling table.
///
/// `US_ARMY` resolves to this same table (see note 4 in the module docs).
/// Kept as a `match` rather than a map: Python's `self._digit_table[ch]` is a
/// dict lookup guarded by `if ch.isdigit()`, and on integer input the only
/// characters that ever reach it are ASCII `0`-`9`.
/// `_ICAO_MINUS`.
const MINUS_WORD: &str = "minus";
/// `_ICAO_DECIMAL`. The AERO float reader emits *this*, not `self.pointword`
/// ("point") — `to_cardinal` joins `self._decimal_word` between the integer
/// and fractional digit runs. So the float path is spelled "decimal" and the
/// inherited `pointword` is dead for this class.
const DECIMAL_WORD: &str = "decimal";
/// Shared tail of `Num2Word_EN_AERO.to_cardinal` once `_digits_of` has
/// normalised the input to `(sign, integer-digits, fractional-digits)`.
///
/// ```python
/// words = []
/// if is_negative:
/// words.append(self._minus_word)
/// for ch in int_part:
/// if ch.isdigit():
/// words.append(self._digit_table[ch])
/// if frac_part:
/// words.append(self._decimal_word)
/// for ch in frac_part:
/// if ch.isdigit():
/// words.append(self._digit_table[ch])
/// return " ".join(words)
/// ```
///
/// The `ch.isdigit()` guard is kept structurally via `icao_digit` returning
/// `Option` — on the digit strings we build here every char is ASCII `0`-`9`,
/// so nothing is ever actually skipped, exactly as in Python for numeric input.