Maybe create some logic to do something like this for each word:
start with 0
one - add 1
hundred - multiply by 100
twenty - add 20
three - add 3
I guess you'll have to put aside values after encountering a multiply-by step. Consider the 34108 case, for one and then hundred you'd have to keep 1 separate from the 34,000 and total them when you're done.