Written numbers to integer form

View: New views
2 Messages — Rating Filter:   Alert me  

Written numbers to integer form

by jnance :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Does anyone know how I'd go about changing written numbers to their integer forms? For example, change "seventeen" to "17."

Thanks,

James

Re: Written numbers to integer form

by Landei :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ICU http://www-306.ibm.com/software/globalization/icu/index.jsp can convert 17 to "seventeen", but I don't know if they have implemented the reverse process, too.

If you can't find something predefined, you could write a parser (using SableCC, ANTLR etc). But to help you to find the best way, I would need some more background: How big are the numbers? Are they always formatted the same way, or not ("hundred" vs "one hundred" etc). Do you have only numbers or are they embedded in other text?

Landei
LightInTheBox - Buy quality products at wholesale price!