Skip to content
Merged
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
2 changes: 2 additions & 0 deletions num2words2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
lang_EL,
lang_EN,
lang_EN_IN,
lang_EN_NE,
lang_EN_NG,
lang_EO,
lang_ES,
Expand Down Expand Up @@ -198,6 +199,7 @@
"el": lang_EL.Num2Word_EL(),
"en": lang_EN.Num2Word_EN(),
"en_IN": lang_EN_IN.Num2Word_EN_IN(),
"en_NE": lang_EN_NE.Num2Word_EN_NE(),
"en_NG": lang_EN_NG.Num2Word_EN_NG(),
"eo": lang_EO.Num2Word_EO(),
"es": lang_ES.Num2Word_ES(),
Expand Down
31 changes: 31 additions & 0 deletions num2words2/lang_EN_NE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- 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 __future__ import unicode_literals

from .lang_EN import Num2Word_EN


class Num2Word_EN_NE(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"
98 changes: 98 additions & 0 deletions tests/lang/test_en_ne.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# -*- 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 num2words2 import num2words


class Num2WordsENNETest(TestCase):
def test_cardinal(self):
# Basic powers of 100 progression
self.assertEqual(num2words(1e5, lang="en_NE"), "one lakh")
self.assertEqual(num2words(1e6, lang="en_NE"), "ten lakh")
self.assertEqual(num2words(1e7, lang="en_NE"), "one crore")
self.assertEqual(num2words(1e8, lang="en_NE"), "ten crore")
self.assertEqual(num2words(1e9, lang="en_NE"), "one arba")
self.assertEqual(num2words(1e10, lang="en_NE"), "ten arba")
self.assertEqual(num2words(1e11, lang="en_NE"), "one kharba")
self.assertEqual(num2words(1e12, lang="en_NE"), "ten kharba")
self.assertEqual(num2words(1e13, lang="en_NE"), "one neel")
self.assertEqual(num2words(1e14, lang="en_NE"), "ten neel")
self.assertEqual(num2words(1e15, lang="en_NE"), "one padam")
self.assertEqual(num2words(1e16, lang="en_NE"), "ten padam")
self.assertEqual(num2words(1e17, lang="en_NE"), "one shankha")
self.assertEqual(num2words(1e18, lang="en_NE"), "ten shankha")

def test_intermediate_values(self):
# Test intermediate values to ensure proper grouping
self.assertEqual(
num2words(150000, lang="en_NE"),
"one lakh, fifty thousand"
)
self.assertEqual(
num2words(250000, lang="en_NE"),
"two lakh, fifty thousand"
)
self.assertEqual(
num2words(1250000, lang="en_NE"),
"twelve lakh, fifty thousand"
)
self.assertEqual(
num2words(15000000, lang="en_NE"),
"one crore, fifty lakh"
)
self.assertEqual(
num2words(12345567, lang="en_NE"),
"one crore, twenty-three lakh, forty-five thousand, "
"five hundred and sixty-seven"
)
self.assertEqual(
num2words(125000000, lang="en_NE"), "twelve crore, "
"fifty lakh"
)

def test_small_numbers(self):
# Ensure small numbers still work correctly
self.assertEqual(num2words(0, lang="en_NE"), "zero")
self.assertEqual(num2words(1, lang="en_NE"), "one")
self.assertEqual(num2words(99, lang="en_NE"), "ninety-nine")
self.assertEqual(
num2words(999, lang="en_NE"),
"nine hundred and ninety-nine"
)
self.assertEqual(
num2words(9999, lang="en_NE"),
"nine thousand, nine hundred and ninety-nine"
)
self.assertEqual(
num2words(99999, lang="en_NE"),
"ninety-nine thousand, nine hundred and ninety-nine"
)

def test_complex_values(self):
# Real-world complex numbers
self.assertEqual(
num2words(12345678, lang="en_NE"),
"one crore, twenty-three lakh, forty-five thousand, "
"six hundred and seventy-eight"
)
self.assertEqual(
num2words(987654321, lang="en_NE"),
"ninety-eight crore, seventy-six lakh, "
"fifty-four thousand, three hundred and twenty-one"
)
Loading