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
Built Distribution
File details
Details for the file numi-0.0.13.tar.gz
.
File metadata
- Download URL: numi-0.0.13.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cb6d1876c20301adaf1740e1991a0a951be527d14a306882899cebbcca606c9 |
|
MD5 | 27b3a60664daf35468949c3f13e7f4af |
|
BLAKE2b-256 | f0f4b0140c455d3f4d61536f97a493796c39ad3d6d086d62e0fc76317d2292d5 |
File details
Details for the file numi-0.0.13-py3-none-any.whl
.
File metadata
- Download URL: numi-0.0.13-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 602b7ec3c60f145c06495bb0633ec4d189ffa65d1faa03e920b5d8a9c184e9af |
|
MD5 | f8510d4033baf15ce829c4fbdb7dc8ba |
|
BLAKE2b-256 | b4042e8e0f0b2bc81922304b235df58b8d817bd0cc4fdc9cbf8046ad083e9bcc |