Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support For Nepalese Numbering System #548

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a
* ``en_GB`` (English - Great Britain)
* ``en_IN`` (English - India)
* ``en_NG`` (English - Nigeria)
* ``en_NP`` (English - Nepal)
* ``es`` (Spanish)
* ``es_CO`` (Spanish - Colombia)
* ``es_VE`` (Spanish - Venezuela)
Expand Down Expand Up @@ -156,4 +157,4 @@ added Lithuanian support, but didn't take over maintenance of the project.
I am thus basing myself on Marius Grigaitis' improvements and re-publishing
``pynum2word`` as ``num2words``.

Virgil Dupras, Savoir-faire Linux
Virgil Dupras, Savoir-faire Linux
3 changes: 2 additions & 1 deletion num2words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import unicode_literals

from . import (lang_AM, lang_AR, lang_AZ, lang_BY, lang_CZ, lang_DE, lang_DK,
lang_EN, lang_EN_IN, lang_EN_NG, lang_EO, lang_ES, lang_ES_CO,
lang_EN, lang_EN_IN, lang_EN_NG, lang_EN_NP, lang_EO, lang_ES, lang_ES_CO,
lang_ES_GT, lang_ES_NI, lang_ES_VE, lang_FA, lang_FI, lang_FR,
lang_FR_BE, lang_FR_CH, lang_FR_DZ, lang_HE, lang_HU, lang_ID,
lang_IS, lang_IT, lang_JA, lang_KN, lang_KO, lang_KZ, lang_LT,
Expand All @@ -35,6 +35,7 @@
'en': lang_EN.Num2Word_EN(),
'en_IN': lang_EN_IN.Num2Word_EN_IN(),
'en_NG': lang_EN_NG.Num2Word_EN_NG(),
'en_NP': lang_EN_NP.Num2Word_EN_NP(),
'fa': lang_FA.Num2Word_FA(),
'fr': lang_FR.Num2Word_FR(),
'fr_CH': lang_FR_CH.Num2Word_FR_CH(),
Expand Down
35 changes: 35 additions & 0 deletions num2words/lang_EN_NP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA

# for Nepalese Number System
# Added support for Nepali Numbering System by Ajira Group, Nepal [email protected]


from __future__ import unicode_literals

from .lang_EN import Num2Word_EN


class Num2Word_EN_NP(Num2Word_EN):
def set_high_numwords(self, high):
self.cards[10 ** 17] = "shankha"
self.cards[10 ** 15] = "padam"
self.cards[10 ** 13] = "neel"
self.cards[10 ** 11] = "kharba"
self.cards[10 ** 9] = "arba"
self.cards[10 ** 7] = "crore"
self.cards[10 ** 5] = "lakh"
39 changes: 39 additions & 0 deletions tests/test_en_np.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA

from unittest import TestCase

from num2words import num2words


class Num2WordsENINTest(TestCase):
def test_cardinal(self):
self.assertEqual(num2words(1e5, lang="en_NP"), "one lakh")
self.assertEqual(num2words(1e6, lang="en_NP"), "ten lakh")
self.assertEqual(num2words(1e7, lang="en_NP"), "one crore")
self.assertEqual(num2words(1e8, lang="en_NP"), "ten crore")
self.assertEqual(num2words(1e9, lang="en_NP"), "one arba")
self.assertEqual(num2words(1e10, lang="en_NP"), "ten arba")
self.assertEqual(num2words(1e11, lang="en_NP"), "one kharba")
self.assertEqual(num2words(1e12, lang="en_NP"), "ten kharba")
self.assertEqual(num2words(1e13, lang="en_NP"), "one neel")
self.assertEqual(num2words(1e14, lang="en_NP"), "ten neel")
self.assertEqual(num2words(1e15, lang="en_NP"), "one padam")
self.assertEqual(num2words(1e16, lang="en_NP"), "ten padam")
self.assertEqual(num2words(1e17, lang="en_NP"), "one shankha")
self.assertEqual(num2words(1e18, lang="en_NP"), "ten shankha")