num2words2 0.1.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. num2words2/README.md +69 -0
  2. num2words2/__init__.py +196 -0
  3. num2words2/_version.py +3 -0
  4. num2words2/base.py +377 -0
  5. num2words2/compat.py +29 -0
  6. num2words2/currency.py +60 -0
  7. num2words2/lang_AF.py +202 -0
  8. num2words2/lang_AM.py +193 -0
  9. num2words2/lang_AR.py +435 -0
  10. num2words2/lang_AS.py +119 -0
  11. num2words2/lang_AZ.py +208 -0
  12. num2words2/lang_BA.py +119 -0
  13. num2words2/lang_BE.py +356 -0
  14. num2words2/lang_BG.py +393 -0
  15. num2words2/lang_BN.py +242 -0
  16. num2words2/lang_BO.py +122 -0
  17. num2words2/lang_BR.py +135 -0
  18. num2words2/lang_BS.py +189 -0
  19. num2words2/lang_CA.py +476 -0
  20. num2words2/lang_CE.py +546 -0
  21. num2words2/lang_CS.py +260 -0
  22. num2words2/lang_CY.py +574 -0
  23. num2words2/lang_DA.py +170 -0
  24. num2words2/lang_DE.py +180 -0
  25. num2words2/lang_EL.py +338 -0
  26. num2words2/lang_EN.py +118 -0
  27. num2words2/lang_EN_IN.py +26 -0
  28. num2words2/lang_EN_NG.py +45 -0
  29. num2words2/lang_EO.py +130 -0
  30. num2words2/lang_ES.py +399 -0
  31. num2words2/lang_ES_CO.py +37 -0
  32. num2words2/lang_ES_CR.py +38 -0
  33. num2words2/lang_ES_GT.py +37 -0
  34. num2words2/lang_ES_NI.py +35 -0
  35. num2words2/lang_ES_VE.py +43 -0
  36. num2words2/lang_ET.py +393 -0
  37. num2words2/lang_EU.py +158 -0
  38. num2words2/lang_EUR.py +104 -0
  39. num2words2/lang_FA.py +187 -0
  40. num2words2/lang_FI.py +759 -0
  41. num2words2/lang_FO.py +136 -0
  42. num2words2/lang_FR.py +133 -0
  43. num2words2/lang_FR_BE.py +49 -0
  44. num2words2/lang_FR_CH.py +48 -0
  45. num2words2/lang_FR_DZ.py +35 -0
  46. num2words2/lang_GL.py +135 -0
  47. num2words2/lang_GU.py +172 -0
  48. num2words2/lang_HA.py +293 -0
  49. num2words2/lang_HAW.py +144 -0
  50. num2words2/lang_HE.py +314 -0
  51. num2words2/lang_HI.py +243 -0
  52. num2words2/lang_HR.py +304 -0
  53. num2words2/lang_HT.py +136 -0
  54. num2words2/lang_HU.py +189 -0
  55. num2words2/lang_HY.py +364 -0
  56. num2words2/lang_ID.py +242 -0
  57. num2words2/lang_IS.py +208 -0
  58. num2words2/lang_IT.py +265 -0
  59. num2words2/lang_JA.py +615 -0
  60. num2words2/lang_JW.py +136 -0
  61. num2words2/lang_KA.py +169 -0
  62. num2words2/lang_KK.py +136 -0
  63. num2words2/lang_KM.py +173 -0
  64. num2words2/lang_KN.py +182 -0
  65. num2words2/lang_KO.py +175 -0
  66. num2words2/lang_KZ.py +161 -0
  67. num2words2/lang_LA.py +135 -0
  68. num2words2/lang_LB.py +135 -0
  69. num2words2/lang_LN.py +136 -0
  70. num2words2/lang_LO.py +149 -0
  71. num2words2/lang_LT.py +283 -0
  72. num2words2/lang_LV.py +266 -0
  73. num2words2/lang_MG.py +143 -0
  74. num2words2/lang_MI.py +151 -0
  75. num2words2/lang_MK.py +136 -0
  76. num2words2/lang_ML.py +159 -0
  77. num2words2/lang_MN.py +319 -0
  78. num2words2/lang_MR.py +187 -0
  79. num2words2/lang_MS.py +293 -0
  80. num2words2/lang_MT.py +159 -0
  81. num2words2/lang_MY.py +152 -0
  82. num2words2/lang_NE.py +157 -0
  83. num2words2/lang_NL.py +204 -0
  84. num2words2/lang_NN.py +136 -0
  85. num2words2/lang_NO.py +143 -0
  86. num2words2/lang_OC.py +135 -0
  87. num2words2/lang_PA.py +159 -0
  88. num2words2/lang_PL.py +336 -0
  89. num2words2/lang_PS.py +136 -0
  90. num2words2/lang_PT.py +280 -0
  91. num2words2/lang_PT_BR.py +224 -0
  92. num2words2/lang_RO.py +183 -0
  93. num2words2/lang_RU.py +570 -0
  94. num2words2/lang_SA.py +136 -0
  95. num2words2/lang_SD.py +136 -0
  96. num2words2/lang_SI.py +152 -0
  97. num2words2/lang_SK.py +250 -0
  98. num2words2/lang_SL.py +306 -0
  99. num2words2/lang_SN.py +447 -0
  100. num2words2/lang_SO.py +136 -0
  101. num2words2/lang_SQ.py +252 -0
  102. num2words2/lang_SR.py +254 -0
  103. num2words2/lang_SU.py +136 -0
  104. num2words2/lang_SV.py +169 -0
  105. num2words2/lang_SW.py +219 -0
  106. num2words2/lang_TA.py +303 -0
  107. num2words2/lang_TE.py +169 -0
  108. num2words2/lang_TET.py +285 -0
  109. num2words2/lang_TG.py +149 -0
  110. num2words2/lang_TH.py +214 -0
  111. num2words2/lang_TK.py +136 -0
  112. num2words2/lang_TL.py +145 -0
  113. num2words2/lang_TR.py +882 -0
  114. num2words2/lang_TT.py +136 -0
  115. num2words2/lang_UK.py +1101 -0
  116. num2words2/lang_UR.py +168 -0
  117. num2words2/lang_UZ.py +136 -0
  118. num2words2/lang_VI.py +143 -0
  119. num2words2/lang_WO.py +136 -0
  120. num2words2/lang_YI.py +135 -0
  121. num2words2/lang_YO.py +136 -0
  122. num2words2/lang_ZH.py +296 -0
  123. num2words2/lang_ZH_CN.py +85 -0
  124. num2words2/lang_ZH_HK.py +48 -0
  125. num2words2/lang_ZH_TW.py +198 -0
  126. num2words2/utils.py +35 -0
  127. num2words2-0.1.0.dev1.data/scripts/num2words2 +98 -0
  128. num2words2-0.1.0.dev1.dist-info/METADATA +244 -0
  129. num2words2-0.1.0.dev1.dist-info/RECORD +133 -0
  130. num2words2-0.1.0.dev1.dist-info/WHEEL +5 -0
  131. num2words2-0.1.0.dev1.dist-info/entry_points.txt +2 -0
  132. num2words2-0.1.0.dev1.dist-info/licenses/COPYING +145 -0
  133. num2words2-0.1.0.dev1.dist-info/top_level.txt +1 -0
num2words2/lang_TE.py ADDED
@@ -0,0 +1,169 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from __future__ import unicode_literals
4
+
5
+ from .lang_EUR import Num2Word_EUR
6
+
7
+
8
+ class Num2Word_TE(Num2Word_EUR):
9
+ def set_high_numwords(self, high):
10
+ for n, word in self.high_numwords:
11
+ self.cards[10**n] = word
12
+
13
+ def setup(self):
14
+ self.low_numwords = [
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
+ self.mid_numwords = [(100, "వంద")]
118
+
119
+ self.high_numwords = [(7, "కోట్ల"), (5, "లక్ష"), (3, "వేయి")]
120
+
121
+ self.pointword = "బిందువు "
122
+
123
+ self.modifiers = [
124
+ " ్ ",
125
+ "ా ",
126
+ " ి ",
127
+ " ీ ",
128
+ " ు ",
129
+ " ూ ",
130
+ " ృ ",
131
+ " ౄ ",
132
+ " ె ",
133
+ " ే ",
134
+ " ై ",
135
+ " ొ",
136
+ " ో ",
137
+ " ౌ ",
138
+ " ఁ ",
139
+ " ం ",
140
+ " ః ",
141
+ ]
142
+
143
+ def merge(self, lpair, rpair):
144
+ ltext, lnum = lpair
145
+ rtext, rnum = rpair
146
+ if lnum == 1 and rnum < 100:
147
+ return (rtext, rnum)
148
+ elif 100 > lnum > rnum:
149
+ return ("%s-%s" % (ltext, rtext), lnum + rnum)
150
+ elif lnum >= 100 > rnum:
151
+ if ltext[-1] in self.modifiers:
152
+ return ("%s %s" % (ltext[:-1], rtext), lnum + rnum)
153
+ else:
154
+ return ("%s %s" % (ltext + "ల", rtext), lnum + rnum)
155
+ elif rnum > lnum:
156
+ return ("%s %s" % (ltext, rtext), lnum * rnum)
157
+ return ("%s %s" % (ltext, rtext), lnum + rnum)
158
+
159
+ def to_ordinal_num(self, value):
160
+ self.verify_ordinal(value)
161
+ return "%s%s" % (value, self.to_ordinal(value)[-1:])
162
+
163
+ def to_ordinal(self, value):
164
+ self.verify_ordinal(value)
165
+ outwords = self.to_cardinal(value)
166
+ if outwords[-1] in self.modifiers:
167
+ outwords = outwords[:-1]
168
+ ordinal_num = outwords + "వ"
169
+ return ordinal_num
num2words2/lang_TET.py ADDED
@@ -0,0 +1,285 @@
1
+ # -*- coding: utf-8 -*-Num2Word_TET
2
+ # Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
3
+ # Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
4
+
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ # MA 02110-1301 USA
17
+
18
+
19
+ from decimal import Decimal
20
+
21
+ from num2words2.currency import parse_currency_parts
22
+
23
+ from .lang_EUR import Num2Word_EUR
24
+
25
+ DOLLAR = ('dolar', 'dolar')
26
+ CENTS = ('sentavu', 'sentavu')
27
+
28
+
29
+ class Num2Word_TET(Num2Word_EUR):
30
+
31
+ CURRENCY_FORMS = {
32
+ 'AUD': (DOLLAR, CENTS),
33
+ 'CAD': (DOLLAR, CENTS),
34
+ 'EUR': (('euro', 'euros'), CENTS),
35
+ 'GBP': (('pound sterling', 'pound sterling'), ('pence', 'pence')),
36
+ 'USD': (DOLLAR, CENTS),
37
+ }
38
+
39
+ GIGA_SUFFIX = None
40
+ MEGA_SUFFIX = "iliaun"
41
+
42
+ def setup(self):
43
+ super().setup()
44
+ lows = ["kuatr", "tr", "b", "m"]
45
+ self.high_numwords = self.gen_high_numwords([], [], lows)
46
+ self.negword = "menus "
47
+ self.pointword = "vírgula"
48
+ self.exclude_title = ["resin", "vírgula", "menus"]
49
+ self.count = 0
50
+
51
+ self.mid_numwords = [
52
+ (1000, "rihun"), (100, "atus"), (90, "sia nulu"),
53
+ (80, "ualu nulu"), (70, "hitu nulu"), (60, "neen nulu"),
54
+ (50, "lima nulu"), (40, "haat nulu"), (30, "tolu nulu"),
55
+ (20, "rua nulu")
56
+ ]
57
+ self.low_numwords = [
58
+ "sanulu",
59
+ "sia", "ualu", "hitu", "neen", "lima", "haat", "tolu", "rua",
60
+ "ida", "mamuk"
61
+ ]
62
+ self.hundreds = {
63
+ 1: "atus",
64
+ 2: "atus rua",
65
+ 3: "atus tolu",
66
+ 4: "atus haat",
67
+ 5: "atus lima",
68
+ 6: "atus neen",
69
+ 7: "atus hitu",
70
+ 8: "atus ualu",
71
+ 9: "atus sia",
72
+ }
73
+
74
+ def merge(self, curr, next):
75
+ ctext, cnum, ntext, nnum = curr + next
76
+
77
+ if cnum == 1 and nnum < 100:
78
+ return next
79
+
80
+ if nnum < cnum:
81
+ if nnum < 10:
82
+ value_str = str(cnum + nnum)
83
+ if int(value_str) > 100:
84
+ zero_list = value_str[1:-1]
85
+ all_zero = all(element == '0' for element in zero_list)
86
+ if all_zero:
87
+ if self.count >= 1:
88
+ self.count += 0
89
+ return (
90
+ "ho %s %s" % (ctext, ntext),
91
+ cnum + nnum
92
+ )
93
+ self.count += 1
94
+ return ("%s %s" % (ctext, ntext), cnum + nnum)
95
+
96
+ return ("%s resin %s" % (ctext, ntext), cnum + nnum)
97
+ else:
98
+ return ("%s %s" % (ctext, ntext), cnum + nnum)
99
+
100
+ return (ntext + " " + ctext, cnum * nnum)
101
+
102
+ def ho_result(self, result, value):
103
+ index = result.find('ho')
104
+ count_ho = result.count('ho')
105
+
106
+ if index != -1 and count_ho >= 1:
107
+ index_rihun = result.find('rihun')
108
+ value_str = len(str(value))
109
+ if index_rihun != -1 and value_str > 7:
110
+ result = result.replace("rihun ho", "ho rihun")
111
+ lows = ["kuatr", "tr", "b", "m"]
112
+ MEGA_SUFFIX = "iliaun"
113
+ for low in lows:
114
+ result = result.replace(
115
+ low + MEGA_SUFFIX + " ho", "ho " + low + MEGA_SUFFIX)
116
+ remove_first_ho = result.startswith('ho')
117
+ if remove_first_ho:
118
+ result = result[3:]
119
+ return result
120
+
121
+ def remove_ho(self, result, value):
122
+ value_str = str(value)
123
+ result = self.ho_result(result, value)
124
+ end_value = value_str[:-4]
125
+ end_true = end_value.endswith('0')
126
+ if end_true is False:
127
+ if value > 100:
128
+ if value_str[-1] != '0' and value_str[-2] == '0':
129
+ result = result.replace("ho", "")
130
+ result = result.replace(" ", " ")
131
+
132
+ return result
133
+
134
+ def to_cardinal(self, value):
135
+ result = super().to_cardinal(value)
136
+
137
+ results = self.remove_ho(result, value)
138
+ return results
139
+
140
+ def to_ordinal(self, value):
141
+ self.verify_ordinal(value)
142
+ out = ""
143
+ val = self.splitnum(value)
144
+ outs = val
145
+ while len(val) != 1:
146
+ outs = []
147
+ left, right = val[:2]
148
+ if isinstance(left, tuple) and isinstance(right, tuple):
149
+ outs.append(self.merge(left, right))
150
+ if val[2:]:
151
+ outs.append(val[2:])
152
+ else:
153
+ for elem in val:
154
+ if isinstance(elem, list):
155
+ if len(elem) == 1:
156
+ outs.append(elem[0])
157
+ else:
158
+ outs.append(self.clean(elem))
159
+ else:
160
+ outs.append(elem)
161
+ val = outs
162
+
163
+ words, num = outs[0]
164
+
165
+ words = self.remove_ho(words, value)
166
+
167
+ if num in [90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 5, 3, 2]:
168
+ words = 'da' + words + 'k'
169
+ if num in [6, 4]:
170
+ words = 'da' + words
171
+ if num == 1:
172
+ words = 'dahuluk'
173
+ if num in [900, 800, 700, 500, 300, 200, 100]:
174
+ words = 'dah' + words + 'k'
175
+ if num in [600, 400]:
176
+ words = 'dah' + words
177
+
178
+ words_split = words.split()
179
+ if len(words_split) >= 3 and num < 100:
180
+ first_word = 'da' + words_split[0]
181
+ second_word = " ".join(words_split[1:])
182
+ if 'haat' in second_word or 'neen' in second_word:
183
+ words = first_word + " " + second_word
184
+ else:
185
+ words = first_word + " " + second_word + 'k'
186
+
187
+ word_first = 'dah' + words_split[0]
188
+ if word_first == 'dahatus' and len(words_split) >= 3:
189
+ word_second = " ".join(words_split[1:])
190
+ if 'haat' in word_second or 'neen' in word_second:
191
+ words = word_first + " " + word_second
192
+ else:
193
+ words = word_first + " " + word_second + 'k'
194
+
195
+ if len(str(num)) > 3:
196
+ if 'haat' in words_split[-1:] or 'neen' in words_split[-1:]:
197
+ words = 'da' + words
198
+ else:
199
+ words = 'da' + words + 'k'
200
+
201
+ result = self.title(out + words)
202
+
203
+ return result
204
+
205
+ def to_ordinal_num(self, value):
206
+ self.verify_ordinal(value)
207
+ return "%sº" % (value)
208
+
209
+ def to_year(self, val, longval=True):
210
+ if val < 0:
211
+ return self.to_cardinal(abs(val)) + ' antes Kristu'
212
+ return self.to_cardinal(val)
213
+
214
+ def to_currency(self, val, currency='USD', cents=True):
215
+ """
216
+ Args:
217
+ val: Numeric value
218
+ currency (str): Currency code
219
+ cents (bool): Verbose cents
220
+ adjective (bool): Prefix currency name with adjective
221
+ Returns:
222
+ str: Formatted string
223
+
224
+ """
225
+ # Check if value has fractional cents
226
+ decimal_val = Decimal(str(val))
227
+ has_fractional_cents = (decimal_val * 100) % 1 != 0
228
+
229
+ # Check if input is an integer - don't show cents for integers
230
+ is_integer_input = isinstance(val, int)
231
+
232
+ left, right, is_negative = parse_currency_parts(val, is_int_with_cents=False)
233
+
234
+ try:
235
+ cr1, cr2 = self.CURRENCY_FORMS[currency]
236
+
237
+ except KeyError:
238
+ raise NotImplementedError(
239
+ 'Currency code "%s" not implemented for "%s"' %
240
+ (currency, self.__class__.__name__))
241
+
242
+ minus_str = "%s " % self.negword.strip() if is_negative else ""
243
+ money_str = self._money_verbose(left, currency)
244
+
245
+ # For integers, never show cents
246
+ if is_integer_input:
247
+ curr_name = self.pluralize(left, cr1)
248
+ return u'%s%s %s' % (
249
+ minus_str,
250
+ curr_name,
251
+ money_str
252
+ )
253
+
254
+ if has_fractional_cents and right > 0:
255
+ # Handle fractional cents using to_cardinal_float
256
+ fractional_cents = right / 100.0
257
+ cents_str = self.to_cardinal_float(fractional_cents) if hasattr(self, 'to_cardinal_float') else self.to_cardinal(fractional_cents)
258
+ else:
259
+ cents_str = self._cents_verbose(right, currency) \
260
+ if cents else self._cents_terse(right, currency)
261
+
262
+ if right == 0:
263
+ return u'%s%s %s' % (
264
+ minus_str,
265
+ self.pluralize(left, cr1),
266
+ money_str
267
+ )
268
+ else:
269
+ if has_fractional_cents:
270
+ # For fractional cents, use different formatting
271
+ return u'%s%s %s %s %s' % (
272
+ minus_str,
273
+ self.pluralize(left, cr1),
274
+ money_str,
275
+ cents_str,
276
+ self.pluralize(1, cr2) # Use singular for fractional
277
+ )
278
+ else:
279
+ return u'%s%s %s %s %s' % (
280
+ minus_str,
281
+ self.pluralize(left, cr1),
282
+ money_str,
283
+ self.pluralize(right, cr2),
284
+ cents_str
285
+ )
num2words2/lang_TG.py ADDED
@@ -0,0 +1,149 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
3
+ # Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
4
+
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16
+ # MA 02110-1301 USA
17
+
18
+ from __future__ import division, print_function, unicode_literals
19
+
20
+ from . import lang_EUR
21
+
22
+ GENERIC_DOLLARS = ("доллар", "доллар")
23
+ GENERIC_CENTS = ("сент", "сент")
24
+
25
+
26
+ class Num2Word_TG(lang_EUR.Num2Word_EUR):
27
+ CURRENCY_FORMS = {
28
+ # repalced by EUR
29
+ "EUR": (("евро", "евро"), GENERIC_CENTS),
30
+ # replaced by EUR
31
+ "USD": (GENERIC_DOLLARS, GENERIC_CENTS),
32
+ "RUB": (("рубл", "рубл"), ("копейк", "копейк")),
33
+ "TJS": (("сомонӣ", "сомонӣ"), ("дирам", "дирам")),
34
+ }
35
+
36
+ GIGA_SUFFIX = "иллиард"
37
+ MEGA_SUFFIX = "иллион"
38
+
39
+ def set_high_numwords(self, high):
40
+ cap = 3 * (len(high) + 1)
41
+
42
+ for word, n in zip(high, range(cap, 5, -3)):
43
+ if n == 9:
44
+ self.cards[10 ** n] = word + self.GIGA_SUFFIX
45
+
46
+ else:
47
+ self.cards[10 ** n] = word + self.MEGA_SUFFIX
48
+
49
+ def setup(self):
50
+ super(Num2Word_TG, self).setup()
51
+
52
+ lows = ["квинт", "квадр", "тр", "м", "м"]
53
+ self.high_numwords = self.gen_high_numwords([], [], lows)
54
+ self.negword = "минус "
55
+ self.pointword = "нуқта"
56
+ self.exclude_title = ["ва", "минус", "нуқта"]
57
+
58
+ self.mid_numwords = [
59
+ (1000, "ҳазор"),
60
+ (100, "сад"),
61
+ (90, "навад"),
62
+ (80, "ҳаштод"),
63
+ (70, "ҳафтод"),
64
+ (60, "шаст"),
65
+ (50, "панҷоҳ"),
66
+ (40, "чил"),
67
+ (30, "си"),
68
+ ]
69
+ self.low_numwords = [
70
+ "бист",
71
+ "нуздаҳ",
72
+ "ҳаждаҳ",
73
+ "ҳабдаҳ",
74
+ "шонздаҳ",
75
+ "понздаҳ",
76
+ "чордаҳ",
77
+ "сенздаҳ",
78
+ "дувоздаҳ",
79
+ "ёздаҳ",
80
+ "даҳ",
81
+ "нӯҳ",
82
+ "ҳашт",
83
+ "ҳафт",
84
+ "шаш",
85
+ "панҷ",
86
+ "чор",
87
+ "се",
88
+ "ду",
89
+ "як",
90
+ "сифр",
91
+ ]
92
+
93
+ def to_cardinal(self, value):
94
+ try:
95
+ assert int(value) == value
96
+ except (ValueError, TypeError, AssertionError):
97
+ return self.to_cardinal_float(value)
98
+
99
+ out = ""
100
+ if value < 0:
101
+ value = abs(value)
102
+ out = self.negword
103
+
104
+ if value >= self.MAXVAL:
105
+ raise OverflowError(self.errmsg_toobig % (value, self.MAXVAL))
106
+
107
+ if value == 100:
108
+ return self.title(out + "сад")
109
+ else:
110
+ val = self.splitnum(value)
111
+ words, num = self.clean(val)
112
+ return self.title(out + words)
113
+
114
+ def merge(self, lpair, rpair):
115
+ ltext, lnum = lpair
116
+ rtext, rnum = rpair
117
+ if lnum == 1 and rnum < 100:
118
+ return (rtext, rnum)
119
+ elif 100 > lnum > rnum:
120
+ if ltext == "си":
121
+ return ("%sю %s" % (ltext, rtext), lnum + rnum)
122
+ elif ltext == "панҷоҳ":
123
+ return ("панҷову %s" % (rtext), lnum + rnum)
124
+ else:
125
+ return ("%sу %s" % (ltext, rtext), lnum + rnum)
126
+ elif lnum >= 100 > rnum:
127
+ return ("%sу %s" % (ltext, rtext), lnum + rnum)
128
+ elif rnum > lnum:
129
+ if ltext == "яксад" and rtext not in self.low_numwords:
130
+ return ("сад %s" % (rtext), lnum * rnum)
131
+ if rtext == "сад":
132
+ return ("%s%s" % (ltext, rtext), lnum * rnum)
133
+ else:
134
+ return ("%s %s" % (ltext, rtext), lnum * rnum)
135
+ return ("%sу %s" % (ltext, rtext), lnum + rnum)
136
+
137
+ def to_ordinal(self, value):
138
+ self.verify_ordinal(value)
139
+ cardinal = self.to_cardinal(value)
140
+ outwords = cardinal.split(" ")
141
+ lastword = outwords[-1]
142
+ if lastword in ["ду", "се", "си"]:
143
+ return "%sюм" % (cardinal)
144
+ else:
145
+ return "%sум" % (cardinal)
146
+
147
+ def to_ordinal_num(self, value):
148
+ self.verify_ordinal(value)
149
+ return "%s%s" % (value, self.to_ordinal(value)[-2:])