All Projects → 5j9 → num2fawords

5j9 / num2fawords

Licence: GPL-3.0 License
Takes a number and converts it to Persian word form

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to num2fawords

persian
Some utilities for Persian language in Go (Golang)
Stars: ✭ 65 (+140.74%)
Mutual labels:  persian, farsi
gahshomar
A Persian (Jalali/Farsi) calendar for Linux
Stars: ✭ 69 (+155.56%)
Mutual labels:  persian, farsi
PersianSubtitleFixer
Fix Arabic and Persian subtitles by converting them into UTF-8
Stars: ✭ 25 (-7.41%)
Mutual labels:  persian, farsi
Begiresh
Smart Android App Banner for Persian Markets
Stars: ✭ 28 (+3.7%)
Mutual labels:  persian, farsi
Wudooh
Browser extension that allows Arabic script modifications for clarity and customization
Stars: ✭ 43 (+59.26%)
Mutual labels:  persian, farsi
matnbaz
📚 The source-code for matnbaz.net. A monorepo containing the back-end (NestJS/Prisma/Apollo), front-end (Next.js/Apollo) and some tooling.
Stars: ✭ 481 (+1681.48%)
Mutual labels:  persian, farsi
Nozha-rtl-Dashboard
Nozha is a rtl / ltr Admin Panel with Dark Mode
Stars: ✭ 31 (+14.81%)
Mutual labels:  persian, farsi
awesome-persian-youtubers
لیست یوتیوبرهای فارسی‌زبان
Stars: ✭ 52 (+92.59%)
Mutual labels:  persian, farsi
DNTPersianComponents.Blazor
A collection of Persian components for Blazor
Stars: ✭ 27 (+0%)
Mutual labels:  persian, farsi
Persian-OCR
Optical character recognition of Farsi and Arabic letters
Stars: ✭ 36 (+33.33%)
Mutual labels:  persian, farsi
prisoners
حبس از دید اعداد واقعی - Persian translation for "Incarceration in real numbers"
Stars: ✭ 22 (-18.52%)
Mutual labels:  persian, farsi
thewhite
✒️ It's a minimal and light wordpress blog theme 🎨
Stars: ✭ 87 (+222.22%)
Mutual labels:  persian, farsi
OpenSourceTutorials-Introduction
Open Source Kotlin Tutorial
Stars: ✭ 38 (+40.74%)
Mutual labels:  persian, farsi
RitaFontTester
Auxiliary tool for the development of Persian-Arabic fonts
Stars: ✭ 16 (-40.74%)
Mutual labels:  persian, farsi
PersianDataAnnotations
PersianDataAnnotations is ASP.NET Core MVC & ASP.NET MVC Custom Localization DataAnnotations (Localized MVC Errors) for Persian(Farsi) language - فارسی سازی خطاهای اعتبارسنجی توکار ام.وی.سی. و کور.ام.وی.سی. برای نمایش اعتبار سنجی سمت کلاینت
Stars: ✭ 38 (+40.74%)
Mutual labels:  persian, farsi
pardakhtyari
کتابخانه ها و مستندات مربوط به روال پرداخت یاری شاپرک - طبق مستندات رسمی شاپرک
Stars: ✭ 22 (-18.52%)
Mutual labels:  persian, farsi
persiantools
Jalali date and datetime with other tools
Stars: ✭ 101 (+274.07%)
Mutual labels:  persian, farsi
discord-guide-fa
اینجا یاد میگیرید چطور از صفر یک دیسکورد بات بسازید 🐱‍🏍
Stars: ✭ 69 (+155.56%)
Mutual labels:  persian, farsi
coderz
coderz.ir
Stars: ✭ 25 (-7.41%)
Mutual labels:  persian, farsi
HandySub
Download Subtitle from Subscene and other sources
Stars: ✭ 42 (+55.56%)
Mutual labels:  persian, farsi
https://travis-ci.org/5j9/num2fawords.svg?branch=master https://codecov.io/github/5j9/num2fawords/coverage.svg?branch=master https://ci.appveyor.com/api/projects/status/github/5j9/num2fawords?svg=true&branch=master

num2fawords

num2fawords is a highly customizable library which provides functions to convert a number (int, float, Decimal, Fraction, or str) into Persian word form.

Installation

  • Python 3.4+ is required
  • pip install 'setuptools>=36.2.1'
  • pip install num2fawords

Usage

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

Obviously, words is used to convert to word form and ordinal_words is for ordinal word from.

words also accepts other common standard types:

>>> words(19.75)
'نوزده و هفتاد و پنج صدم'
>>> from decimal import Decimal
>>> words(Decimal('1.1'))
'یک و یک دهم'
>>> from fractions import Fraction
>>> words(Fraction(-2, 5))
'منفی دو پنجم'

The default decimal separator is "و" but it can be changed to "ممیز" (or any other string) as follows:

>>> words(19.75, decimal_separator=' ممیز ')
'نوزده ممیز هفتاد و پنج صدم'

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

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

Some examples for other arguments of words:

>>> words(7, positive='مثبت ')
'مثبت هفت'
>>> words(-2, negative='منهای ')
'منهای دو'
>>> words('۱/۲')
'یک دوم'
>>> words('1/2', fraction_separator=' تقسیم بر ', ordinal_denominator=False)
'یک تقسیم بر دو'
>>> words(1.1e-9)
'یک و یک دهم در ده به توان منفی نه'
>>> words(1.1e-9, scientific_separator=' ضربدر ده به قوهٔ ')
'یک و یک دهم ضربدر ده به قوهٔ منفی نه'

Of-course the above arguments can be used together.

If you prefer to change the default argument values once and for all, use the change_defaults function:

>>> from num2fawords import change_defaults, words
>>> change_defaults(fraction_separator=' بخش بر ', ordinal_denominator=False)
>>> words('۱/۴')
'یک بخش بر چهار'

That's all. Enjoy!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].