unicode-rbnf 2.3.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unicode_rbnf-2.3.0/unicode_rbnf.egg-info → unicode_rbnf-2.4.0}/PKG-INFO +10 -2
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/pyproject.toml +11 -1
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_en.py +4 -3
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_engine.py +16 -4
- unicode_rbnf-2.4.0/tests/test_ko.py +8 -0
- unicode_rbnf-2.4.0/tests/test_pl.py +49 -0
- unicode_rbnf-2.4.0/tests/test_zu.py +36 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/engine.py +192 -27
- unicode_rbnf-2.4.0/unicode_rbnf/rbnf/zu.xml +120 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0/unicode_rbnf.egg-info}/PKG-INFO +10 -2
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf.egg-info/SOURCES.txt +6 -1
- unicode_rbnf-2.4.0/unicode_rbnf.egg-info/requires.txt +8 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/LICENSE.md +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/README.md +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/setup.cfg +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_de.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_decimal_format.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_es.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_fi.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_fr.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_load_all.py +2 -2
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_ro.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/tests/test_sl.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/__init__.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/__main__.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/decimal_format.py +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/py.typed +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/af.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ak.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/am.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ar.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/az.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/be.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/bg.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/bs.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ca.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ccp.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/chr.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/cs.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/cy.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/da.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/de.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/de_CH.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ee.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/el.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/en.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/en_001.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/en_IN.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/eo.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/es.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/es_419.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/et.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fa.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fa_AF.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ff.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fi.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fil.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fo.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fr.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fr_BE.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/fr_CH.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ga.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/he.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/hi.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/hr.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/hu.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/hy.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/id.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/is.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/it.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ja.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ka.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/kk.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/kl.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/km.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ko.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ky.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/lb.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/lo.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/lrc.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/lt.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/lv.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/mk.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ms.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/mt.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/my.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/nb.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ne.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/nl.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/nn.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/no.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/pl.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/pt.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/pt_PT.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/qu.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ro.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/root.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ru.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/se.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sk.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sl.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sq.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sr.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sr_Latn.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/su.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sv.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/sw.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/ta.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/th.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/tr.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/uk.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/vec.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/vi.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/yue.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/yue_Hans.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/zh.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf/rbnf/zh_Hant.xml +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf.egg-info/dependency_links.txt +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf.egg-info/top_level.txt +0 -0
- {unicode_rbnf-2.3.0 → unicode_rbnf-2.4.0}/unicode_rbnf.egg-info/zip-safe +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: unicode-rbnf
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Rule-based number formatting using Unicode CLDR data
|
|
5
5
|
Author-email: Michael Hansen <mike@rhasspy.org>
|
|
6
6
|
License: MIT
|
|
@@ -20,6 +20,14 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
20
20
|
Requires-Python: >=3.8.0
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: black==24.8.0; extra == "dev"
|
|
25
|
+
Requires-Dist: flake8==7.1.1; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy==1.14.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pylint==3.2.7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest==8.3.4; extra == "dev"
|
|
29
|
+
Requires-Dist: build==1.2.2; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
23
31
|
|
|
24
32
|
# Unicode RBNF
|
|
25
33
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "unicode-rbnf"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.4.0"
|
|
8
8
|
license = {text = "MIT"}
|
|
9
9
|
description = "Rule-based number formatting using Unicode CLDR data"
|
|
10
10
|
readme = "README.md"
|
|
@@ -29,6 +29,16 @@ requires-python = ">=3.8.0"
|
|
|
29
29
|
[project.urls]
|
|
30
30
|
"Source Code" = "https://github.com/rhasspy/unicode-rbnf"
|
|
31
31
|
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"black==24.8.0",
|
|
35
|
+
"flake8==7.1.1",
|
|
36
|
+
"mypy==1.14.0",
|
|
37
|
+
"pylint==3.2.7",
|
|
38
|
+
"pytest==8.3.4",
|
|
39
|
+
"build==1.2.2",
|
|
40
|
+
]
|
|
41
|
+
|
|
32
42
|
[tool.setuptools]
|
|
33
43
|
platforms = ["any"]
|
|
34
44
|
zip-safe = true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from unicode_rbnf import
|
|
1
|
+
from unicode_rbnf import FormatPurpose, RbnfEngine
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def test_english():
|
|
@@ -32,11 +32,12 @@ def test_english():
|
|
|
32
32
|
# Special rules
|
|
33
33
|
assert engine.format_number(-1).text == "minus one"
|
|
34
34
|
assert engine.format_number(float("nan")).text == "not a number"
|
|
35
|
-
assert engine.format_number(float("inf")).text == "
|
|
35
|
+
assert engine.format_number(float("inf")).text == "infinity"
|
|
36
36
|
|
|
37
37
|
# Fractions
|
|
38
|
-
assert engine.format_number(3.14).text == "three point
|
|
38
|
+
assert engine.format_number(3.14).text == "three point one four"
|
|
39
39
|
assert engine.format_number("5.3").text == "five point three"
|
|
40
|
+
assert engine.format_number(0.0123).text == "zero point zero one two three"
|
|
40
41
|
|
|
41
42
|
# Ordinals
|
|
42
43
|
assert engine.format_number(20, FormatPurpose.ORDINAL).text == "twentieth"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
3
|
from unicode_rbnf.engine import (
|
|
4
|
+
FormatResult,
|
|
5
|
+
NoRuleForNumberError,
|
|
6
|
+
RbnfEngine,
|
|
4
7
|
RbnfRule,
|
|
5
|
-
TextRulePart,
|
|
6
8
|
SubRulePart,
|
|
7
9
|
SubType,
|
|
8
|
-
|
|
9
|
-
FormatResult,
|
|
10
|
-
NoRuleForNumberError,
|
|
10
|
+
TextRulePart,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
|
|
@@ -68,6 +68,7 @@ def test_format_number():
|
|
|
68
68
|
|
|
69
69
|
assert engine.format_number(222) == FormatResult(
|
|
70
70
|
text="two hundred twenty-two",
|
|
71
|
+
text_ruleset="spellout-cardinal",
|
|
71
72
|
text_by_ruleset={"spellout-cardinal": "two hundred twenty-two"},
|
|
72
73
|
)
|
|
73
74
|
|
|
@@ -88,3 +89,14 @@ def test_no_rules_for_number():
|
|
|
88
89
|
|
|
89
90
|
with pytest.raises(NoRuleForNumberError):
|
|
90
91
|
engine.format_number(1, ruleset_names=["does_not_exist"])
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_parse_remainder_whitespace():
|
|
95
|
+
assert RbnfRule.parse(12.34, "←← x →→→;") == RbnfRule(
|
|
96
|
+
12,
|
|
97
|
+
parts=[
|
|
98
|
+
SubRulePart(SubType.QUOTIENT),
|
|
99
|
+
TextRulePart(" x"),
|
|
100
|
+
SubRulePart(SubType.REMAINDER, text_before=" "),
|
|
101
|
+
],
|
|
102
|
+
)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from unicode_rbnf import FormatPurpose, RbnfEngine
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_polish():
|
|
5
|
+
engine = RbnfEngine.for_language("pl")
|
|
6
|
+
|
|
7
|
+
assert engine.format_number(7).text == "siedem"
|
|
8
|
+
assert engine.format_number(15).text == "piętnaście"
|
|
9
|
+
assert engine.format_number(42).text == "czterdzieści dwa"
|
|
10
|
+
assert engine.format_number(100).text == "sto"
|
|
11
|
+
assert engine.format_number(143).text == "sto czterdzieści trzy"
|
|
12
|
+
assert engine.format_number(1000).text == "tysiąc"
|
|
13
|
+
assert engine.format_number(1234).text == "tysiąc dwieście trzydzieści cztery"
|
|
14
|
+
assert engine.format_number(3144).text == "trzy tysiące sto czterdzieści cztery"
|
|
15
|
+
assert engine.format_number(10000).text == "dziesięć tysięcy"
|
|
16
|
+
assert (
|
|
17
|
+
engine.format_number(83145).text
|
|
18
|
+
== "osiemdziesiąt trzy tysiące sto czterdzieści pięć"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
assert engine.format_number(100000).text == "sto tysięcy"
|
|
22
|
+
assert (
|
|
23
|
+
engine.format_number(683146).text
|
|
24
|
+
== "sześćset osiemdziesiąt trzy tysiące sto czterdzieści sześć"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
assert engine.format_number(1000000).text == "milion"
|
|
28
|
+
assert engine.format_number(10000000).text == "dziesięć milionów"
|
|
29
|
+
assert engine.format_number(100000000).text == "sto milionów"
|
|
30
|
+
assert engine.format_number(1000000000).text == "miliard"
|
|
31
|
+
|
|
32
|
+
# Special rules
|
|
33
|
+
assert engine.format_number(-1).text == "minus jeden"
|
|
34
|
+
assert engine.format_number(-14).text == "minus czternaście"
|
|
35
|
+
# assert engine.format_number(-14.6).text == "minus czternaście przecinek sześć"
|
|
36
|
+
# assert engine.format_number(-14.89).text == "minus czternaście przecinek osiemdziesiąt dziewięć"
|
|
37
|
+
|
|
38
|
+
# assert engine.format_number(float("nan")).text == "nie jest liczbą"
|
|
39
|
+
# assert engine.format_number(float("inf")).text == "nieskończona"
|
|
40
|
+
|
|
41
|
+
# Fractions
|
|
42
|
+
# assert engine.format_number(3.14).text == "trzy przecinek czternaście"
|
|
43
|
+
# assert engine.format_number("5.3").text == "pięć przecinek trzy"
|
|
44
|
+
|
|
45
|
+
# Years
|
|
46
|
+
assert (
|
|
47
|
+
engine.format_number(1999, FormatPurpose.YEAR).text
|
|
48
|
+
== "tysiąc dziewięćset dziewięćdziesiąt dziewięć"
|
|
49
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Tests for Zulu."""
|
|
2
|
+
|
|
3
|
+
from unicode_rbnf import RbnfEngine
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_zulu():
|
|
7
|
+
engine = RbnfEngine.for_language("zu")
|
|
8
|
+
|
|
9
|
+
assert engine.format_number(3).text == "kuthathu"
|
|
10
|
+
assert engine.format_number(15).text == "ishumi nanhlanu"
|
|
11
|
+
assert engine.format_number(21).text == "amashumi amabili nanye"
|
|
12
|
+
assert engine.format_number(47).text == "amashumi amane nesikhombisa"
|
|
13
|
+
assert engine.format_number(123).text == "ikhulu namashumi amabili nantathu"
|
|
14
|
+
assert (
|
|
15
|
+
engine.format_number(999).text
|
|
16
|
+
== "amakhulu ayisishiyagalolunye namashumi ayisishiyagalolunye nesishiyagalolunye"
|
|
17
|
+
)
|
|
18
|
+
assert engine.format_number(4000).text == "izinkulungwane ezine"
|
|
19
|
+
assert (
|
|
20
|
+
engine.format_number(8192).text
|
|
21
|
+
== "izinkulungwane eziyisishiyagalombili nekhulu namashumi ayisishiyagalolunye nambili"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
assert (
|
|
25
|
+
engine.format_number(15123).text
|
|
26
|
+
== "izinkulungwane eziyishumi nanhlanu nekhulu namashumi amabili nantathu"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# # 3.5 million
|
|
30
|
+
# assert (
|
|
31
|
+
# engine.format_number(3500000).text
|
|
32
|
+
# == "izigidi ezintathu namakhulu ayishihlanu ezinkulungwane"
|
|
33
|
+
# )
|
|
34
|
+
|
|
35
|
+
# # 12 million
|
|
36
|
+
# assert engine.format_number(12000000).text == "izigidi eziyishumi ezimbili"
|
|
@@ -10,9 +10,9 @@ from bisect import bisect_left
|
|
|
10
10
|
from dataclasses import dataclass, field
|
|
11
11
|
from decimal import Decimal
|
|
12
12
|
from enum import Enum, IntFlag, auto
|
|
13
|
-
from math import ceil, floor, isinf, isnan, log
|
|
13
|
+
from math import ceil, floor, isinf, isnan, log
|
|
14
14
|
from pathlib import Path
|
|
15
|
-
from typing import Dict, Final, Iterable, List, Optional, Set, Union
|
|
15
|
+
from typing import Dict, Final, Iterable, List, Optional, Set, Tuple, Union
|
|
16
16
|
from xml.etree import ElementTree as et
|
|
17
17
|
|
|
18
18
|
DEFAULT_TOLERANCE: Final = 1e-8
|
|
@@ -57,6 +57,11 @@ class FormatPurpose(Enum):
|
|
|
57
57
|
return FormatPurpose.UNKNOWN
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
_DEFAULT_RULESETS: Dict[Tuple[str, FormatPurpose], str] = {
|
|
61
|
+
("ko", FormatPurpose.CARDINAL): "spellout-cardinal-sinokorean",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
60
65
|
@dataclass
|
|
61
66
|
class FormatResult:
|
|
62
67
|
"""Result of formatting a number."""
|
|
@@ -64,6 +69,9 @@ class FormatResult:
|
|
|
64
69
|
text: str
|
|
65
70
|
"""Formatted text from shortest ruleset name."""
|
|
66
71
|
|
|
72
|
+
text_ruleset: str
|
|
73
|
+
"""Ruleset that was used for text."""
|
|
74
|
+
|
|
67
75
|
text_by_ruleset: Dict[str, str]
|
|
68
76
|
"""Formatted text for each ruleset."""
|
|
69
77
|
|
|
@@ -84,6 +92,19 @@ class RbnfRulePart(ABC):
|
|
|
84
92
|
"""Abstract base class for rule parts."""
|
|
85
93
|
|
|
86
94
|
|
|
95
|
+
class ParseState(str, Enum):
|
|
96
|
+
"""Set of rbnf parser."""
|
|
97
|
+
|
|
98
|
+
TEXT = "text"
|
|
99
|
+
SUB_OPTIONAL_BEFORE = "optional_before"
|
|
100
|
+
SUB_OPTIONAL_AFTER = "optional_after"
|
|
101
|
+
SUB_PLURAL_FORMAT = "plural_format"
|
|
102
|
+
SUB_REMAINDER = "remainder"
|
|
103
|
+
SUB_QUOTIENT = "quotient"
|
|
104
|
+
SUB_RULESET_NAME = "sub_ruleset_name"
|
|
105
|
+
REPLACE_RULESET_NAME = "replace_ruleset_name"
|
|
106
|
+
|
|
107
|
+
|
|
87
108
|
@dataclass
|
|
88
109
|
class TextRulePart(RbnfRulePart):
|
|
89
110
|
"""Literal text rule part."""
|
|
@@ -133,16 +154,66 @@ class ReplaceRulePart(RbnfRulePart):
|
|
|
133
154
|
"""Name of ruleset to use."""
|
|
134
155
|
|
|
135
156
|
|
|
136
|
-
|
|
137
|
-
|
|
157
|
+
@dataclass
|
|
158
|
+
class PluralFormatPart(RbnfRulePart):
|
|
159
|
+
"""Function with other ruleset (keep value)."""
|
|
138
160
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
function_name: str = ""
|
|
162
|
+
"""Function to use for substitution."""
|
|
163
|
+
|
|
164
|
+
function_value: str = ""
|
|
165
|
+
"""Value to use for fucntion substitution."""
|
|
166
|
+
|
|
167
|
+
previous_state: Optional[ParseState] = None
|
|
168
|
+
"""Previous state of parser."""
|
|
169
|
+
|
|
170
|
+
previous_part: Optional[RbnfRulePart] = None
|
|
171
|
+
"""Previous part of parser."""
|
|
172
|
+
|
|
173
|
+
def render(self, number: Union[int, float, Decimal]) -> str:
|
|
174
|
+
"""Render function with value."""
|
|
175
|
+
count_zero = self.function_value.count("0")
|
|
176
|
+
name_value = str(number)[:-count_zero]
|
|
177
|
+
value = Decimal(name_value[-1:])
|
|
178
|
+
value_many = Decimal(name_value[-2:])
|
|
179
|
+
|
|
180
|
+
clean_fn = self.function_name.replace("cardinal,", "").replace("ordinal,", "")
|
|
181
|
+
|
|
182
|
+
zero_match = re.search(r"zero\{(.*?)\}", clean_fn)
|
|
183
|
+
zero_value = zero_match.group(1) if zero_match else ""
|
|
184
|
+
if zero_match and zero_value and value == 0:
|
|
185
|
+
return zero_value
|
|
186
|
+
|
|
187
|
+
one_match = re.search(r"one\{(.*?)\}", clean_fn)
|
|
188
|
+
one_value = one_match.group(1) if one_match else ""
|
|
189
|
+
if one_match and one_value and value == 1:
|
|
190
|
+
return one_value
|
|
191
|
+
|
|
192
|
+
two_match = re.search(r"two\{(.*?)\}", clean_fn)
|
|
193
|
+
two_value = two_match.group(1) if two_match else ""
|
|
194
|
+
if two_match and two_value and value == 2:
|
|
195
|
+
return two_value
|
|
196
|
+
|
|
197
|
+
few_match = re.search(r"few\{(.*?)\}", clean_fn)
|
|
198
|
+
few_value = few_match.group(1) if few_match else ""
|
|
199
|
+
if few_match and few_value and value in [2, 3, 4]:
|
|
200
|
+
return few_value
|
|
201
|
+
|
|
202
|
+
many_match = re.search(r"many\{(.*?)\}", clean_fn)
|
|
203
|
+
many_value = many_match.group(1) if many_match else ""
|
|
204
|
+
if (
|
|
205
|
+
many_match
|
|
206
|
+
and few_value
|
|
207
|
+
and value_many in [11, 12, 13, 14, 15, 16, 17, 18, 19]
|
|
208
|
+
):
|
|
209
|
+
return few_value
|
|
210
|
+
|
|
211
|
+
other_match = re.search(r"other\{(.*?)\}", clean_fn)
|
|
212
|
+
other_value = other_match.group(1) if other_match else ""
|
|
213
|
+
if other_match and other_value:
|
|
214
|
+
return other_value
|
|
215
|
+
|
|
216
|
+
return many_value
|
|
146
217
|
|
|
147
218
|
|
|
148
219
|
class RbnfSpecialRule(str, Enum):
|
|
@@ -199,8 +270,13 @@ class RbnfRule:
|
|
|
199
270
|
part: Optional[RbnfRulePart] = None
|
|
200
271
|
is_sub_optional = False
|
|
201
272
|
sub_text_before = ""
|
|
273
|
+
skip_next_char = False
|
|
274
|
+
|
|
275
|
+
for x, c in enumerate(text):
|
|
276
|
+
if skip_next_char:
|
|
277
|
+
skip_next_char = False
|
|
278
|
+
continue
|
|
202
279
|
|
|
203
|
-
for c in text:
|
|
204
280
|
if c == ";":
|
|
205
281
|
# End of rule text
|
|
206
282
|
break
|
|
@@ -209,10 +285,24 @@ class RbnfRule:
|
|
|
209
285
|
# Placeholder
|
|
210
286
|
continue
|
|
211
287
|
|
|
288
|
+
next_c: Optional[str] = None
|
|
289
|
+
if (x + 1) < len(text):
|
|
290
|
+
next_c = text[x + 1]
|
|
291
|
+
|
|
212
292
|
if c in (">", "→"):
|
|
213
293
|
# Divide the number by the rule's divisor and format the remainder
|
|
214
294
|
if state in {ParseState.TEXT, ParseState.SUB_OPTIONAL_BEFORE}:
|
|
215
295
|
state = ParseState.SUB_REMAINDER
|
|
296
|
+
|
|
297
|
+
if rule.parts and isinstance(rule.parts[-1], TextRulePart):
|
|
298
|
+
# Shift whitespace before arrow here.
|
|
299
|
+
# This is so it separates words in fractional mode.
|
|
300
|
+
prev_text_part: TextRulePart = rule.parts[-1]
|
|
301
|
+
prev_text_stripped = prev_text_part.text.rstrip()
|
|
302
|
+
prev_whitespace = prev_text_part.text[len(prev_text_stripped) :]
|
|
303
|
+
prev_text_part.text = prev_text_stripped
|
|
304
|
+
sub_text_before += prev_whitespace
|
|
305
|
+
|
|
216
306
|
part = SubRulePart(
|
|
217
307
|
SubType.REMAINDER,
|
|
218
308
|
is_optional=is_sub_optional,
|
|
@@ -220,7 +310,14 @@ class RbnfRule:
|
|
|
220
310
|
)
|
|
221
311
|
rule.parts.append(part)
|
|
222
312
|
sub_text_before = ""
|
|
313
|
+
|
|
223
314
|
elif state in {ParseState.SUB_REMAINDER, ParseState.SUB_RULESET_NAME}:
|
|
315
|
+
if next_c in (">", "→"):
|
|
316
|
+
# Ignore final arrow in triple arrow.
|
|
317
|
+
# It means to render digit-by-digit, which we already do
|
|
318
|
+
# in "fractional" mode.
|
|
319
|
+
skip_next_char = True
|
|
320
|
+
|
|
224
321
|
if is_sub_optional:
|
|
225
322
|
state = ParseState.SUB_OPTIONAL_AFTER
|
|
226
323
|
else:
|
|
@@ -255,6 +352,24 @@ class RbnfRule:
|
|
|
255
352
|
pass
|
|
256
353
|
else:
|
|
257
354
|
raise ValueError(f"Got {c} in {state}")
|
|
355
|
+
elif c == "$":
|
|
356
|
+
# $(cardinal,plural syntax)$, $(ordinal,plural syntax)$
|
|
357
|
+
if text[x + 1] == "(":
|
|
358
|
+
_previous_state = state
|
|
359
|
+
_previous_part = part
|
|
360
|
+
state = ParseState.SUB_PLURAL_FORMAT
|
|
361
|
+
part = PluralFormatPart()
|
|
362
|
+
part.function_value = value_str
|
|
363
|
+
part.previous_state = _previous_state
|
|
364
|
+
part.previous_part = _previous_part
|
|
365
|
+
elif state == ParseState.SUB_PLURAL_FORMAT and text[x - 1] == ")":
|
|
366
|
+
assert isinstance(part, PluralFormatPart)
|
|
367
|
+
assert part.previous_state is not None
|
|
368
|
+
rule.parts.append(part)
|
|
369
|
+
state = part.previous_state
|
|
370
|
+
part = part.previous_part
|
|
371
|
+
else:
|
|
372
|
+
raise ValueError(f"Got {c} in {state} fot text: {text} (x: {x})")
|
|
258
373
|
elif c == "[":
|
|
259
374
|
# [optional] (start)
|
|
260
375
|
if state == ParseState.TEXT:
|
|
@@ -289,6 +404,10 @@ class RbnfRule:
|
|
|
289
404
|
# [... after]
|
|
290
405
|
assert isinstance(part, SubRulePart)
|
|
291
406
|
part.text_after += c
|
|
407
|
+
elif state == ParseState.SUB_PLURAL_FORMAT:
|
|
408
|
+
assert isinstance(part, PluralFormatPart)
|
|
409
|
+
if c not in ["(", ")"]:
|
|
410
|
+
part.function_name += c
|
|
292
411
|
elif state == ParseState.SUB_RULESET_NAME:
|
|
293
412
|
# %ruleset_name in << or >>
|
|
294
413
|
assert isinstance(part, SubRulePart)
|
|
@@ -336,6 +455,9 @@ class RbnfRuleSet:
|
|
|
336
455
|
special_rules: Dict[RbnfSpecialRule, RbnfRule] = field(default_factory=dict)
|
|
337
456
|
"""Rules keyed by special rule type."""
|
|
338
457
|
|
|
458
|
+
is_private: bool = False
|
|
459
|
+
"""True if ruleset is private."""
|
|
460
|
+
|
|
339
461
|
_sorted_numbers: Optional[List[int]] = field(default=None)
|
|
340
462
|
"""Sorted list of numeric_rules keys (updated on demand)."""
|
|
341
463
|
|
|
@@ -462,12 +584,13 @@ class RbnfEngine:
|
|
|
462
584
|
rule_text: str,
|
|
463
585
|
ruleset_name: str,
|
|
464
586
|
radix: int = 10,
|
|
587
|
+
is_private: bool = False,
|
|
465
588
|
) -> Optional[RbnfRule]:
|
|
466
589
|
"""Manually add a rule to the engine."""
|
|
467
590
|
assert ruleset_name is not None
|
|
468
591
|
ruleset = self.rulesets.get(ruleset_name)
|
|
469
592
|
if ruleset is None:
|
|
470
|
-
ruleset = RbnfRuleSet(name=ruleset_name)
|
|
593
|
+
ruleset = RbnfRuleSet(name=ruleset_name, is_private=is_private)
|
|
471
594
|
self.rulesets[ruleset_name] = ruleset
|
|
472
595
|
|
|
473
596
|
rule = RbnfRule.parse(value_str, rule_text, radix=radix)
|
|
@@ -499,6 +622,8 @@ class RbnfEngine:
|
|
|
499
622
|
_LOGGER.debug("Skipping ruleset: %s", ruleset_name)
|
|
500
623
|
continue
|
|
501
624
|
|
|
625
|
+
is_private = group_elem.attrib.get("access") == "private"
|
|
626
|
+
|
|
502
627
|
for rule_elem in group_elem.findall("rbnfrule"):
|
|
503
628
|
if not rule_elem.text:
|
|
504
629
|
continue
|
|
@@ -511,6 +636,7 @@ class RbnfEngine:
|
|
|
511
636
|
rule_elem.text,
|
|
512
637
|
ruleset_name,
|
|
513
638
|
radix=radix,
|
|
639
|
+
is_private=is_private,
|
|
514
640
|
)
|
|
515
641
|
|
|
516
642
|
def format_number(
|
|
@@ -529,10 +655,11 @@ class RbnfEngine:
|
|
|
529
655
|
if ruleset_names is None:
|
|
530
656
|
# Gather all rulesets that fit the formatting purpose
|
|
531
657
|
ruleset_names = [
|
|
532
|
-
|
|
533
|
-
for r in self.rulesets
|
|
534
|
-
if
|
|
535
|
-
and (
|
|
658
|
+
r_name
|
|
659
|
+
for r_name, r in self.rulesets.items()
|
|
660
|
+
if (not r.is_private)
|
|
661
|
+
and (FormatPurpose.from_ruleset_name(r_name) == purpose)
|
|
662
|
+
and ("verbose" not in r_name)
|
|
536
663
|
]
|
|
537
664
|
|
|
538
665
|
if not ruleset_names:
|
|
@@ -564,10 +691,20 @@ class RbnfEngine:
|
|
|
564
691
|
if not number_strs:
|
|
565
692
|
raise NoRuleForNumberError(f"No rules were successful for {number}")
|
|
566
693
|
|
|
567
|
-
|
|
694
|
+
# Put spellout-numbering at the end
|
|
695
|
+
default_ruleset = _DEFAULT_RULESETS.get((self.language, purpose))
|
|
696
|
+
if (not default_ruleset) or (default_ruleset not in number_strs):
|
|
697
|
+
default_ruleset = "spellout-numbering"
|
|
698
|
+
|
|
699
|
+
if default_ruleset not in number_strs:
|
|
700
|
+
# Use ruleset with shortest length.
|
|
701
|
+
# Silly, but works most of the time.
|
|
702
|
+
default_ruleset = sorted(number_strs, key=len)[0]
|
|
568
703
|
|
|
569
704
|
return FormatResult(
|
|
570
|
-
text=number_strs[
|
|
705
|
+
text=number_strs[default_ruleset],
|
|
706
|
+
text_ruleset=default_ruleset,
|
|
707
|
+
text_by_ruleset=number_strs,
|
|
571
708
|
)
|
|
572
709
|
|
|
573
710
|
def iter_format_number(
|
|
@@ -594,35 +731,43 @@ class RbnfEngine:
|
|
|
594
731
|
|
|
595
732
|
q: int = 0
|
|
596
733
|
r: int = 0
|
|
734
|
+
r_digits: Optional[str] = None
|
|
597
735
|
|
|
598
736
|
if isinstance(rule.value, RbnfSpecialRule):
|
|
599
737
|
if rule.value == RbnfSpecialRule.NEGATIVE_NUMBER:
|
|
600
738
|
r = int(-number)
|
|
601
739
|
elif rule.value == RbnfSpecialRule.IMPROPER_FRACTION:
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
740
|
+
dec_num = Decimal(str(number))
|
|
741
|
+
q_str, r_digits = str(dec_num).split(".", maxsplit=1)
|
|
742
|
+
q = int(q_str)
|
|
605
743
|
elif rule.value in {RbnfSpecialRule.NOT_A_NUMBER, RbnfSpecialRule.INFINITY}:
|
|
606
744
|
# Should just be text substitutions
|
|
607
745
|
pass
|
|
608
746
|
else:
|
|
609
747
|
_LOGGER.warning("Unhandled special rule: %s", rule.value)
|
|
610
748
|
elif rule.value > 0:
|
|
749
|
+
if len(str(rule.value)) > 1 and str(rule.value)[0] != "1":
|
|
750
|
+
rule.value = int("1" + str(rule.value)[1:])
|
|
611
751
|
power_below = rule.radix ** int(floor(log(rule.value, rule.radix)))
|
|
612
752
|
power_above = rule.radix ** int(ceil(log(rule.value, rule.radix)))
|
|
613
753
|
divisor = power_above if (number >= power_above) else power_below
|
|
614
|
-
q, r = divmod(number, divisor)
|
|
754
|
+
q, r = divmod(int(number), divisor)
|
|
615
755
|
|
|
616
756
|
for part in rule.parts:
|
|
617
757
|
if isinstance(part, TextRulePart):
|
|
618
758
|
if part.text:
|
|
619
759
|
yield part.text
|
|
760
|
+
elif isinstance(part, PluralFormatPart):
|
|
761
|
+
if part.function_name:
|
|
762
|
+
yield part.render(number)
|
|
620
763
|
elif isinstance(part, SubRulePart):
|
|
621
764
|
sub_part: SubRulePart = part
|
|
622
765
|
|
|
623
766
|
if part.type == SubType.QUOTIENT:
|
|
624
|
-
if (
|
|
625
|
-
|
|
767
|
+
if (
|
|
768
|
+
(q == 0)
|
|
769
|
+
and (sub_part.is_optional or (part.ruleset_name is None))
|
|
770
|
+
and (not r_digits)
|
|
626
771
|
):
|
|
627
772
|
# Rulesets can use quotients of zero
|
|
628
773
|
continue
|
|
@@ -637,19 +782,39 @@ class RbnfEngine:
|
|
|
637
782
|
if part.text_after:
|
|
638
783
|
yield part.text_after
|
|
639
784
|
elif part.type == SubType.REMAINDER:
|
|
640
|
-
if (
|
|
641
|
-
|
|
785
|
+
if (
|
|
786
|
+
(r == 0)
|
|
787
|
+
and (sub_part.is_optional or (part.ruleset_name is None))
|
|
788
|
+
and (not r_digits)
|
|
642
789
|
):
|
|
643
790
|
# Rulesets can use remainders of zero
|
|
644
791
|
continue
|
|
645
792
|
|
|
793
|
+
if r_digits:
|
|
794
|
+
# Render digit-by-digit
|
|
795
|
+
for digit_str in r_digits:
|
|
796
|
+
digit = int(digit_str)
|
|
797
|
+
|
|
798
|
+
if part.text_before:
|
|
799
|
+
yield part.text_before
|
|
800
|
+
yield from self.iter_format_number(
|
|
801
|
+
digit,
|
|
802
|
+
ruleset_name=part.ruleset_name or ruleset_name,
|
|
803
|
+
tolerance=tolerance,
|
|
804
|
+
)
|
|
805
|
+
if part.text_after:
|
|
806
|
+
yield part.text_after
|
|
807
|
+
continue
|
|
808
|
+
|
|
646
809
|
if part.text_before:
|
|
647
810
|
yield part.text_before
|
|
811
|
+
|
|
648
812
|
yield from self.iter_format_number(
|
|
649
813
|
r,
|
|
650
814
|
ruleset_name=part.ruleset_name or ruleset_name,
|
|
651
815
|
tolerance=tolerance,
|
|
652
816
|
)
|
|
817
|
+
|
|
653
818
|
if part.text_after:
|
|
654
819
|
yield part.text_after
|
|
655
820
|
elif isinstance(part, ReplaceRulePart):
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE ldml SYSTEM "../../common/dtd/ldml.dtd">
|
|
3
|
+
<ldml>
|
|
4
|
+
<identity>
|
|
5
|
+
<version number="1.0"/>
|
|
6
|
+
<language type="zu"/> <!-- Zulu locale -->
|
|
7
|
+
</identity>
|
|
8
|
+
<rbnf>
|
|
9
|
+
<rulesetGrouping type="SpelloutRules">
|
|
10
|
+
<ruleset type="spellout-numbering">
|
|
11
|
+
<rbnfrule value="0">=%spellout-cardinal=;</rbnfrule>
|
|
12
|
+
</ruleset>
|
|
13
|
+
|
|
14
|
+
<ruleset type="spellout-cardinal">
|
|
15
|
+
<!-- ones -->
|
|
16
|
+
<rbnfrule value="0">iqanda;</rbnfrule>
|
|
17
|
+
<rbnfrule value="1">kunye;</rbnfrule>
|
|
18
|
+
<rbnfrule value="2">kubili;</rbnfrule>
|
|
19
|
+
<rbnfrule value="3">kuthathu;</rbnfrule>
|
|
20
|
+
<rbnfrule value="4">kune;</rbnfrule>
|
|
21
|
+
<rbnfrule value="5">kuhlanu;</rbnfrule>
|
|
22
|
+
<rbnfrule value="6">isithupha;</rbnfrule>
|
|
23
|
+
<rbnfrule value="7">isikhombisa;</rbnfrule>
|
|
24
|
+
<rbnfrule value="8">isishiyagalombili;</rbnfrule>
|
|
25
|
+
<rbnfrule value="9">isishiyagalolunye;</rbnfrule>
|
|
26
|
+
|
|
27
|
+
<!-- tens -->
|
|
28
|
+
<rbnfrule value="10">ishumi[ →%%spellout-cardinal-and→];</rbnfrule>
|
|
29
|
+
<rbnfrule value="20">amashumi amabili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
30
|
+
<rbnfrule value="30">amashumi amathathu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
31
|
+
<rbnfrule value="40">amashumi amane[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
32
|
+
<rbnfrule value="50">amashumi amahlanu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
33
|
+
<rbnfrule value="60">amashumi ayisithupha[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
34
|
+
<rbnfrule value="70">amashumi ayisikhombisa[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
35
|
+
<rbnfrule value="80">amashumi ayisishiyagalombili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
36
|
+
<rbnfrule value="90">amashumi ayisishiyagalolunye[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
37
|
+
|
|
38
|
+
<!-- hundreds -->
|
|
39
|
+
<rbnfrule value="100">ikhulu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
40
|
+
<rbnfrule value="200">amakhulu amabili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
41
|
+
<rbnfrule value="300">amakhulu amathathu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
42
|
+
<rbnfrule value="400">amakhulu amane[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
43
|
+
<rbnfrule value="500">amakhulu amahlanu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
44
|
+
<rbnfrule value="600">amakhulu ayisithupha[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
45
|
+
<rbnfrule value="700">amakhulu ayisikhombisa[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
46
|
+
<rbnfrule value="800">amakhulu ayisishiyagalombili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
47
|
+
<rbnfrule value="900">amakhulu ayisishiyagalolunye[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
48
|
+
|
|
49
|
+
<!-- thousands -->
|
|
50
|
+
<rbnfrule value="1000">inkulungwane[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
51
|
+
<rbnfrule value="2000">izinkulungwane ezimbili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
52
|
+
<rbnfrule value="3000">izinkulungwane ezintathu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
53
|
+
<rbnfrule value="4000">izinkulungwane ezine[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
54
|
+
<rbnfrule value="5000">izinkulungwane ezinhlanu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
55
|
+
<rbnfrule value="6000">izinkulungwane eziyisithupha[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
56
|
+
<rbnfrule value="7000">izinkulungwane eziyisikhombisa[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
57
|
+
<rbnfrule value="8000">izinkulungwane eziyisishiyagalombili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
58
|
+
<rbnfrule value="9000">izinkulungwane eziyisishiyagalolunye[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
59
|
+
|
|
60
|
+
<!-- tens of thousands -->
|
|
61
|
+
<rbnfrule value="10000">izinkulungwane eziyishumi[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
62
|
+
<rbnfrule value="11000" radix="110">izinkulungwane eziyishumi nanye[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
63
|
+
<rbnfrule value="12000" radix="120">izinkulungwane eziyishumi nambili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
64
|
+
<rbnfrule value="13000" radix="130">izinkulungwane eziyishumi nantathu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
65
|
+
<rbnfrule value="14000" radix="140">izinkulungwane eziyishumi nane[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
66
|
+
<rbnfrule value="15000" radix="150">izinkulungwane eziyishumi nanhlanu[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
67
|
+
<rbnfrule value="16000" radix="160">izinkulungwane eziyishumi nesithupha[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
68
|
+
<rbnfrule value="17000" radix="170">izinkulungwane eziyishumi nesikhombisa[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
69
|
+
<rbnfrule value="18000" radix="180">izinkulungwane eziyishumi nesishiyagalombili[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
70
|
+
<rbnfrule value="19000" radix="190">izinkulungwane eziyishumi nesishiyagalolunye[ →%%spellout-cardinal-and→]</rbnfrule>
|
|
71
|
+
</ruleset>
|
|
72
|
+
|
|
73
|
+
<ruleset type="spellout-cardinal-and" access="private">
|
|
74
|
+
<!-- ones -->
|
|
75
|
+
<rbnfrule value="1">nanye;</rbnfrule>
|
|
76
|
+
<rbnfrule value="2">nambili;</rbnfrule>
|
|
77
|
+
<rbnfrule value="3">nantathu;</rbnfrule>
|
|
78
|
+
<rbnfrule value="4">nane;</rbnfrule>
|
|
79
|
+
<rbnfrule value="5">nanhlanu;</rbnfrule>
|
|
80
|
+
<rbnfrule value="6">nesithupha;</rbnfrule>
|
|
81
|
+
<rbnfrule value="7">nesikhombisa;</rbnfrule>
|
|
82
|
+
<rbnfrule value="8">nesishiyagalombili;</rbnfrule>
|
|
83
|
+
<rbnfrule value="9">nesishiyagalolunye;</rbnfrule>
|
|
84
|
+
|
|
85
|
+
<!-- tens -->
|
|
86
|
+
<rbnfrule value="10">neshumi[ →→];</rbnfrule>
|
|
87
|
+
<rbnfrule value="20">namashumi amabili[ →→]</rbnfrule>
|
|
88
|
+
<rbnfrule value="30">namashumi amathathu[ →→]</rbnfrule>
|
|
89
|
+
<rbnfrule value="40">namashumi amane[ →→]</rbnfrule>
|
|
90
|
+
<rbnfrule value="50">namashumi amahlanu[ →→]</rbnfrule>
|
|
91
|
+
<rbnfrule value="60">namashumi ayisithupha[ →→]</rbnfrule>
|
|
92
|
+
<rbnfrule value="70">namashumi ayisikhombisa[ →→]</rbnfrule>
|
|
93
|
+
<rbnfrule value="80">namashumi ayisishiyagalombili[ →→]</rbnfrule>
|
|
94
|
+
<rbnfrule value="90">namashumi ayisishiyagalolunye[ →→]</rbnfrule>
|
|
95
|
+
|
|
96
|
+
<!-- hundreds -->
|
|
97
|
+
<rbnfrule value="100">nekhulu[ →→]</rbnfrule>
|
|
98
|
+
<rbnfrule value="200">namakhulu amabili[ →→]</rbnfrule>
|
|
99
|
+
<rbnfrule value="300">namakhulu amathathu[ →→]</rbnfrule>
|
|
100
|
+
<rbnfrule value="400">namakhulu amane[ →→]</rbnfrule>
|
|
101
|
+
<rbnfrule value="500">namakhulu amahlanu[ →→]</rbnfrule>
|
|
102
|
+
<rbnfrule value="600">namakhulu ayisithupha[ →→]</rbnfrule>
|
|
103
|
+
<rbnfrule value="700">namakhulu ayisikhombisa[ →→]</rbnfrule>
|
|
104
|
+
<rbnfrule value="800">namakhulu ayisishiyagalombili[ →→]</rbnfrule>
|
|
105
|
+
<rbnfrule value="900">namakhulu ayisishiyagalolunye[ →→]</rbnfrule>
|
|
106
|
+
|
|
107
|
+
<!-- thousands -->
|
|
108
|
+
<rbnfrule value="1000">nenkulungwane[ →→]</rbnfrule>
|
|
109
|
+
<rbnfrule value="2000">nezinkulungwane ezimbili[ →→]</rbnfrule>
|
|
110
|
+
<rbnfrule value="3000">nezinkulungwane ezintathu[ →→]</rbnfrule>
|
|
111
|
+
<rbnfrule value="4000">nezinkulungwane ezine[ →→]</rbnfrule>
|
|
112
|
+
<rbnfrule value="5000">nezinkulungwane ezinhlanu[ →→]</rbnfrule>
|
|
113
|
+
<rbnfrule value="6000">nezinkulungwane eziyisithupha[ →→]</rbnfrule>
|
|
114
|
+
<rbnfrule value="7000">nezinkulungwane eziyisikhombisa[ →→]</rbnfrule>
|
|
115
|
+
<rbnfrule value="8000">nezinkulungwane eziyisishiyagalombili[ →→]</rbnfrule>
|
|
116
|
+
<rbnfrule value="9000">nezinkulungwane eziyisishiyagalolunye[ →→]</rbnfrule>
|
|
117
|
+
</ruleset>
|
|
118
|
+
</rulesetGrouping>
|
|
119
|
+
</rbnf>
|
|
120
|
+
</ldml>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: unicode-rbnf
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Rule-based number formatting using Unicode CLDR data
|
|
5
5
|
Author-email: Michael Hansen <mike@rhasspy.org>
|
|
6
6
|
License: MIT
|
|
@@ -20,6 +20,14 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
20
20
|
Requires-Python: >=3.8.0
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: black==24.8.0; extra == "dev"
|
|
25
|
+
Requires-Dist: flake8==7.1.1; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy==1.14.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pylint==3.2.7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest==8.3.4; extra == "dev"
|
|
29
|
+
Requires-Dist: build==1.2.2; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
23
31
|
|
|
24
32
|
# Unicode RBNF
|
|
25
33
|
|
|
@@ -9,9 +9,12 @@ tests/test_engine.py
|
|
|
9
9
|
tests/test_es.py
|
|
10
10
|
tests/test_fi.py
|
|
11
11
|
tests/test_fr.py
|
|
12
|
+
tests/test_ko.py
|
|
12
13
|
tests/test_load_all.py
|
|
14
|
+
tests/test_pl.py
|
|
13
15
|
tests/test_ro.py
|
|
14
16
|
tests/test_sl.py
|
|
17
|
+
tests/test_zu.py
|
|
15
18
|
unicode_rbnf/__init__.py
|
|
16
19
|
unicode_rbnf/__main__.py
|
|
17
20
|
unicode_rbnf/decimal_format.py
|
|
@@ -20,6 +23,7 @@ unicode_rbnf/py.typed
|
|
|
20
23
|
unicode_rbnf.egg-info/PKG-INFO
|
|
21
24
|
unicode_rbnf.egg-info/SOURCES.txt
|
|
22
25
|
unicode_rbnf.egg-info/dependency_links.txt
|
|
26
|
+
unicode_rbnf.egg-info/requires.txt
|
|
23
27
|
unicode_rbnf.egg-info/top_level.txt
|
|
24
28
|
unicode_rbnf.egg-info/zip-safe
|
|
25
29
|
unicode_rbnf/rbnf/af.xml
|
|
@@ -111,4 +115,5 @@ unicode_rbnf/rbnf/vi.xml
|
|
|
111
115
|
unicode_rbnf/rbnf/yue.xml
|
|
112
116
|
unicode_rbnf/rbnf/yue_Hans.xml
|
|
113
117
|
unicode_rbnf/rbnf/zh.xml
|
|
114
|
-
unicode_rbnf/rbnf/zh_Hant.xml
|
|
118
|
+
unicode_rbnf/rbnf/zh_Hant.xml
|
|
119
|
+
unicode_rbnf/rbnf/zu.xml
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|