Skip to main content

A tool to convert numbers (int, float) into Persian words

Project description

https://travis-ci.org/5j9/num2fawords.svg?branch=master https://codecov.io/github/5j9/num2fawords/coverage.svg?branch=master

num2fawords

This package provides functions to convert a number (int or float) to a Persian word form.

installation

Python 3.3+ is required.

Install using pip install num2fawords command.

Usage

>>> from num2fawords import cardinal_words, ordinal_words
>>> cardinal_words(1984)
'یک هزار و نهصد و هشتاد و چهار'
>>> ordinal_words(1232)
'یک هزار و دویست و سی و دوم'
>>> ordinal_words(123)
'یکصد و بیست و سوم'

Obviously, cardinal_words is used convert to cardinal form and ordinal_words for ordinal from.

Use can also pass in floating point numbers:

>>> cardinal_words(19.75)
'نوزده و هفتاد و پنج صدم'

This is the default setting. If you’d like to use “ممیز” instead of “و” for decimal point, you can:

>>> from num2fawords import DECIMAL_SEPARATOR
>>> DECIMAL_SEPARATOR  # default value:
' و '
>>> DECIMAL_SEPARATOR = ' ممیز '
>>> cardinal_words(19.75)
'نوزده ممیز هفتاد و پنج صدم'

Also some people prefer, for example, “صد و هفتاد” over its other form “یکصد و هفتاد”. This library uses the second form which is the form used on official Iranian banknotes. But it can be changed:

>>> from num2fawords import HUNDREDS
>>> cardinal_words(170)
'یکصد و هفتاد'
>>> HUNDREDS[1] = 'صد'
>>> cardinal_words(170)
'صد و هفتاد'

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

num2fawords-0.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

num2fawords-0.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file num2fawords-0.3.tar.gz.

File metadata

  • Download URL: num2fawords-0.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for num2fawords-0.3.tar.gz
Algorithm Hash digest
SHA256 56f3de06deae7c60755f0a16a099c2b9348080ac9e16dc6a2eab27fa598f9c87
MD5 efad3a24b7f1edbd0ea0689895588254
BLAKE2b-256 515f4667a72e42049173d083a90076c0bb1c23c97b09945e068215f5f10cb0e8

See more details on using hashes here.

File details

Details for the file num2fawords-0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for num2fawords-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9f759e1d0fa724aa6d7d9a41a2ab2c136771dc7a036f3b81c78f44de1767bbbf
MD5 71d8f3bd46877cc45aed13a045d59d7c
BLAKE2b-256 f1bb5cabab335da5637aaad7364b8dda22f8a96fd17adff02f1244b750c60e47

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