Skip to main content

A small package for handy conversion of german numerals (also ordinal / signed) written as words to numbers.

Project description

zahlwort2num (v. 0.1.6)

:de: :de: :de: A small but useful (due shortage of/low quality support for lang_DE) package for handy conversion of german numerals (incl. ordinal number) written as string to the from numbers.

To put it differently it allows: rnverse text normalization for numbers.

This package might be a good complementary lib to https://github.com/savoirfairelinux/num2words

:crying_cat_face: Currently is doesn't support swiss variant. TBD :switzerland:

PyPi direct page of project

https://pypi.org/project/zahlwort2num/

Installation

pip2 install zahlwort2num

Usage

Definition:

import zahlwort2num as w2n

Example:

w2n.convert("Zweihundertfünfundzwanzig") # => 225
w2n.convert("neunte") # => '9.' 
w2n.convert("minus siebenhundert Millionen achtundsiebzig") # => -700000078

or even stuff like:

w2n.convert("sechshundertdreiundfünfzigtausendfünfhunderteinundzwanzig") # => 653521

:see_no_evil:

Command line:

  • (Obviously it is better to use a parameter enclosed with apostrophs due to possible spaces)
bin/zahlwort2num-convert "eine Million siebenhunderteinundzwanzig"

WIKI

TBD

Already implemented features :sunglasses:

  • Theoretically it works for any numbers from range 0 upto 999 * 10^27 [big numbers]
  • Command-line mode (see above)
  • Supported with ordinal numerals (incl. inflections [sufficies like 'ste', 'ten' etc. ])
    In this case it returns coerced String type value e.g '15.' instead of Integer :point_up:
  • Relative mild rules in terms of trailing whitespaces, lower/upper-case (unification).
  • Handling of signed numerals (also ordinal ones) e.g 'minus zehn'

TODO / Known issues

  • Make POC, functional for all common cases
  • Ordinal number support
  • Take care for exceptions / trailing whitespaces etc.
  • Make structure + publish as PyPI package
  • Command line support :computer:
  • More comprehensible tests
  • Swiss variant
  • More fault tolerant (ß -> ss) etc
  • Larger scale than 10^60
  • Ordinal with very large numbers (without addons) e.g Millionste
  • Few benchmark improvements (e.g tail recursion etc)
  • Better error handling + validation for idiotical cases (e.g minus null Miliarde)
  • Simplify/refactor POC code, add better documentation
  • Fractions?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zahlwort2num-0.1.7.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zahlwort2num-0.1.7-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file zahlwort2num-0.1.7.tar.gz.

File metadata

  • Download URL: zahlwort2num-0.1.7.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for zahlwort2num-0.1.7.tar.gz
Algorithm Hash digest
SHA256 112abdd6e87c68077b57a3cc77e2af03952c0f4149a01b4e82d5d9349b6fbdfd
MD5 4d2b38378f6f65558e94ad8cc5f4f827
BLAKE2b-256 c9bba2ca98667a481d24b67f16c4a0d78acf2a863268880833d777f65c1243d7

See more details on using hashes here.

File details

Details for the file zahlwort2num-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: zahlwort2num-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for zahlwort2num-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e3310b5c2bd5636fb2d7b899d56d0dde4b11a30a43642fffc67c334f145bb014
MD5 b6801948a2ee6f82ad188f01d1708596
BLAKE2b-256 ed9c19af3951b6c8473f26b99e419d6f72a6bc2f1f7351150d44fd9aa7be2529

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page