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")

> ["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.

We use pytest for development testing. Run pip install requirements_dev.txt for the development packages.

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/

Future work

  • Adding the first decimal place for all numbers
  • Add CLI support
  • Add numbers support for numbers 1,000-999,999

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.7.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

numi-0.0.7-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numi-0.0.7.tar.gz
  • Upload date:
  • Size: 7.3 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.7.tar.gz
Algorithm Hash digest
SHA256 91c3913ca95cf957d6a54238f1d7a147dfafa6c65862e48646bf94acf76f1426
MD5 8b03544795adb4a2bb8b7249ff2e487c
BLAKE2b-256 faaf5ee8b9a9be6c88bd588bdb7034e876b0245506c362a67921518407ce2fe0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numi-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 04169ed7a4115d8c2f76182a99e7059cfb40a3ad3eb422ac0be4102dd5e697c9
MD5 6e961e29d94dd160049bfd57cfeaa4bf
BLAKE2b-256 e0896652372e834967827c3a7e17ec456e4d37d41f63a9461f4d3cbaeeb26da9

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