Add support for Croatian#643
Conversation
|
@Jetman80, thanks for putting this together — Croatian support has been a long gap in num2words, and the cardinal + currency implementation here is solid. I tested it against real-world Croatian text (TTS pre-normalisation for narration) and the cardinals match what a native speaker would say. Two pieces are still missing for the PR to fully cover Croatian usage: to_ordinal() raises NotImplementedError. Croatian ordinals are essential — “17. rujna”, “21. stoljeću”, “1986. godine” all involve ordinal forms. Masculine-nominative ordinals via last-cardinal-word substitution (prvi, drugi, treći, četvrti, peti, …, dvadeseti, stoti, tisućiti) (a) submit it as a separate PR after this one merges, or Could a maintainer (@savoirfairelinux team) take a look? |
@tihomirjauk I don't believe (a) can happen in the nearest future, it's been almost a year since I posted my PR. I just reference github source in my pip installs for now. I am happy to merge commits if you provide PR to my fork, so this implementation and PR are more complete in this way. Thanks! |
PR savoirfairelinux#643 implements cardinals + currency for Croatian but leaves to_ordinal raising NotImplementedError, and to_year falls through to to_cardinal via the base class default. This commit: - Implements masculine-nominative-singular ordinals (prvi, drugi, ..., šesti, dvadeseti, stoti, tisućiti) via last-cardinal-word substitution. - Implements to_year() with feminine-genitive ending (the form actually used before 'godine' in Croatian: 1986 → tisuću devetsto osamdeset šeste). Collapses 'jedna tisuća' → 'tisuću' for years 1000-1999. - Adds ~25 ordinal tests + 5 year tests covering ones (regular and irregular), tens, twenties, hundreds, exact powers of 10, and full 4-digit year forms.
Add to_ordinal() and to_year() for Croatian
This commit adds support for the Croatian language. Implementation includes cardinal numbers, EUR, USD, HRK currencies, tests. It is based on the Serbian language implementation as the closest one.
Changes proposed in this pull request:
num2words/lang_HR.py)tests/test_hr.py)__init__.pyandREADME.rstupdates to reflect the changesStatus
How to verify this change
Run the tests for Croatian language with
python3 -m pytest tests/test_hy.py -vto run tests. You can also manually test with examples like: