Rev 16169 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10915 | bpr | 1 | !if $wims_read_parm!=slib_header |
13585 | bpr | 2 | !goto proc |
10915 | bpr | 3 | !endif |
4 | |||
15639 | bpr | 5 | slib_author=Bernadette, Perrin-Riou; Raoul, Hatterer; Eric, Reyssat |
6 | slib_parms=3\ |
||
15626 | reyssat | 7 | ,number\ |
8 | ,language (fr,en,it ; default=fr)\ |
||
16169 | bpr | 9 | ,space separated options in brackets (works in french): frrule (trad/1990, default=1990),type (card/ord, default=card), plural (yes/no, default=no), fracdenom (yes/no, default=yes), 70=septante 80=huitante 90=nonante |
15626 | reyssat | 10 | |
16165 | bpr | 11 | slib_example=5678\ |
10915 | bpr | 12 | [678,122]\ |
13 | [295,180],fr\ |
||
11751 | bpr | 14 | [295,180],en\ |
10915 | bpr | 15 | [181,1008,1081,200,201,280]\ |
11751 | bpr | 16 | [181,1008,1081,200,201,280],en\ |
14528 | czzmrn | 17 | [181,1008,1081,200,201,280],it\ |
15626 | reyssat | 18 | 80080,fr\ |
11751 | bpr | 19 | [9880,99120],fr\ |
14528 | czzmrn | 20 | [9880,99120],en\ |
15626 | reyssat | 21 | [9880,99120],it\ |
15639 | bpr | 22 | 371,fr,[type=ord plural=yes]\ |
23 | 371,fr,[type=ord plural=yes frrule=trad]\ |
||
24 | 4,fr,[type=ord]\ |
||
25 | 4,fr,[type=ord plural=yes fracdenom=no]\ |
||
15626 | reyssat | 26 | [0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], fr\ |
14528 | czzmrn | 27 | [0,1,10,100,1000,10000,100000,1000000,10000000], en\ |
16161 | bpr | 28 | [0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], it\ |
16169 | bpr | 29 | [678,9880,99120],fr,[type=ord 70=septante 80=huitante 90=nonante]\ |
30 | [485,95,1881,91],fr,[70=septante 80=huiptante] |
||
11751 | bpr | 31 | |
10915 | bpr | 32 | !exit |
33 | |||
34 | :proc |
||
35 | |||
15626 | reyssat | 36 | |
37 | !! Extraction des paramètres et options |
||
38 | !distribute item $wims_read_parm into slib_data,slib_language,slib_options |
||
15639 | bpr | 39 | slib_options=!declosing $slib_options |
15626 | reyssat | 40 | |
41 | slib_rule=!getopt frrule in $slib_options |
||
42 | !default slib_rule=1990 |
||
43 | slib_type=!getopt type in $slib_options |
||
44 | !default slib_type=card |
||
45 | slib_plural=!getopt plural in $slib_options |
||
46 | !default slib_plural=no |
||
47 | slib_fden=!getopt fracdenom in $slib_options |
||
48 | !default slib_fden=yes |
||
16169 | bpr | 49 | slib_variant7=!getopt 70 in $slib_options |
50 | slib_variant8=!getopt 80 in $slib_options |
||
51 | slib_variant9=!getopt 90 in $slib_options |
||
11751 | bpr | 52 | slib_language= $(wims_read_parm[2]) |
15766 | czzmrn | 53 | !if $slib_language notwordof it fr en |
54 | slib_language=fr |
||
55 | !endif |
||
10915 | bpr | 56 | !reset slib_out |
57 | slib_data= $(wims_read_parm[1]) |
||
58 | slib_data=!declosing $slib_data |
||
11751 | bpr | 59 | !if $slib_language=en |
60 | !! english transcription |
||
61 | !! author : Raoul HATTERER |
||
62 | !! algorithm: http://www.blackwasp.co.uk/NumberToWords.aspx |
||
10915 | bpr | 63 | |
11751 | bpr | 64 | slib_smallNumbers = one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen |
65 | slib_tyWords = , twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety |
||
66 | slib_scaleNumbers = ,thousand, million, billion |
||
67 | |||
68 | !for slib_number in $slib_data |
||
69 | !! Zero Rule. |
||
70 | !! If the value is zero then the number in words is 'zero' |
||
71 | !! and no other rules apply. |
||
72 | !if $slib_number==0 |
||
73 | slib_combined=zero |
||
74 | !else |
||
75 | !! Three Digit Rule. |
||
76 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
77 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
15638 | reyssat | 78 | !! of the relevant scale number (thousand, million, billion). |
11751 | bpr | 79 | |
80 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
15639 | bpr | 81 | !reset slib_3digitsGroups |
82 | !for slib_scale= 1 to 4 |
||
83 | slib_3digits=!char -3 to -1 of $slib_number |
||
84 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
11751 | bpr | 85 | slib_number=!char 1 to -4 of $slib_number |
15639 | bpr | 86 | !next |
11751 | bpr | 87 | |
88 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
||
15639 | bpr | 89 | !reset slib_textGroups |
90 | !for slib_scale= 1 to 4 |
||
91 | slib_3digits= !column $slib_scale of $slib_3digitsGroups |
||
92 | !if $slib_3digits > 99 |
||
93 | slib_hundreds=!char -3 of $slib_3digits |
||
94 | !else |
||
95 | slib_hundreds=0 |
||
96 | !endif |
||
97 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
98 | slib_tens=!char -2 of $slib_3digits |
||
99 | slib_units=!char -1 of $slib_3digits |
||
100 | !! Hundreds Rules. |
||
101 | !! If the hundreds portion of a three-digit group is not zero, |
||
102 | !! the number of hundreds is added as a word. |
||
103 | !! If the three-digit group is exactly divisible by one hundred, |
||
104 | !! the text 'hundred' is appended. |
||
105 | !! If not, the text "hundred and" is appended. |
||
106 | !! eg. 'two hundred' or 'one hundred and twelve' |
||
107 | !reset slib_3digitsText |
||
108 | !if $slib_hundreds!=0 |
||
109 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
11751 | bpr | 110 | slib_3digitsText = $slib_3digitsText hundred |
15639 | bpr | 111 | !if $slib_tensUnits!=00 |
112 | slib_3digitsText = $slib_3digitsText and |
||
113 | !endif |
||
114 | !endif |
||
11751 | bpr | 115 | |
15639 | bpr | 116 | !! Tens Rules. |
117 | !! If the tens section of a three-digit group is two or higher, |
||
118 | !! the appropriate '-ty' word (twenty, thirty, etc.) is added |
||
119 | !! to the text and followed by the name of the third digit |
||
120 | !! (unless the third digit is a zero, which is ignored). |
||
121 | !! If the tens and the units are both zero, no text is added. |
||
122 | !! For any other value, the name of the one or two-digit number |
||
123 | !! is added as a special case. |
||
124 | !if $slib_tens >= 2 |
||
125 | slib_tyWord=!column $slib_tens of $slib_tyWords |
||
126 | slib_3digitsText= $slib_3digitsText $slib_tyWord |
||
127 | !if $slib_units!= 0 |
||
128 | slib_unitWord=!column $slib_units of $slib_smallNumbers |
||
129 | slib_3digitsText=$slib_3digitsText-$slib_unitWord |
||
130 | !endif |
||
131 | !else |
||
132 | !if $[$slib_tensUnits]!= 0 |
||
133 | slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers |
||
134 | slib_3digitsText= $slib_3digitsText $slib_tenUnitWord |
||
135 | !endif |
||
136 | !endif |
||
137 | !if $slib_3digits==000 |
||
138 | slib_3digitsText=zero |
||
139 | !endif |
||
140 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
141 | !next |
||
11751 | bpr | 142 | |
15639 | bpr | 143 | !! Recombination Rules. |
144 | !! When recombining the translated three-digit groups, |
||
145 | !! each group except the last is followed by a large number name |
||
146 | !! and a comma, |
||
147 | !! unless the group is blank and therefore not included at all. |
||
148 | !! One exception is when the final group does not include |
||
149 | !! any hundreds and there is more than one non-blank group. |
||
150 | !! In this case, the final comma is replaced with 'and'. |
||
151 | !! eg. 'one billion, one million and twelve'. |
||
11751 | bpr | 152 | |
15639 | bpr | 153 | slib_combined = !column 1 of $slib_textGroups |
154 | !if $slib_combined=zero |
||
155 | slib_combined= |
||
156 | !endif |
||
157 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
158 | !if $[$slib_3digits]>0 and $[$slib_3digits]<100 |
||
159 | slib_appendAnd=true |
||
160 | !else |
||
161 | slib_appendAnd=false |
||
162 | !endif |
||
163 | !for slib_scale = 2 to 4 |
||
164 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
165 | !if $[$slib_3digits]!=0 |
||
166 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
||
167 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbers |
||
168 | slib_prefix = $slib_3digitsText $slib_scaleNumber |
||
169 | !if $slib_appendAnd==true |
||
170 | slib_prefix=$slib_prefix and |
||
171 | slib_appendAnd=false |
||
172 | !else |
||
173 | slib_empty=!charcnt $slib_combined |
||
174 | !if $slib_empty!=0 |
||
175 | slib_prefix=$slib_prefix, |
||
176 | !endif |
||
177 | !endif |
||
178 | slib_combined=$slib_prefix $slib_combined |
||
179 | !endif |
||
180 | !next |
||
11751 | bpr | 181 | !endif |
182 | slib_out=!append item $slib_combined to $slib_out |
||
183 | !next |
||
14528 | czzmrn | 184 | !goto end |
15639 | bpr | 185 | !! todo: ten million should be ten millions etc. |
186 | !endif |
||
14528 | czzmrn | 187 | |
188 | !if $slib_language=it |
||
15639 | bpr | 189 | !! use adapted English algorithm (MC) |
14528 | czzmrn | 190 | slib_smallNumbers = uno, due, tre, quattro, cinque, sei, sette, otto, nove, dieci, undici, dodici, tredici, quattordici, quindici, sedici, diciassette, diciotto, diciannove |
191 | slib_tyWords = , venti, trenta, quaranta, cinquanta, sessanta, settanta, ottanta, novanta |
||
192 | slib_scaleNumbers = ,mila, milioni, miliardi |
||
193 | |||
194 | !for slib_number in $slib_data |
||
195 | !! Zero Rule. |
||
196 | !! If the value is zero then the number in words is 'zero' |
||
197 | !! and no other rules apply. |
||
198 | !if $slib_number==0 |
||
199 | slib_combined=zero |
||
200 | !else |
||
201 | !! Three Digit Rule. |
||
202 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
203 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
15639 | bpr | 204 | !! of the relevant scale number (thousand, million, billion). |
14528 | czzmrn | 205 | |
206 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
15639 | bpr | 207 | !reset slib_3digitsGroups |
208 | !for slib_scale= 1 to 4 |
||
209 | slib_3digits=!char -3 to -1 of $slib_number |
||
210 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
14528 | czzmrn | 211 | slib_number=!char 1 to -4 of $slib_number |
15639 | bpr | 212 | !next |
14528 | czzmrn | 213 | |
214 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
||
15639 | bpr | 215 | !reset slib_textGroups |
216 | !for slib_scale= 1 to 4 |
||
217 | slib_3digits= !column $slib_scale of $slib_3digitsGroups |
||
218 | !if $slib_3digits > 99 |
||
219 | slib_hundreds=!char -3 of $slib_3digits |
||
220 | !else |
||
221 | slib_hundreds=0 |
||
222 | !endif |
||
223 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
224 | slib_tens=!char -2 of $slib_3digits |
||
225 | slib_units=!char -1 of $slib_3digits |
||
226 | !! Hundreds Rules. |
||
227 | !! If the hundreds portion of a three-digit group is not zero |
||
228 | !! if it is 1, the word "uno" is omitted, |
||
229 | !! the number of hundreds is added as a word. |
||
230 | !reset slib_3digitsText |
||
231 | !if $slib_hundreds!=0 |
||
232 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
233 | !if $slib_hundreds==1 |
||
234 | slib_3digitsText = cento |
||
235 | !else |
||
236 | slib_3digitsText = $slib_3digitsText cento |
||
237 | !endif |
||
238 | !endif |
||
14528 | czzmrn | 239 | |
15639 | bpr | 240 | !! Tens Rules. |
241 | !! If the tens section of a three-digit group is two or higher, |
||
242 | !! the appropriate '-ty' word (twenty, thirty, etc.) is added |
||
243 | !! to the text and followed by the name of the third digit |
||
244 | !! (unless the third digit is a zero, which is ignored). |
||
245 | !! If the tens and the units are both zero, no text is added. |
||
246 | !! For any other value, the name of the one or two-digit number |
||
247 | !! is added as a special case. |
||
248 | !if $slib_tens >= 2 |
||
249 | slib_tyWord=!column $slib_tens of $slib_tyWords |
||
250 | slib_3digitsText= $slib_3digitsText $slib_tyWord |
||
251 | !if $slib_units!= 0 |
||
252 | slib_unitWord=!column $slib_units of $slib_smallNumbers |
||
253 | slib_3digitsText=$slib_3digitsText $slib_unitWord |
||
254 | !endif |
||
255 | !else |
||
256 | !if $[$slib_tensUnits]!= 0 |
||
257 | slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers |
||
258 | slib_3digitsText= $slib_3digitsText $slib_tenUnitWord |
||
259 | !endif |
||
260 | !endif |
||
261 | !if $slib_3digits==000 |
||
262 | slib_3digitsText=zero |
||
263 | !endif |
||
264 | slib_3digitsText=!nospace $slib_3digitsText |
||
265 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
266 | !next |
||
14528 | czzmrn | 267 | |
15639 | bpr | 268 | !! Recombination Rules. |
269 | !! When recombining the translated three-digit groups, |
||
270 | !! each group except the last is followed by a large number name |
||
271 | !! unless the group is blank and therefore not included at all. |
||
272 | !! One exception is when the final group does not include |
||
273 | !! any hundreds and there is more than one non-blank group. |
||
274 | !! In this case, the final comma is replaced with 'and'. |
||
275 | !! eg. 'one billion, one million and twelve'. |
||
14528 | czzmrn | 276 | |
15639 | bpr | 277 | slib_combined = !column 1 of $slib_textGroups |
278 | !if $slib_combined=zero |
||
279 | slib_combined= |
||
280 | !endif |
||
281 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
282 | !if $[$slib_3digits]>0 and $[$slib_3digits]<100 |
||
283 | slib_appendAnd=true |
||
284 | !else |
||
285 | slib_appendAnd=false |
||
286 | !endif |
||
287 | !for slib_scale = 2 to 4 |
||
288 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
289 | !if $[$slib_3digits]!=0 |
||
290 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
||
291 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbers |
||
292 | !if $[$slib_3digits]==1 |
||
293 | !if $slib_scale=2 |
||
294 | slib_prefix = mille |
||
295 | !else |
||
296 | !! !if $slib_prefix==2 |
||
297 | slib_prefix = un $slib_scaleNumber |
||
298 | !! !else |
||
299 | !! slib_prefix = $slib_scaleNumber |
||
300 | !! !endif |
||
301 | !endif |
||
302 | !else |
||
303 | !if $slib_scale=2 |
||
304 | slib_prefix = $slib_3digitsText$slib_scaleNumber |
||
305 | !else |
||
306 | slib_prefix = $slib_3digitsText $slib_scaleNumber |
||
307 | !endif |
||
308 | !endif |
||
309 | !if $slib_appendAnd==true |
||
310 | slib_prefix=$slib_prefix e |
||
311 | slib_appendAnd=false |
||
312 | !else |
||
313 | slib_empty=!charcnt $slib_combined |
||
314 | !if $slib_empty!=0 |
||
315 | slib_prefix=$slib_prefix |
||
316 | !endif |
||
317 | !endif |
||
318 | slib_combined=$slib_prefix $slib_combined |
||
319 | !endif |
||
320 | !next |
||
14528 | czzmrn | 321 | !endif |
322 | slib_out=!append item $slib_combined to $slib_out |
||
323 | !next |
||
15639 | bpr | 324 | !! contrazioni eufoniche di vocali |
14528 | czzmrn | 325 | slib_out=!replace internal oo by o in $slib_out |
326 | slib_out=!replace internal antauno by antuno in $slib_out |
||
14529 | czzmrn | 327 | slib_out=!replace internal antaotto by antotto in $slib_out |
14528 | czzmrn | 328 | slib_out=!replace internal tiuno by tuno in $slib_out |
14529 | czzmrn | 329 | slib_out=!replace internal tiotto by totto in $slib_out |
15639 | bpr | 330 | !! need singular |
14528 | czzmrn | 331 | slib_out=!replace internal un milioni by un milione in $slib_out |
332 | slib_out=!replace internal un miliardi by un miliardo in $slib_out |
||
15639 | bpr | 333 | !goto end |
14528 | czzmrn | 334 | !endif |
335 | |||
15626 | reyssat | 336 | !if $slib_language=fr |
15638 | reyssat | 337 | !! use adapted English algorithm (E.R.) |
338 | !! treats simultaneously cardinal and ordinal numbers |
||
15639 | bpr | 339 | |
15626 | reyssat | 340 | slib_smallNumbers = un, deux, trois, quatre, cinq, six, sept, huit, neuf, dix, onze, douze, treize, quatorze, quinze, seize, dix-sept, dix-huit, dix-neuf |
15638 | reyssat | 341 | slib_tyWords = , vingt, trente, quarante, cinquante, soixante, soixante, quatre-vingt, quatre-vingt |
15626 | reyssat | 342 | slib_scaleNumbers = ,mille, million, milliard |
343 | slib_smallNumbersOrd = unième, deuxième, troisième, quatrième, cinquième, sixième, septième, huitième, neuvième, dixième, onzième, douzième, treizième, quatorzième, quinzième, seizième, dix-septième, dix-huitième, dix-neuvième |
||
15639 | bpr | 344 | slib_tyWordsOrd = , vingtième, trentième, quarantième, cinquantième, soixantième, , quatre-vingtième, |
15626 | reyssat | 345 | slib_scaleNumbersOrd = ,millième, millionième, milliardième |
16165 | bpr | 346 | slib_var1=7,9 |
347 | slib_var2=2,3,4,5,6,8 |
||
348 | slib_var3=8 |
||
16169 | bpr | 349 | !if $slib_variant7!=$empty |
350 | slib_tyWords=!replace item number 7 by $slib_variant7 in $slib_tyWords |
||
351 | slib_variantie7=!char 1 to -2 of $slib_variant7 |
||
352 | slib_variantie7=$(slib_variantie7)ième |
||
353 | slib_tyWordsOrd=!replace item number 7 by $slib_variantie7 in $slib_tyWordsOrd |
||
16165 | bpr | 354 | slib_var1=!listcomplement 7 in $slib_var1 |
355 | slib_var2=$slib_var2,7 |
||
356 | !endif |
||
16169 | bpr | 357 | !if $slib_variant8!=$empty |
358 | slib_tyWords=!replace item number 8 by $slib_variant8 in $slib_tyWords |
||
359 | slib_variantie8=!char 1 to -2 of $slib_variant8 |
||
360 | slib_variantie8=$(slib_variantie8)ième |
||
361 | slib_tyWordsOrd=!replace item number 8 by $slib_variantie8 in $slib_tyWordsOrd |
||
16165 | bpr | 362 | slib_var1=!listcomplement 8 in $slib_var1 |
363 | slib_var2=$slib_var2,8 |
||
364 | slib_var3= |
||
365 | !endif |
||
16169 | bpr | 366 | !if $slib_variant9!=$empty |
367 | slib_tyWords=!replace item number 9 by $slib_variant9 in $slib_tyWords |
||
368 | slib_variantie9=!char 1 to -2 of $slib_variant9 |
||
369 | slib_variantie9=$(slib_variantie9)ième |
||
370 | slib_tyWordsOrd=!replace item number 9 by $slib_variantie9 in $slib_tyWordsOrd |
||
16165 | bpr | 371 | slib_var1=!listcomplement 9 in $slib_var1 |
372 | slib_var2=$slib_var2,9 |
||
373 | !endif |
||
374 | slib_var2=!sort list $slib_var2 |
||
15638 | reyssat | 375 | !! mark for french plural (so we can use $s) |
15626 | reyssat | 376 | s=s |
15638 | reyssat | 377 | |
15639 | bpr | 378 | !! join words with space character (traditional french rule) or - sign (1990 french "new spelling" rule) |
15626 | reyssat | 379 | !if $slib_rule issamecase trad |
15639 | bpr | 380 | tiret=$ $ |
15626 | reyssat | 381 | !else |
382 | tiret=- |
||
15639 | bpr | 383 | !endif |
15638 | reyssat | 384 | et=$(tiret)et$tiret |
15626 | reyssat | 385 | |
386 | !for slib_number in $slib_data |
||
15638 | reyssat | 387 | !! Zero and small ordinals (<=4) treated first separately. |
388 | !! If the value is zero then the cardinal number in words is 'zero' (ordinal is 'zéro-ième') |
||
15626 | reyssat | 389 | !! and no other rules apply. |
390 | !if $slib_number==0 |
||
391 | !if $slib_type issamecase ord |
||
15638 | reyssat | 392 | slib_combined=zéro-ième |
15626 | reyssat | 393 | !else |
15638 | reyssat | 394 | slib_combined=zéro |
15626 | reyssat | 395 | !endif |
396 | !else |
||
397 | !if $[$slib_number]<5 and ($slib_type issamecase ord) |
||
398 | !if $slib_fden issamecase no |
||
15639 | bpr | 399 | slib_ordinals=premier,deuxième,troisième,quatrième |
15626 | reyssat | 400 | !else |
15639 | bpr | 401 | slib_ordinals=unième,demi,tiers,quart |
15626 | reyssat | 402 | !endif |
403 | slib_combined=!column $slib_number of $slib_ordinals |
||
404 | |||
15638 | reyssat | 405 | !else !! GENERAL CASE of slib_number, neither 0 nor small ordinal |
15639 | bpr | 406 | |
15638 | reyssat | 407 | !! Three Digit Rule. |
408 | !! The integer value is split into groups of three digits starting from the right-hand side. |
||
409 | !! Once converted to text, the three-digit groups are recombined with the addition |
||
410 | !! of the relevant scale number (mille, million, milliard). |
||
15639 | bpr | 411 | |
15638 | reyssat | 412 | !! First, split in groups of 3 starting from right |
413 | !reset slib_3digitsGroups |
||
414 | !for slib_scale= 1 to 4 |
||
415 | slib_3digits=!char -3 to -1 of $slib_number |
||
416 | slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups |
||
417 | slib_number=!char 1 to -4 of $slib_number |
||
418 | !next |
||
15639 | bpr | 419 | |
15638 | reyssat | 420 | !! Each set of three digits is then processed individually as a number of hundreds, tens and units. |
421 | !! flag slib_endOfNb to mark if we the current digit is the last non zero one in the whole number |
||
422 | !! (to know if we add 'ième' here to ordinal number) |
||
423 | slib_endOfNb=yes |
||
424 | !reset slib_textGroups |
||
425 | !for slib_scale= 1 to 4 |
||
426 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
427 | !if $slib_3digits > 99 |
||
428 | slib_hundreds=!char -3 of $slib_3digits |
||
429 | !else |
||
430 | slib_hundreds=0 |
||
431 | !endif |
||
432 | slib_tensUnits=!char -2 to -1 of $slib_3digits |
||
433 | slib_tens=!char -2 of $slib_3digits |
||
15626 | reyssat | 434 | |
15638 | reyssat | 435 | !! due to french oddity : 78 = 60 + 18 , 93 = 80 + 13 |
16165 | bpr | 436 | !if $[$slib_tens] isin $slib_var1 |
15638 | reyssat | 437 | slib_tU=$[$slib_tensUnits-10*($slib_tens-1)] |
438 | !else |
||
439 | slib_tU=$slib_tensUnits |
||
440 | !endif |
||
441 | slib_units=!char -1 of $slib_3digits |
||
15639 | bpr | 442 | |
15638 | reyssat | 443 | !! Hundreds Rules. |
444 | !! If the hundreds portion of a three-digit group is not zero |
||
445 | !! the number of hundreds is added as a word (except if it is 1) |
||
446 | !! and then the word 'cent/cents/centième (depending on singular/plural/ordinal) |
||
447 | !reset slib_3digitsText |
||
15639 | bpr | 448 | |
15638 | reyssat | 449 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) and ($[$slib_tensUnits]==0) |
450 | slib_centType=centième |
||
451 | slib_centsType=centième |
||
452 | slib_endOfNb=no |
||
453 | !else |
||
454 | slib_centType=cent |
||
455 | slib_centsType=cents |
||
456 | !endif |
||
15639 | bpr | 457 | |
15638 | reyssat | 458 | !if $slib_hundreds!=0 |
459 | slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers |
||
460 | !if $slib_hundreds==1 |
||
461 | !if $slib_tensUnits>0 |
||
462 | slib_3digitsText = cent$tiret |
||
15639 | bpr | 463 | !else |
15638 | reyssat | 464 | slib_3digitsText = $slib_centType |
465 | !endif |
||
466 | !else |
||
467 | !if $slib_tensUnits>0 |
||
468 | slib_3digitsText = $slib_3digitsText$(tiret)cent$tiret |
||
469 | !else |
||
470 | slib_3digitsText = $slib_3digitsText$(tiret)$slib_centsType |
||
471 | !endif |
||
472 | !endif |
||
473 | !endif |
||
15639 | bpr | 474 | |
15638 | reyssat | 475 | !! Tens Rules. |
476 | !! If the tens section of a three-digit group is two or higher, |
||
477 | !! the appropriate '-ty' word (vingt, trente, etc.) is added |
||
478 | !! to the text and followed by the name of the third digit |
||
479 | !! (unless the third digit is a zero, which is ignored, but for 70, 90, the 'third digit' is dix)). |
||
15639 | bpr | 480 | !! French oddity : add 'et' between tens and units when units=1, except if tens=8 (vingt-et-un, quatre-vingt-un) |
481 | !! Similar rule for 71 |
||
482 | !! French oddity : quatre-vingts with s iff nothing after. |
||
15638 | reyssat | 483 | !! If the tens and the units are both zero, no text is added. |
15639 | bpr | 484 | !! 7x and 9x are treated differently. |
15638 | reyssat | 485 | !! For any other value, the name of the one or two-digit number |
486 | !! is added as a special case. |
||
15626 | reyssat | 487 | |
15638 | reyssat | 488 | !! _tyWord ends differently if ordinal number without unit 'digit' |
16168 | bpr | 489 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) and ($slib_units==0) and ($slib_tens isin $slib_var2) |
15638 | reyssat | 490 | slib_tyWordsType=$slib_tyWordsOrd |
491 | slib_endOfNb=no |
||
492 | !else |
||
493 | slib_tyWordsType=$slib_tyWords |
||
494 | !endif |
||
15639 | bpr | 495 | |
15638 | reyssat | 496 | !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes) |
497 | slib_smallNumbersType=$slib_smallNumbersOrd |
||
498 | slib_endOfNb=no |
||
499 | !else |
||
500 | slib_smallNumbersType=$slib_smallNumbers |
||
501 | !endif |
||
15639 | bpr | 502 | |
16165 | bpr | 503 | !if $slib_tens>=2 |
15638 | reyssat | 504 | slib_tyWord=!column $slib_tens of $slib_tyWordsType |
505 | slib_3digitsText= $slib_3digitsText$slib_tyWord |
||
16165 | bpr | 506 | !if $[$slib_tens] isin $slib_var2 |
15638 | reyssat | 507 | !if $slib_units!= 0 |
508 | slib_unitWord=!column $slib_units of $slib_smallNumbersType |
||
16165 | bpr | 509 | !if $slib_units>1 or $slib_tens==$slib_var3 |
15638 | reyssat | 510 | slib_3digitsText=$slib_3digitsText-$slib_unitWord |
511 | !else |
||
512 | slib_3digitsText=$slib_3digitsText$et$slib_unitWord |
||
513 | !endif |
||
514 | !endif |
||
16168 | bpr | 515 | !if ($slib_tensUnits==$[$slib_var3*10]) and ($slib_type==card) and ($slib_scale==1) |
15638 | reyssat | 516 | slib_3digitsText=$slib_3digitsText$s |
15639 | bpr | 517 | !endif |
16165 | bpr | 518 | !else !! donc slib_tens vaut 7 ou 9 en general |
15638 | reyssat | 519 | !if $[$slib_tensUnits]!= 0 |
520 | slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType |
||
521 | !if $[$slib_tensUnits]==71 |
||
522 | slib_tenUnitWord=$et$slib_tenUnitWord |
||
523 | slib_3digitsText=$slib_3digitsText$slib_tenUnitWord |
||
15639 | bpr | 524 | !else |
15638 | reyssat | 525 | slib_3digitsText=$slib_3digitsText-$slib_tenUnitWord |
15639 | bpr | 526 | !endif |
15638 | reyssat | 527 | !endif |
528 | !endif |
||
16165 | bpr | 529 | !else !! donc slib_tens vaut 0 ou 1 |
15638 | reyssat | 530 | slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType |
531 | slib_3digitsText= $slib_3digitsText$slib_tenUnitWord |
||
532 | !endif |
||
533 | !if $slib_3digits==000 |
||
534 | slib_3digitsText=zero |
||
535 | !endif |
||
536 | slib_textGroups=!append item $slib_3digitsText to $slib_textGroups |
||
15626 | reyssat | 537 | |
15638 | reyssat | 538 | !! if this pack of 3 digits is non zero then next packs are not at end of number (useful for ordinals) |
539 | !if $[$slib_3digits]!=0 |
||
540 | slib_endOfNb=no |
||
541 | !endif |
||
542 | !next |
||
15639 | bpr | 543 | |
15638 | reyssat | 544 | !! Recombination Rules. |
545 | !! When recombining the translated three-digit groups, |
||
546 | !! each group except the last is followed by a scale number name |
||
547 | !! unless the group is blank and therefore not included at all. |
||
15639 | bpr | 548 | |
15638 | reyssat | 549 | slib_endOfNb=yes |
550 | slib_combined = !column 1 of $slib_textGroups |
||
551 | !if $slib_combined=zero |
||
552 | slib_combined= |
||
553 | !endif |
||
554 | slib_3digits=!column 1 of $slib_3digitsGroups |
||
555 | !if $[$slib_3digits]>0 |
||
556 | slib_endOfNb=no |
||
557 | !endif |
||
558 | !for slib_scale = 2 to 4 |
||
559 | slib_3digits=!column $slib_scale of $slib_3digitsGroups |
||
560 | !if $[$slib_3digits]!=0 |
||
15639 | bpr | 561 | !! do we use cardinal or ordinal scale number name (mille/millième, ...) ? |
562 | !if ($slib_endOfNb issamecase yes) and ($slib_type issamecase ord) |
||
15638 | reyssat | 563 | slib_scaleNumbersType=$slib_scaleNumbersOrd |
564 | slib_endOfNb=no |
||
565 | !else |
||
566 | slib_scaleNumbersType=$slib_scaleNumbers |
||
567 | !endif |
||
15626 | reyssat | 568 | slib_3digitsText=!column $slib_scale of $slib_textGroups |
16165 | bpr | 569 | slib_scaleNumber=!column $slib_scale of $slib_scaleNumbersType |
15638 | reyssat | 570 | !if $[$slib_3digits]==1 |
571 | !if $slib_scale=2 |
||
572 | slib_prefix = $slib_scaleNumber |
||
573 | !else |
||
574 | !if ($slib_type issamecase ord) and ($slib_scaleNumbersType issamecase $slib_scaleNumbersOrd) |
||
575 | slib_prefix = $slib_scaleNumber |
||
576 | !else |
||
577 | slib_prefix = un$tiret$slib_scaleNumber |
||
578 | !endif |
||
579 | !endif |
||
580 | !else |
||
581 | slib_prefix = $slib_3digitsText$tiret$slib_scaleNumber |
||
15639 | bpr | 582 | !! add plural mark to scale number |
15638 | reyssat | 583 | !if ($slib_scale notsamecase 2) and ($slib_scaleNumbersType notsamecase $slib_scaleNumbersOrd) |
584 | slib_prefix = $slib_prefix$s |
||
585 | !endif |
||
586 | !endif |
||
587 | slib_empty=!charcnt $slib_combined |
||
588 | !if $slib_empty!=0 |
||
589 | slib_prefix=$slib_prefix$tiret |
||
590 | !endif |
||
591 | slib_combined=$slib_prefix$slib_combined |
||
592 | !endif |
||
593 | !if $[$slib_3digits] > 0 |
||
594 | slib_endOfNb=no |
||
595 | !endif |
||
596 | !next slib_scale |
||
597 | !endif |
||
598 | !endif (slib_number==0?) |
||
599 | |||
600 | !! if plural of ordinal, add s |
||
601 | !if ($slib_plural issamecase yes) and ($slib_type issamecase ord) |
||
602 | slib_dc=!char -1 of $slib_combined |
||
603 | !if $slib_dc notsamecase s |
||
604 | slib_combined=$slib_combined$s |
||
605 | !endif |
||
15626 | reyssat | 606 | !endif |
607 | slib_out=!append item $slib_combined to $slib_out |
||
15638 | reyssat | 608 | !next slib_number |
16172 | bpr | 609 | !reset slib_variant7 slib_variant8 slib_variant9 |
15638 | reyssat | 610 | !goto end |
15626 | reyssat | 611 | !endif |
14529 | czzmrn | 612 | :end |