How to use num2words - 10 common examples

To help you get started, we’ve selected a few num2words examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github savoirfairelinux / num2words / tests / test_cli.py View on Github external
def test_cli_list_langs(self):
        """You should be able to list all availabe languages
        """
        output = self.cli.run_cmd('--list-languages')
        self.assertEqual(
            sorted(list(num2words.CONVERTER_CLASSES.keys())),
            output.out.strip().split(os.linesep)
        )
        output = self.cli.run_cmd('-L')
        self.assertEqual(
            sorted(list(num2words.CONVERTER_CLASSES.keys())),
            output.out.strip().split(os.linesep)
        )
github savoirfairelinux / num2words / tests / test_cli.py View on Github external
def test_cli_list_langs(self):
        """You should be able to list all availabe languages
        """
        output = self.cli.run_cmd('--list-languages')
        self.assertEqual(
            sorted(list(num2words.CONVERTER_CLASSES.keys())),
            output.out.strip().split(os.linesep)
        )
        output = self.cli.run_cmd('-L')
        self.assertEqual(
            sorted(list(num2words.CONVERTER_CLASSES.keys())),
            output.out.strip().split(os.linesep)
        )
github savoirfairelinux / num2words / tests / test_kz.py View on Github external
def test_to_cardinal_floats(self):
        self.assertEqual(num2words(100.67, lang="kz"), "жүз бүтін алпыс жеті")
        self.assertEqual(num2words(0.7, lang="kz"), "нөл бүтін жеті")
        self.assertEqual(num2words(1.73, lang="kz"), "бір бүтін жетпіс үш")
github savoirfairelinux / num2words / tests / test_fr_be.py View on Github external
self.assertEqual(
            num2words(5, ordinal=True, lang=LANG), "cinquième"
        )
        self.assertEqual(
            num2words(6, ordinal=True, lang=LANG), "sixième"
        )
        self.assertEqual(
            num2words(35, ordinal=True, lang=LANG), "trente-cinquième"
        )
        self.assertEqual(num2words(9, ordinal=True, lang=LANG), "neuvième")
        self.assertEqual(
            num2words(49, ordinal=True, lang=LANG), "quarante-neuvième"
        )
        self.assertEqual(num2words(71, lang=LANG), "septante et un")
        self.assertEqual(num2words(81, lang=LANG), "quatre-vingt et un")
        self.assertEqual(num2words(80, lang=LANG), "quatre-vingt")
        self.assertEqual(
            num2words(880, lang=LANG), "huit cents quatre-vingt")
        self.assertEqual(
            num2words(91, ordinal=True, lang=LANG), "nonante et unième"
        )
        self.assertEqual(num2words(53, lang=LANG), "cinquante-trois")
github savoirfairelinux / num2words / tests / test_vi.py View on Github external
def test_20_to_99(self):
        self.assertEqual(num2words(20, lang="vi"), "hai mươi")
        self.assertEqual(num2words(23, lang="vi"), "hai mươi ba")
        self.assertEqual(num2words(28, lang="vi"), "hai mươi tám")
        self.assertEqual(num2words(31, lang="vi"), "ba mươi mốt")
        self.assertEqual(num2words(40, lang="vi"), "bốn mươi")
        self.assertEqual(num2words(66, lang="vi"), "sáu mươi sáu")
        self.assertEqual(num2words(92, lang="vi"), "chín mươi hai")
github savoirfairelinux / num2words / tests / test_sl.py View on Github external
# Tests were compiled from cases in
        # https://github.com/gregopet/zapis-slovenskih-stevil
        self.assertEqual(num2words(0, lang='sl'), "nič")
        self.assertEqual(num2words(1, lang='sl'), "ena")
        self.assertEqual(num2words(2, lang='sl'), "dve")
        self.assertEqual(num2words(3, lang='sl'), "tri")
        self.assertEqual(num2words(4, lang='sl'), "štiri")
        self.assertEqual(num2words(5, lang='sl'), "pet")
        self.assertEqual(num2words(6, lang='sl'), "šest")
        self.assertEqual(num2words(7, lang='sl'), "sedem")
        self.assertEqual(num2words(8, lang='sl'), "osem")
        self.assertEqual(num2words(9, lang='sl'), "devet")
        self.assertEqual(num2words(10, lang='sl'), "deset")
        self.assertEqual(num2words(11, lang='sl'), "enajst")
        self.assertEqual(num2words(12, lang='sl'), "dvanajst")
        self.assertEqual(num2words(13, lang='sl'), "trinajst")
        self.assertEqual(num2words(14, lang='sl'), "štirinajst")
        self.assertEqual(num2words(15, lang='sl'), "petnajst")
        self.assertEqual(num2words(16, lang='sl'), "šestnajst")
        self.assertEqual(num2words(17, lang='sl'), "sedemnajst")
        self.assertEqual(num2words(18, lang='sl'), "osemnajst")
        self.assertEqual(num2words(19, lang='sl'), "devetnajst")
        self.assertEqual(num2words(20, lang='sl'), "dvajset")
        self.assertEqual(num2words(21, lang='sl'), "enaindvajset")
        self.assertEqual(num2words(22, lang='sl'), "dvaindvajset")
        self.assertEqual(num2words(23, lang='sl'), "triindvajset")
        self.assertEqual(num2words(24, lang='sl'), "štiriindvajset")
        self.assertEqual(num2words(25, lang='sl'), "petindvajset")
        self.assertEqual(num2words(26, lang='sl'), "šestindvajset")
        self.assertEqual(num2words(27, lang='sl'), "sedemindvajset")
        self.assertEqual(num2words(28, lang='sl'), "osemindvajset")
        self.assertEqual(num2words(29, lang='sl'), "devetindvajset")
github savoirfairelinux / num2words / tests / test_uk.py View on Github external
def test_to_cardinal(self):
        self.maxDiff = None
        self.assertEqual(num2words(100, lang='uk'), 'сто')
        # self.assertEqual(num2words(101, lang='uk'), 'сто один')
        self.assertEqual(num2words(110, lang='uk'), 'сто десять')
        self.assertEqual(num2words(115, lang='uk'), "сто п'ятнадцять")
        self.assertEqual(num2words(123, lang='uk'), 'сто двадцять три')
        self.assertEqual(num2words(1000, lang='uk'), 'одна тисяча')
        # self.assertEqual(num2words(1001, lang='uk'), 'одна тисяча один')
        self.assertEqual(num2words(2012, lang='uk'), 'двi тисячi дванадцять')
        self.assertEqual(
            num2words(12519.85, lang='uk'),
            "дванадцять тисяч п'ятсот дев'ятнадцять кома вiсiмдесят п'ять")
        # self.assertEqual(
github savoirfairelinux / num2words / tests / test_kn.py View on Github external
num2words(22, lang='kn', to='ordinal'),
            u'ಇಪ್ಪತ್ತ್ ಎರಡನೇ'
        )
        self.assertEqual(
            num2words(12, lang='kn', to='ordinal'),
            u'ಹನ್ನೆರಡನೇ'
        )
        self.assertEqual(
            num2words(130, lang='kn', to='ordinal'),
            u'ಒಂದು ನೂರ ಮೂವತ್ತನೇ'
        )
        self.assertEqual(
            num2words(1003, lang='kn', to='ordinal'),
            u'ಒಂದು ಸಾವಿರದ ಮೂರನೇ'
        )
        self.assertEqual(num2words(2, lang="kn", ordinal=True), u"ಎರಡನೇ")
        self.assertEqual(num2words(5, lang="kn", ordinal=True), u"ಐದನೇ")
        self.assertEqual(num2words(16, lang="kn", ordinal=True), u"ಹದಿನಾರನೇ")
        self.assertEqual(num2words(113, lang="kn", ordinal=True),
                         u"ಒಂದು ನೂರ ಹದಿಮೂರನೇ")
github savoirfairelinux / num2words / tests / test_tr.py View on Github external
)
        self.assertEqual(
            num2words(100011001, False, "tr"), u"yüzmilyononbirbinbir"
        )
        self.assertEqual(
            num2words(101011001, False, "tr"), u"yüzbirmilyononbirbinbir"
        )
        self.assertEqual(
            num2words(101011010, False, "tr"), u"yüzbirmilyononbirbinon"
        )
        self.assertEqual(
            num2words(1101011010, False, "tr"),
            u"birmilyaryüzbirmilyononbirbinon"
        )
        self.assertEqual(
            num2words(101101011010, False, "tr"),
            u"yüzbirmilyaryüzbirmilyononbirbinon"
        )
        self.assertEqual(
            num2words(1000000000001, False, "tr"), u"birtrilyonbir"
        )
        self.assertEqual(num2words(0.01, False, "tr"), u"sıfırvirgülbir")
        self.assertEqual(num2words(0.1, False, "tr"), u"sıfırvirgülon")
        self.assertEqual(num2words(0.21, False, "tr"), u"sıfırvirgülyirmibir")
        self.assertEqual(num2words(1.01, False, "tr"), u"birvirgülbir")
        self.assertEqual(num2words(1.1, False, "tr"), u"birvirgülon")
        self.assertEqual(num2words(1.21, False, "tr"), u"birvirgülyirmibir")
        self.assertEqual(
            num2words(101101011010.02, False, "tr"),
            u"yüzbirmilyaryüzbirmilyononbirbinonvirgüliki"
        )
        self.assertEqual(
github savoirfairelinux / num2words / tests / test_pt.py View on Github external
)
        self.assertEqual(
            num2words(2114, lang='pt', ordinal=True),
            'segundo milésimo centésimo décimo quarto'
        )
        self.assertEqual(
            num2words(73421, lang='pt', ordinal=True),
            'septuagésimo terceiro milésimo quadrigentésimo vigésimo primeiro'
        )

        self.assertEqual(
            num2words(100000, lang='pt', ordinal=True),
            'centésimo milésimo'
        )
        self.assertEqual(
            num2words(250050, lang='pt', ordinal=True),
            'ducentésimo quinquagésimo milésimo quinquagésimo'
        )
        self.assertEqual(
            num2words(6000000, lang='pt', ordinal=True), 'sexto milionésimo'
        )
        self.assertEqual(
            num2words(19000000000, lang='pt', ordinal=True),
            'décimo nono milésimo milionésimo'
        )
        self.assertEqual(
            num2words(145000000002, lang='pt', ordinal=True),
            'centésimo quadragésimo quinto milésimo milionésimo segundo'
        )