Skip to main content

A package that expands Icelandic numbers to their corresponding written form

Project description

Númi

Númi er pakki sem stafar út tölustafi. Þegar notandinn gefur Núma tölu ásamt streng sem inniheldur upplýsingar um beygingar skilar hann öllum mögulegum leiðum sem þessi tala getur verið stöfðu út.

This package expands Icelandic numbers to their corresponding written form. Given a digit and a string containing the case, gender and inflection the funciton will output a list of strings for all written variants.

Usage

To get started run

pip install numi

The main function in Númi is spell_out. It takes in two parameters, a number and a string specifying the desired morphology.

In the following example, we want to get the number 124 in plural, masculine and nominative form.

> from numi import spell_out
> print(spell_out(124, "ft_kk_nf")

> [124, "ft_kk_nf", ["eitt hundrað tuttugu og fjórir", "hundrað tuttugu og fjórir"]]

The spell_out function parses the input string so that the order of the values is not irrelevant. If one or all of the three values (number, gender, case) Numi will fill in all possible forms for that number. Note that the output will contain the string for the form values.

In the following example, the value for the case is omitted and Numi will fill in all possible declensions


> print(spell_out((92, "ft_kvk"))
>  [[92, 'ft_kvk_nf', ['níutíu og tvær']], 
    [92, 'ft_kvk_þf', ['níutíu og tvær']],
    [92, 'ft_kvk_þgf', ['níutíu og tveimur', 'níutíu og tveim']],
    [92, 'ft_kvk_ef', ['níutíu og tveggja']]]

All the abbreviations for the input string are as follows:

Abbr. English Icelandic
et singular eintala
ft plural fleirtala
kk masculine karlkyns
kvk feminine kvenkyns
hk neuter hvorugkyns
nf nominative nefnifall
þf accusative þolfall
þgf dative þágufall
ef genitive eignafall

The Icelandic number system isn't the simplest (to state it lightly). The numbers one to four are declined for the respective cases and genders, of them the number 1 has both a singular and plural form. Other numbers are not declined, except for those that are actually nouns.

Numbers other than 1-4 that are also not nouns have the shorthand:

at_af (án tölu og án fallbeygingar) 

(This is probably not a linguistically correct term and will be changed once the author is scolded by a linguist)

Contributing

This package is a work in progress. Rough ideas of development are listed in the project status.

There are probably some error that can be found and comments and corrects are highly welcomed.

To contribute please install the requiements file and use the tests/test_numi.py file with pytest for development testing.

Setting up:

python venv .venv
python -m pip install -r requirements_dev.txt
pip install -e .
pytest

Project status

  • 0.0.6
    • Support for numbers between 1-999
    • Add test script for development
    • Document the abbreviations
  • 0.0.7 - Parse user input in a robust way/
  • 0.0.8 - Add numbers support for numbers 1,000-999,999
  • 0.0.10 - Standerdized the output

Future work

  • Adding the first decimal place for all numbers
  • Add CLI support

License

MIT

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

numi-0.0.10.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

numi-0.0.10-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file numi-0.0.10.tar.gz.

File metadata

  • Download URL: numi-0.0.10.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for numi-0.0.10.tar.gz
Algorithm Hash digest
SHA256 cbeb5cf0b167a8e98cf32a8c43617bf25ce3c79afc0225a962dc50adbafb99e5
MD5 ed65fb1d3ded43853623788da3718f2c
BLAKE2b-256 568833f060091cbc1e68a62b90d7ceaff1e1106f12503dd6754ea1ee6866c4c8

See more details on using hashes here.

File details

Details for the file numi-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: numi-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for numi-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6f244feed1cc0820a7757a8e105cd2ba26b381c4ee9d9e527f51dfb0147c1939
MD5 fb95163bb81dcc8926ca80540e2b9c1a
BLAKE2b-256 31e98ba0480fe1480078a242cb1e1c613af1340d9b0c6031f6c79d38ea545a46

See more details on using hashes here.

Supported by

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