Re: word to digit module

2004-12-22 Thread John Machin
Stephen Thorne wrote: > Thankyou for you feedback, both of you. No wuckas. > http://thorne.id.au/users/stephen/scripts/eng2num.py contains your suggestions. This points to some javascript which prints "No." -- http://mail.python.org/mailman/listinfo/python-list

Re: word to digit module

2004-12-22 Thread Stephen Thorne
On Wed, 22 Dec 2004 11:41:26 -0800, Scott David Daniels <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > Stephen Thorne wrote: > > .def toNumber2(s): > > . items = s.replace(',', '').split() > > . numbers = [translation.get(item.strip(), -1) for item in items if > > item.strip()] > > . sta

Re: word to digit module

2004-12-22 Thread M.E.Farmer
Cool script just one little thing, toNumber('One thousand') bites the dust. Guess you should add another test, and s.lower() ;) Stephen Thorne wrote: {code snip} > def toNumber(s): + s = s.lower() > items = s.replace(',', '').split() > numbers = [translation.get(item.strip(), -1) for i

Re: word to digit module

2004-12-22 Thread Scott David Daniels
John Machin wrote: Stephen Thorne wrote: .def toNumber2(s): . items = s.replace(',', '').split() . numbers = [translation.get(item.strip(), -1) for item in items if item.strip()] . stack = [0] . for num in numbers: . if num == -1: . raise ValueError("Invalid string '%s'" % (s,)

Re: word to digit module

2004-12-22 Thread John Machin
Stephen Thorne wrote: > On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva > <[EMAIL PROTECTED]> wrote: > > Is there any module available that converts word like 'one', 'two', > > 'three' to corresponding digits 1, 2, 3?? > > This seemed like an interesting problem! So I decided to solve it. > >

Re: word to digit module

2004-12-22 Thread Fredrik Lundh
Stephen Thorne wrote: >> Is there any module available that converts word like 'one', 'two', >> 'three' to corresponding digits 1, 2, 3?? > > This seemed like an interesting problem! So I decided to solve it. > for i in range(4): that's a slightly unusual definition of "digit", but it's a ni

Re: word to digit module

2004-12-21 Thread Stephen Thorne
On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva <[EMAIL PROTECTED]> wrote: > Is there any module available that converts word like 'one', 'two', > 'three' to corresponding digits 1, 2, 3?? This seemed like an interesting problem! So I decided to solve it. I started with http://www.python.o

Re: word to digit module

2004-12-21 Thread M.E.Farmer
Gurpreet Sachdeva wrote: > Is there any module available that converts word like 'one', 'two', > 'three' to corresponding digits 1, 2, 3?? > > Thanks and Regards, > GSS Hello, This is not a module but is a way to do it Hope this helps you. # looku

Re: word to digit module

2004-12-21 Thread Binu K S
Oops! That just does the opposite of what you want. I guess you can tinker it a bit to do the reverse conversion unless someone suggests a better module. On Wed, 22 Dec 2004 10:41:46 +0530, Binu K S <[EMAIL PROTECTED]> wrote: > You'll find a script here: > http://www.python.org/pycon/dc2004/papers

Re: word to digit module

2004-12-21 Thread Binu K S
You'll find a script here: http://www.python.org/pycon/dc2004/papers/42/ex1-C/ Found it in the miscellany section at http://www.vex.net/parnassus/ (num2eng) On Wed, 22 Dec 2004 10:27:16 +0530, Gurpreet Sachdeva <[EMAIL PROTECTED]> wrote: > Is there any module available that converts word like 'one

word to digit module

2004-12-21 Thread Gurpreet Sachdeva
Is there any module available that converts word like 'one', 'two', 'three' to corresponding digits 1, 2, 3?? Thanks and Regards, GSS -- http://mail.python.org/mailman/listinfo/python-list