Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
A pure Python implementation of rule based number formatting (RBNF) using the Unicode Common Locale Data Repository (CLDR).
This lets you spell out numbers for a large number of locales:
from unicode_rbnf import RbnfEngine
engine = RbnfEngine.for_language("en")
assert engine.format_number(1234).text == "one thousand two hundred thirty-four"
Different formatting purposes are supported as well, depending on the locale:
from unicode_rbnf import RbnfEngine, FormatPurpose
engine = RbnfEngine.for_language("en")
assert engine.format_number(1999, FormatPurpose.CARDINAL).text == "one thousand nine hundred ninety-nine"
assert engine.format_number(1999, FormatPurpose.YEAR).text == "nineteen ninety-nine"
assert engine.format_number(11, FormatPurpose.ORDINAL).text == "eleventh"
For locales with multiple genders, cases, etc., the different texts are accessible in the result of format_number
:
from unicode_rbnf import RbnfEngine
engine = RbnfEngine.for_language("de")
print(engine.format_number(1))
Result:
FormatResult(
text='eins',
text_by_ruleset={
'spellout-numbering': 'eins',
'spellout-cardinal-neuter': 'ein',
'spellout-cardinal-masculine': 'ein',
'spellout-cardinal-feminine': 'eine',
'spellout-cardinal-n': 'einen',
'spellout-cardinal-r': 'einer',
'spellout-cardinal-s': 'eines',
'spellout-cardinal-m': 'einem'
}
)
The text
property of the result holds the text of the ruleset with the shortest name (least specific).
See: https://github.com/unicode-org/cldr/tree/release-44/common/rbnf
Not all features of the RBNF engine are implemented. The following features are available:
hundred
)<<
or ←←
)>>
or →→
)[...]
)←%ruleset_name←
)=%ruleset_name=
)-x
)x.x
)NaN
)Inf
)Some features that will need to be added eventually:
0.x
)>>>
or →→→
)==
)#,##0.00
)$(ordinal,one{st}...)
)FAQs
Rule-based number formatting using Unicode CLDR data
We found that unicode-rbnf demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.