pub struct LangAz { /* private fields */ }Implementations§
Trait Implementations§
Source§impl Lang for LangAz
impl Lang for LangAz
Source§fn default_currency(&self) -> &str
fn default_currency(&self) -> &str
This language’s own to_currency(currency=...) default,
read from the live Python signature. Only 44 of 156 use EUR.
Source§fn default_separator(&self) -> &str
fn default_separator(&self) -> &str
This language’s own to_currency(separator=...) default,
read from the live Python signature. Base’s is “,”, but only
36 of 149 languages actually use it — most default to “ “ or a
conjunction, so inheriting Base’s comma silently corrupts them.
Source§fn to_cardinal_float(
&self,
value: &FloatValue,
_precision_override: Option<u32>,
) -> Result<String>
fn to_cardinal_float( &self, value: &FloatValue, _precision_override: Option<u32>, ) -> Result<String>
Not a port of Num2Word_AZ.to_cardinal_float — there is no such
method. AZ inherits Base’s, which is dead code for it, and overrides
to_cardinal instead, handling non-integers inline. This hook is where
the dispatcher’s float input lands, so it carries that inline handling.
precision_override (the precision= kwarg, issue #580) is ignored,
which is not an omission: Num2Word_AZ.to_cardinal never reads
self.precision, so the dispatcher’s save/restore around the call
changes nothing. Verified live — num2words(3.14159, lang="az", precision=2) and precision=0 are both byte-identical to the plain
call, all three “üç nöqtə on dörd min yüz əlli doqquz”. AZ reads the
fraction as a whole number, so there is no per-digit knob to turn.
Source§fn cardinal_float_entry(
&self,
value: &FloatValue,
precision_override: Option<u32>,
) -> Result<String>
fn cardinal_float_entry( &self, value: &FloatValue, precision_override: Option<u32>, ) -> Result<String>
to_cardinal(float/Decimal) — the full entry, whole values included.
AZ never takes a whole-value shortcut: str(5.0) is “5.0” and the
algorithm reads the “.0” like any other fraction, so num2words(5.0, lang="az") is “beş nöqtə sıfır”, never “beş”. The trait default’s
as_whole_int() fast path is therefore wrong for AZ and bypassed.
Source§fn ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
fn ordinal_float_entry(&self, value: &FloatValue) -> Result<String>
to_ordinal(float/Decimal): assert int(value) == value — a bare
AssertionError for any fractional value (0.5, 3.25) — then the same
cardinal + vowel-suffix walk as the integer path, over the cardinal of
the full float string: to_ordinal(5.0) == “beş nöqtə sıfırıncı”.
Exponent-form input (1e16, Decimal("1E+2")) is whole, so it passes
the assert and then dies inside to_cardinal with bug 4’s ValueError
— in that order.
Source§fn ordinal_num_float_entry(
&self,
value: &FloatValue,
repr_str: &str,
) -> Result<String>
fn ordinal_num_float_entry( &self, value: &FloatValue, repr_str: &str, ) -> Result<String>
to_ordinal_num(float/Decimal): the assert, the cardinal (needed only
for its last vowel — and for its ValueError on exponent forms), then
"-".join([str(value), suffix]). str(value) is echoed verbatim, so
the “.0” and -0.0’s sign survive: “5.0-cı”, “5.00-cı”, “-0.0-cı”.
Source§fn year_float_entry(&self, value: &FloatValue) -> Result<String>
fn year_float_entry(&self, value: &FloatValue) -> Result<String>
to_year(float/Decimal): the assert, then year = self.to_cardinal(abs(value)) — the cardinal of the absolute value,
so the negword never appears — and if value < 0 (numeric, not the
sign bit) picks the “e.ə.” era prefix. -0.0 is not < 0, so
to_year(-0.0) is a plain “sıfır nöqtə sıfır”.
Source§fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
fn str_to_number(&self, s: &str) -> Result<ParsedNumber>
Base str_to_number (Decimal(value)), with one AZ-visible fixup:
Decimal("Infinity") parses fine in Python, and AZ’s to_cardinal
then walks str() == “Infinity” reversed (“ytinifnI”), so the first
int() call is int("y") — ValueError: invalid literal for int() with base 10: 'y', not the OverflowError of base’s
int(Decimal('Infinity')). “-Infinity” strips its sign first and
names the same ‘y’. The shared Inf sentinel maps to OverflowError in
the binding, so the ValueError is raised here instead.
(For to=“ordinal”/“ordinal_num”/“year” Python would OverflowError
inside assert int(value) == value before to_cardinal runs, but only
cardinal rows exist in the corpus and the mode is not visible from
this hook — the RU port makes the same call.)
Source§fn cardinal_from_decimal(&self, value: &BigDecimal) -> Result<String>
fn cardinal_from_decimal(&self, value: &BigDecimal) -> Result<String>
The fractional-cents branch of Num2Word_Base.to_currency, which Python
reaches as self.to_cardinal(float(right)) — AZ’s to_cardinal, not
Base’s to_cardinal_float. The trait default routes to
floatpath::cardinal_from_bigdecimal, i.e. Base’s digit-by-digit
rendering, which AZ does not inherit and which differs as soon as the
leftover cents carry more than one digit: at 1.0655 USD (65.5 cents)
Python says “altı nöqtə əlli beş sent” — “six point fifty-five” — where
Base’s path would say “altı nöqtə beş beş”.
The float(right) cast is reproduced rather than avoided: it is what
collapses Decimal(“6.5500”) to “6.55” before str() ever sees it.
Source§fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
fn pluralize(&self, n: &BigInt, forms: &[String]) -> Result<String>
Num2Word_AZ.pluralize: forms[0 if n == 1 else 1].
Textually identical to Num2Word_EUR.pluralize, but arrived at
independently — AZ does not inherit from EUR.
Python indexes the tuple directly, so a one-form entry with n != 1
would raise IndexError. All three AZ entries have two forms, so that is
unreachable; it is mapped to Index rather than panicking so the
exception type survives if the table ever changes.
fn negword(&self) -> &str
fn pointword(&self) -> &str
fn to_cardinal(&self, value: &BigInt) -> Result<String>
fn to_ordinal(&self, value: &BigInt) -> Result<String>
fn to_ordinal_num(&self, value: &BigInt) -> Result<String>
fn to_year(&self, value: &BigInt) -> Result<String>
Source§fn currency_forms(&self, code: &str) -> Option<&CurrencyForms>
fn currency_forms(&self, code: &str) -> Option<&CurrencyForms>
CURRENCY_FORMS[code]. None -> NotImplementedError, as in Python.fn cards(&self) -> &Cards
fn maxval(&self) -> &BigInt
fn is_title(&self) -> bool
fn exclude_title(&self) -> &[String]
Source§fn merge(&self, _l: (&str, &BigInt), _r: (&str, &BigInt)) -> (String, BigInt)
fn merge(&self, _l: (&str, &BigInt), _r: (&str, &BigInt)) -> (String, BigInt)
merge is abstract in Python (raise NotImplementedError).
Languages that override to_cardinal never reach it.fn title(&self, value: &str) -> String
Source§fn currency_precision(&self, _code: &str) -> i64
fn currency_precision(&self, _code: &str) -> i64
CURRENCY_PRECISION.get(code, 100) — subunits per unit. 1000 for
3-decimal currencies (BHD/KWD/…), 1 for no-subunit currencies.fn money_verbose(&self, number: &BigInt, _currency: &str) -> Result<String>
fn cents_verbose(&self, number: &BigInt, _currency: &str) -> Result<String>
fn cents_terse(&self, number: &BigInt, currency: &str) -> Result<String>
Source§fn to_currency(
&self,
val: &CurrencyValue,
currency: &str,
cents: bool,
separator: Option<&str>,
adjective: bool,
) -> Result<String>
fn to_currency( &self, val: &CurrencyValue, currency: &str, cents: bool, separator: Option<&str>, adjective: bool, ) -> Result<String>
separator: None means the caller omitted the kwarg, so the
language’s own default applies. Python expresses this as a per-method
default (Num2Word_CA.to_currency(..., separator=" amb")), which a
plain &str cannot represent: once the shim substitutes Base’s “,”,
“caller omitted it” and “caller passed a comma” are indistinguishable.Source§fn default_adjective(&self) -> bool
fn default_adjective(&self) -> bool
to_currency(adjective=...) default. Base’s is
False; only Mongolian defaults to True.fn to_cheque(&self, val: &BigDecimal, currency: &str) -> Result<String>
Source§fn to_fraction(
&self,
numerator: &BigInt,
denominator: &BigInt,
) -> Result<String>
fn to_fraction( &self, numerator: &BigInt, denominator: &BigInt, ) -> Result<String>
Num2Word_Base.to_fraction (issue #584). EN/DE/ES/FR/IT/PT and the
aero profiles override with idiomatic forms (half/quarter/Drittel).Source§fn cardinal_with_pointword(
&self,
_value: &FloatValue,
_pointword: &str,
_precision_override: Option<u32>,
) -> Result<String>
fn cardinal_with_pointword( &self, _value: &FloatValue, _pointword: &str, _precision_override: Option<u32>, ) -> Result<String>
to_cardinal(value) with the pointword
swapped for this one call. Only reachable through
ParsedNumber::DecPoint, so only PT_BR implements it.fn to_cardinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_ordinal_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_ordinal_num_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_year_kw(&self, value: &BigInt, kw: &Kwargs) -> Result<String>
fn to_currency_kw( &self, val: &CurrencyValue, currency: &str, cents: bool, separator: Option<&str>, adjective: bool, kw: &Kwargs, ) -> Result<String>
fn to_cardinal_float_kw( &self, value: &FloatValue, precision_override: Option<u32>, kw: &Kwargs, ) -> Result<String>
Source§fn es_currency_ordinal_fires(&self) -> bool
fn es_currency_ordinal_fires(&self) -> bool
Num2Word_ES
apocopates 1 → “un euro” in to_currency, bypassing to_cardinal, so
the stash never fires (false, the default). The regional es_XX
classes inherit Base.to_currency, whose _money_verbose calls
to_cardinal(1) → the stash fires → “primero córdoba” (true).Source§fn neg_zero_decimal(&self, _to: &str) -> Option<Result<String>>
fn neg_zero_decimal(&self, _to: &str) -> Option<Result<String>>
Decimal('-0.0') for mode to, which BigDecimal cannot
represent (it has no signed zero). None — the default — means the
value coincides with float -0.0, so the binding’s Float{-0.0}
demotion is exact. The ~10 languages that render the Decimal form
differently (ce/cy “dim”/“ноль” via the integer path, pl its float
grammar with the negword, rm a TypeError) override this to serve it
natively instead of leaning on a Python fallback.Source§fn inf_result(&self, _negative: bool, _to: &str) -> Result<String>
fn inf_result(&self, _negative: bool, _to: &str) -> Result<String>
str_to_number produced Decimal('Infinity') / -Infinity. Base’s
integer path does int(Decimal('Infinity')) → OverflowError. The many
self-contained converters that feed the raw token to int("Infinity")
get ValueError instead and override this. to is the requested mode.Source§fn nan_result(&self, _to: &str) -> Result<String>
fn nan_result(&self, _to: &str) -> Result<String>
str_to_number produced Decimal('NaN'). Base’s int(NaN) raises
ValueError (caught into the float path, which raises ValueError again).
Languages whose parse raises decimal.InvalidOperation first override.Source§fn python_maxval(&self) -> Option<BigInt>
fn python_maxval(&self) -> Option<BigInt>
getattr(converter, "MAXVAL", None) — the maxval() API.
Engine languages get it from their card table (Base sets
MAXVAL = 1000 * top_card); self-contained ones mostly lack the
attribute (None). The zero sentinel in maxval() means “unset”.