Metadata-Version: 2.0
Name: num2fawords
Version: 0.1
Summary: A tool to convert numbers (int, float) into Persian words
Home-page: https://github.com/5j9/num2fawords
Author: 5j9
Author-email: 5j9@users.noreply.github.com
License: GNU General Public License v3.0
Keywords: convert number words farsi persian
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Natural Language :: English
Classifier: Natural Language :: Persian
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Text Processing :: General
Classifier: Topic :: Utilities

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

num2fawords
===========

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

Usage
=====

.. code-block:: python

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

.. code-block:: python

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

This is the default setting. If you'd like to ommit the word "ممیز" from the output and use "و" instead of it, you can:

.. code-block:: python

	>>> import num2fawords
	>>> num2fawords.MOMAYEZ  # default value:
	' ممیز '
	>>> num2fawords.MOMAYEZ = ' و '
	>>> num2fawords.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:

.. code-block:: python

	>>> num2fawords.cardinal_words(170)
	'یکصد و هفتاد'
	>>> num2fawords.SADGAN
	['', 'یکصد', 'دویست', 'سیصد', 'چهارصد', 'پانصد', 'ششصد', 'هفتصد', 'هشتصد', 'نهصد']
	>>> num2fawords.SADGAN[1] = 'صد'
	>>> num2fawords.cardinal_words(170)
	'صد و هفتاد'

Command line
============

The program can also be invoked from the command line:

.. code-block::

	>python num2fawords
	usage: num2fawords [-h] [--ordinal] [--cardinal] number
	num2fawords: error: the following arguments are required: number
	>python num2fawords 13
	سیزدهم
	>python num2fawords -o 13
	سیزدهم


