Does anyone know of a program that will take a number in letter format, for example "onethousandtwohundredsixteen" and translate it into "1216".
I have a text file of the numbers 1-1000 and it needs to read each number in letter format and translate it into text. Any help would be greatly appreciated.
EDIT: I already have the numbers translated in a text file side by side, the bot just has to use OCR to check for the numbers, when it see's them type back (also it's not an image).
[willing to pay] Looking for a program that will translate letters to #'s [pre-defined]
-
- Posts: 2
- Joined: 08 May 2021, 17:57
Re: [willing to pay] Looking for a program that will translate letters to #'s [pre-defined]
This is an idea.
Code: Select all
MsgBox, % stringToNumber("onethousandtwohundredtwentyfive")
MsgBox, % stringToNumber("onethousandtwohundredsixteen")
MsgBox, % stringToNumber("ninehundredone")
MsgBox, % stringToNumber("nineteenthousandfortytwo")
MsgBox, % stringToNumber("nineteenthousandsixhundredfortytwo")
MsgBox, % stringToNumber("twelve")
MsgBox, % stringToNumber("twelvehundred")
MsgBox, % stringToNumber("onethousandtwohundred")
MsgBox, % stringToNumber("twohundredtwenty")
MsgBox, % stringToNumber("one")
stringToNumber(str := "") {
Static tens := {twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70
, eighty: 80, ninety: 90}
Static addee := {one: 1, two: 2, three: 3, four: 4, five: 5, six: 6
, seven: 7, eight: 8, nine: 9, ten: 10, eleven: 11, twelve: 12
, thirteen: 13, fourteen: 14, fifteen: 15, sixteen: 16, seventeen: 17, eighteen: 18
, nineteen: 19}
If (str = "")
Return 0
For k, v in [["thousand", 1000], ["hundred", 100]]
If RegExMatch(str, "(.+)" v.1 "(.*)", part)
Return v.2 * stringToNumber(part1) + stringToNumber(part2)
If addee.HasKey(str)
Return addee[str]
For k, v in tens
If RegExMatch(str, k "\K.*", ones)
Return v + stringToNumber(ones)
}
Re: [willing to pay] Looking for a program that will translate letters to #'s [pre-defined]
Don't know where the OP went, but looks like a valid solution to me. Maybe a little neater for readability... Still, another good one mikeyww.
mikeyww wrote: ↑08 May 2021, 19:35This is an idea.
Code: Select all
MsgBox, % stringToNumber("onethousandtwohundredtwentyfive") MsgBox, % stringToNumber("onethousandtwohundredsixteen") MsgBox, % stringToNumber("ninehundredone") MsgBox, % stringToNumber("nineteenthousandfortytwo") MsgBox, % stringToNumber("nineteenthousandsixhundredfortytwo") MsgBox, % stringToNumber("twelve") MsgBox, % stringToNumber("twelvehundred") MsgBox, % stringToNumber("onethousandtwohundred") MsgBox, % stringToNumber("twohundredtwenty") MsgBox, % stringToNumber("one") stringToNumber(str := "") { Static tens := {twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70 , eighty: 80, ninety: 90} Static addee := {one: 1, two: 2, three: 3, four: 4, five: 5, six: 6 , seven: 7, eight: 8, nine: 9, ten: 10, eleven: 11, twelve: 12 , thirteen: 13, fourteen: 14, fifteen: 15, sixteen: 16, seventeen: 17, eighteen: 18 , nineteen: 19} If (str = "") Return 0 For k, v in [["thousand", 1000], ["hundred", 100]] If RegExMatch(str, "(.+)" v.1 "(.*)", part) Return v.2 * stringToNumber(part1) + stringToNumber(part2) If addee.HasKey(str) Return addee[str] For k, v in tens If RegExMatch(str, k "\K.*", ones) Return v + stringToNumber(ones) }
Who is online
Users browsing this forum: Google [Bot] and 329 guests