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.2.1)

: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 reverse 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

  • [x] Make POC, functional for all common cases
  • [x] Ordinal number support
  • [x] Take care for exceptions / trailing whitespaces etc.
  • [x] Make structure + publish as PyPI package
  • [x] 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
  • [ ] Support for fractions?

Project details


Download files

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

Files for zahlwort2num, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size zahlwort2num-0.2.1-py3-none-any.whl (7.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size zahlwort2num-0.2.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page