2009-10-20 10:52:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2006-12-07 13:41:40 +00:00
|
|
|
##############################################################################
|
2009-10-14 12:32:15 +00:00
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
2008-06-16 11:00:21 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 12:32:15 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 18:27:16 +00:00
|
|
|
# This program 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
|
2009-10-14 12:32:15 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2009-10-14 12:32:15 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
unites = {
|
2008-07-22 14:24:36 +00:00
|
|
|
0: '', 1:'un', 2:'deux', 3:'trois', 4:'quatre', 5:'cinq', 6:'six', 7:'sept', 8:'huit', 9:'neuf',
|
|
|
|
10:'dix', 11:'onze', 12:'douze', 13:'treize', 14:'quatorze', 15:'quinze', 16:'seize',
|
|
|
|
21:'vingt et un', 31:'trente et un', 41:'quarante et un', 51:'cinquante et un', 61:'soixante et un',
|
|
|
|
71:'septante et un', 91:'nonante et un', 80:'quatre-vingts'
|
2006-12-07 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dizaine = {
|
2008-07-22 14:24:36 +00:00
|
|
|
1: 'dix', 2:'vingt', 3:'trente',4:'quarante', 5:'cinquante', 6:'soixante', 7:'septante', 8:'quatre-vingt', 9:'nonante'
|
2006-12-07 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
centaine = {
|
2008-07-22 14:24:36 +00:00
|
|
|
0:'', 1: 'cent', 2:'deux cent', 3:'trois cent',4:'quatre cent', 5:'cinq cent', 6:'six cent', 7:'sept cent', 8:'huit cent', 9:'neuf cent'
|
2006-12-07 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mille = {
|
2008-07-22 14:24:36 +00:00
|
|
|
0:'', 1:'mille'
|
2006-12-07 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def _100_to_text(chiffre):
|
2008-07-22 14:24:36 +00:00
|
|
|
if chiffre in unites:
|
|
|
|
return unites[chiffre]
|
|
|
|
else:
|
|
|
|
if chiffre%10>0:
|
|
|
|
return dizaine[chiffre / 10]+'-'+unites[chiffre % 10]
|
|
|
|
else:
|
|
|
|
return dizaine[chiffre / 10]
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
def _1000_to_text(chiffre):
|
2008-07-22 14:24:36 +00:00
|
|
|
d = _100_to_text(chiffre % 100)
|
|
|
|
d2 = chiffre/100
|
|
|
|
if d2>0 and d:
|
|
|
|
return centaine[d2]+' '+d
|
2012-12-14 12:38:03 +00:00
|
|
|
elif d2>1 and not d:
|
2008-07-22 14:24:36 +00:00
|
|
|
return centaine[d2]+'s'
|
|
|
|
else:
|
|
|
|
return centaine[d2] or d
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
def _10000_to_text(chiffre):
|
2008-07-22 14:24:36 +00:00
|
|
|
if chiffre==0:
|
|
|
|
return 'zero'
|
|
|
|
part1 = _1000_to_text(chiffre % 1000)
|
|
|
|
part2 = mille.get(chiffre / 1000, _1000_to_text(chiffre / 1000)+' mille')
|
|
|
|
if part2 and part1:
|
|
|
|
part1 = ' '+part1
|
|
|
|
return part2+part1
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
def int_to_text(i):
|
2008-07-22 14:24:36 +00:00
|
|
|
return _10000_to_text(i)
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
if __name__=='__main__':
|
2008-07-22 14:24:36 +00:00
|
|
|
for i in range(1,999999,139):
|
|
|
|
print int_to_text(i)
|
2008-07-23 15:01:27 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|