unicode-rbnf


Nameunicode-rbnf JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttp://github.com/rhasspy/unicode-rbnf
SummaryRule-based number formatting using Unicode CLDR data
upload_time2024-02-06 16:36:47
maintainer
docs_urlNone
authorMichael Hansen
requires_python
licenseMIT
keywords rbnf unicode number format
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Unicode RBNF

A pure Python implementation of [rule based number formatting](https://icu-project.org/docs/papers/a_rule_based_approach_to_number_spellout/) (RBNF) using the [Unicode Common Locale Data Repository](https://cldr.unicode.org) (CLDR).

This lets you spell out numbers for a large number of locales:

``` python
from unicode_rbnf import RbnfEngine

engine = RbnfEngine.for_language("en")
assert engine.format_number(1234) == "one thousand two hundred thirty-four"
```

Depending on the locale, different rulesets are supported as well:

``` python
from unicode_rbnf import RbnfEngine, RulesetName

engine = RbnfEngine.for_language("en")
assert engine.format_number(1999, RulesetName.YEAR) == "nineteen ninety-nine"
assert engine.format_number(11, RulesetName.ORDINAL) == "eleventh"
```

## Supported locales

See: https://github.com/unicode-org/cldr/tree/release-44/common/rbnf

## Engine implementation

Not [all features](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classRuleBasedNumberFormat.html) of the RBNF engine are implemented. The following features are available:

* Literal text (`hundred`)
* Quotient substitution (`<<` or `←←`)
* Reminder substitution (`>>` or `→→`)
* Optional substitution (`[...]`)
* Rule substituton (`←%ruleset_name←`)
* Rule replacement (`=%ruleset_name=`)
* Special rules:
    * Negative numbers (`-x`)
    * Improper fractions (`x.x`)
    * Not a number (`NaN`)
    * Infinity (`Inf`)
    
Some features that will need to be added eventually:

* Proper fraction rules (`0.x`)
* Preceding reminder substitution (`>>>` or `→→→`)
* Number format strings (`==`)

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/rhasspy/unicode-rbnf",
    "name": "unicode-rbnf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "rbnf unicode number format",
    "author": "Michael Hansen",
    "author_email": "mike@rhasspy.org",
    "download_url": "",
    "platform": null,
    "description": "# Unicode RBNF\n\nA pure Python implementation of [rule based number formatting](https://icu-project.org/docs/papers/a_rule_based_approach_to_number_spellout/) (RBNF) using the [Unicode Common Locale Data Repository](https://cldr.unicode.org) (CLDR).\n\nThis lets you spell out numbers for a large number of locales:\n\n``` python\nfrom unicode_rbnf import RbnfEngine\n\nengine = RbnfEngine.for_language(\"en\")\nassert engine.format_number(1234) == \"one thousand two hundred thirty-four\"\n```\n\nDepending on the locale, different rulesets are supported as well:\n\n``` python\nfrom unicode_rbnf import RbnfEngine, RulesetName\n\nengine = RbnfEngine.for_language(\"en\")\nassert engine.format_number(1999, RulesetName.YEAR) == \"nineteen ninety-nine\"\nassert engine.format_number(11, RulesetName.ORDINAL) == \"eleventh\"\n```\n\n## Supported locales\n\nSee: https://github.com/unicode-org/cldr/tree/release-44/common/rbnf\n\n## Engine implementation\n\nNot [all features](https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classRuleBasedNumberFormat.html) of the RBNF engine are implemented. The following features are available:\n\n* Literal text (`hundred`)\n* Quotient substitution (`<<` or `\u2190\u2190`)\n* Reminder substitution (`>>` or `\u2192\u2192`)\n* Optional substitution (`[...]`)\n* Rule substituton (`\u2190%ruleset_name\u2190`)\n* Rule replacement (`=%ruleset_name=`)\n* Special rules:\n    * Negative numbers (`-x`)\n    * Improper fractions (`x.x`)\n    * Not a number (`NaN`)\n    * Infinity (`Inf`)\n    \nSome features that will need to be added eventually:\n\n* Proper fraction rules (`0.x`)\n* Preceding reminder substitution (`>>>` or `\u2192\u2192\u2192`)\n* Number format strings (`==`)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Rule-based number formatting using Unicode CLDR data",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "http://github.com/rhasspy/unicode-rbnf"
    },
    "split_keywords": [
        "rbnf",
        "unicode",
        "number",
        "format"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2d2a5192e0ba2d151e89b7160acac463d7e10f8f1a606db565f36d0774a2d5b",
                "md5": "e837ac9a3bf102cb55b47fd2ab832031",
                "sha256": "b214131d7998ed05af24407e2bead8c131e7464e418547412217c8376a75ef55"
            },
            "downloads": -1,
            "filename": "unicode_rbnf-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e837ac9a3bf102cb55b47fd2ab832031",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 136653,
            "upload_time": "2024-02-06T16:36:47",
            "upload_time_iso_8601": "2024-02-06T16:36:47.929027Z",
            "url": "https://files.pythonhosted.org/packages/b2/d2/a5192e0ba2d151e89b7160acac463d7e10f8f1a606db565f36d0774a2d5b/unicode_rbnf-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 16:36:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rhasspy",
    "github_project": "unicode-rbnf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "unicode-rbnf"
}
        
Elapsed time: 0.19302s