File: lang_KN.py

package info (click to toggle)
python-num2words 0.5.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,832 kB
  • sloc: python: 27,073; makefile: 3
file content (182 lines) | stat: -rw-r--r-- 7,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# -*- encoding: 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_EU import Num2Word_EU


class Num2Word_KN(Num2Word_EU):
    def set_high_numwords(self, high):
        for n, word in self.high_numwords:
            self.cards[10**n] = word

    def setup(self):
        self.low_numwords = [
            "ತೊಂಬತ್ತೊಂಬತ್ತು",
            "ತೊಂಬತ್ತೆಂಟು",
            "ತೊಂಬತ್ತೇಳು",
            "ತೊಂಬತ್ತಾರು",
            "ತೊಂಬತ್ತೈದು",
            "ತೊಂಬತ್ತ ನಾಲ್ಕು",
            "ತೊಂಬತ್ತ ಮೂರು",
            "ತೊಂಬತ್ತೆರಡು",
            "ತೊಂಬತ್ತೊಂದು",
            "ತೊಂಬತ್ತು",
            "ಎಂಬತ್ತೊಂಬತ್ತು",
            "ಎಂಬತ್ತೆಂಟು",
            "ಎಂಬತ್ತೇಳು",
            "ಎಂಬತ್ತಾರು",
            "ಎಂಬತ್ತೈದು",
            "ಎಂಬತ್ತ್ ನಾಲ್ಕು",
            "ಎಂಬತ್ತ್ ಮೂರು",
            "ಎಂಬತ್ತೆರಡು",
            "ಎಂಬತ್ತೊಂದು",
            "ಎಂಬತ್ತು",
            "ಎಪ್ಪತ್ತೊಂಬತ್ತು",
            "ಎಪ್ಪತ್ತೆಂಟು",
            "ಎಪ್ಪತ್ತೇಳು",
            "ಎಪ್ಪತ್ತಾರು",
            "ಎಪ್ಪತ್ತೈದು",
            "ಎಪ್ಪತ್ತ್ ನಾಲ್ಕು",
            "ಎಪ್ಪತ್ತ್ ಮೂರು",
            "ಎಪ್ಪತ್ತೆರಡು",
            "ಎಪ್ಪತ್ತೊಂದು",
            "ಎಪ್ಪತ್ತು",
            "ಅರವತ್ತೊಂಬತ್ತು",
            "ಅರವತ್ತೆಂಟು",
            "ಅರವತ್ತೇಳು",
            "ಅರವತ್ತಾರು",
            "ಅರವತ್ತೈದು",
            "ಅರವತ್ತ್ ನಾಲ್ಕು",
            "ಅರವತ್ತ್ ಮೂರು",
            "ಅರವತ್ತೆರಡು",
            "ಅರವತ್ತೊಂದು",
            "ಅರವತ್ತು",
            "ಐವತ್ತೊಂಬತ್ತು",
            "ಐವತ್ತೆಂಟು",
            "ಐವತ್ತೇಳು",
            "ಐವತ್ತಾರು",
            "ಐವತ್ತೈದು",
            "ಐವತ್ತ್ನಾಲ್ಕು",
            "ಐವತ್ತಮೂರು",
            "ಐವತ್ತೆರಡು",
            "ಐವತ್ತೊಂದು",
            "ಐವತ್ತು",
            "ನಲವತ್ತೊಂಬತ್ತು",
            "ನಲವತ್ತೆಂಟು",
            "ನಲವತ್ತೇಳು",
            "ನಲವತ್ತಾರು",
            "ನಲವತ್ತೈದು",
            "ನಲವತ್ತ್ ನಾಲ್ಕು",
            "ನಲವತ್ತ್ ಮೂರು",
            "ನಲವತ್ತ್ ಎರಡು",
            "ನಲವತ್ತೊಂದು",
            "ನಲವತ್ತು",
            "ಮೂವತ್ತ್ ಒಂಬತ್ತು",
            "ಮೂವತ್ಎಂಟು",
            "ಮೂವತ್ಏಳು",
            "ಮೂವತ್ಆರು",
            "ಮೂವತ್ತ್ ಐದು",
            "ಮೂವತ್ತ್ ನಾಲ್ಕು",
            "ಮೂವತ್ತ್ ಮೂರು",
            "ಮೂವತ್ತ್ಎರಡು",
            "ಮೂವತ್ತ್ಒಂದು",
            "ಮೂವತ್ತು",
            "ಇಪ್ಪತ್ತ್ಒಂಬತ್ತು",
            "ಇಪ್ಪತ್ತ್ಎಂಟು",
            "ಇಪ್ಪತ್ತ್ಏಳು",
            "ಇಪ್ಪತ್ತ್ಆರು",
            "ಇಪ್ಪತ್ತ್ ಐದು",
            "ಇಪ್ಪತ್ತ್ ನಾಲ್ಕು",
            "ಇಪ್ಪತ್ತ್ ಮೂರು",
            "ಇಪ್ಪತ್ತ್ ಎರಡು",
            "ಇಪ್ಪತ್ತ್ ಒಂದು",
            "ಇಪ್ಪತ್ತು",
            "ಹತ್ತೊಂಬತ್ತು",
            "ಹದಿನೆಂಟು",
            "ಹದಿನೇಳು",
            "ಹದಿನಾರು",
            "ಹದಿನೈದು",
            "ಹದಿನಾಲ್ಕು",
            "ಹದಿಮೂರು",
            "ಹನ್ನೆರಡು",
            "ಹನ್ನೊಂದು",
            "ಹತ್ತು",
            "ಒಂಬತ್ತು",
            "ಎಂಟು",
            "ಏಳು",
            "ಆರು",
            "ಐದು",
            "ನಾಲ್ಕು",
            "ಮೂರು",
            "ಎರಡು",
            "ಒಂದು",
            "ಸೊನ್ನೆ",
        ]

        self.mid_numwords = [(100, "ನೂರು")]

        self.high_numwords = [(7, "ಕೋಟಿ"), (5, "ಒಂದು ಲಕ್ಷ"), (3, "ಸಾವಿರ")]

        self.pointword = "ಬಿಂದು"

        self.modifiers = [
            "್",
            "ಾ",
            "ಿ",
            "ೀ",
            "ೀ",
            "ು",
            "ೂ",
            "ೃ",
            "ೆ",
            "ೇ",
            "ೈ",
            "ೊ",
            "ೋ",
            "ೌ",
            "ೕ",
        ]

    def merge(self, lpair, rpair):
        ltext, lnum = lpair
        rtext, rnum = rpair
        if lnum == 1 and rnum < 100:
            return (rtext, rnum)
        elif 100 > lnum > rnum:
            return ("%s-%s" % (ltext, rtext), lnum + rnum)
        elif lnum >= 100 > rnum:
            if ltext[-1] in self.modifiers:
                return ("%s %s" % (ltext[:-1], rtext), lnum + rnum)
            else:
                return ("%s %s" % (ltext + "ದ", rtext), lnum + rnum)
        elif rnum > lnum:
            return ("%s %s" % (ltext, rtext), lnum * rnum)
        return ("%s %s" % (ltext, rtext), lnum + rnum)

    def to_ordinal_num(self, value):
        self.verify_ordinal(value)
        return "%s%s" % (value, self.to_ordinal(value))

    def to_ordinal(self, value):
        self.verify_ordinal(value)
        outwords = self.to_cardinal(value)
        if outwords[-1] in self.modifiers:
            outwords = outwords[:-1]
        ordinal_num = outwords + "ನೇ"
        return ordinal_num