Skip to content

2.5.0: speak decimals as fractions, fix crashes - #14

Merged
synesthesiam merged 1 commit into
mainfrom
release-2.5.0
Nov 16, 2026
Merged

synesthesiam merged 1 commit into
mainfrom
release-2.5.0

Conversation

@synesthesiam

Copy link
Copy Markdown
Member

What

Fixes for the 2.5.0 release. Version is bumped and CHANGELOG.md updated.

Decimals as fractions (ru, pl, kk, ky)

When an x.x rule sends the fractional part to a different ruleset (→%%fractions-feminine→), ICU treats that ruleset as a fraction ruleset: its rules are keyed by denominator, and the digits after the point are the numerator. The engine spoke them digit by digit through those rules instead, which garbled every decimal in these languages.

input before after
ru 1.5 одна целыхноль десятых одна целая пять десятых
ru 0.5 ноль целыхноль десятых пять десятых
ru 1.25 одна целыхноль десятыхноль десятых одна целая двадцать пять сотых
pl 14.89 czternaście przecinek zero zero czternaście przecinek osiemdziesiąt dziewięć
pl 14.05 czternaście przecinek zero zero czternaście przecinek zero pięć
kk 1.5 бір бүтін оннан нөл бір бүтін оннан бес

Also needed for this:

  • <%ruleset<< (Polish) speaks the numerator's leading zeros
  • A plural form inside [...] now stays with its optional group, so it's dropped along with the substitution (ru 0.5 has no "целых")
  • In an x.x rule, the plural agrees with the integer part ("одна целая")
  • Text after a plural form now comes after it, instead of being appended to the text before it

A fraction the ruleset can't express (a <0< digit pattern, more places than its largest denominator) falls back to digit by digit, as before.

Smaller fixes

  • 1e-7 crashed in every language (str() gives 1E-7, which has no . to split on)
  • -inf crashed in every language with OverflowError; English now gives "minus infinity"
  • Doubled and trailing spaces are removed from format_number output (Arabic ordinals: 21 "الحادي والعشرون"; Arabic and Hebrew decimals had a trailing space)

Testing

  • 127 tests pass; black, isort, flake8, pylint and mypy are clean
  • The 5 new or re-enabled tests (ar, en, kk, pl, ru) fail on main
  • Compared all 32,732 outputs (every public ruleset in all 91 languages, 49 numbers) before and after: 366 changed, all in ru, pl, kk, ky, ar and he, and all are decimals except Arabic ordinal whitespace. No new errors.

Known data quirk, left as is: ru spellout-cardinal-masculine gives "одна целый" because CLDR's ru.xml says one{целый}. ICU gives the same.

🤖 Generated with Claude Code

When a decimal rule sends the fractional part to another ruleset, that
ruleset is keyed by denominator, as in ICU: 1.5 in Russian is "одна целая
пять десятых", not digit by digit. This fixes decimals in Russian, Polish,
Kazakh and Kyrgyz, including Polish's spoken leading zeros (<%rs<<).

The parser also kept a plural form inside [...] apart from its optional
group, and put text after a plural form before it.

Also fix crashes on 1e-7 (scientific notation) and -inf, and remove
doubled and trailing spaces from output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@synesthesiam
synesthesiam merged commit 8c0c9fd into main Nov 16, 2026
1 check passed
@synesthesiam
synesthesiam deleted the release-2.5.0 branch November 16, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant