Searching for "word to number" almost always ends up giving results for converting numbers into word representations which seems a much simpler task than the inverse. There are some pretty trivial cases which could be handled with a basic lookup table ("first,1st,one" -> 1, etc.), but I'm looking for something which is better at tackling the general case. The app which I'm building involves taking user input which may or may not include a number and comparing that with a known result (which itself is stored as text), so for even more complexity it'd be preferable if it were able to deal with misspellings as well (e.g. frist, sceond) however this could probably be accomplished by passing the input through a spell checker first).
So far I've found http://j.mearie.org/post/7462182919/spelt-number-to-decimal which seems pretty cool because it seems to support some other languages (or not), but I would prefer something that was more portable and less obfuscated.
The most sophisticated one I've found is https://github.com/ged/linguistics/blob/master/lib/linguistics/en/numbers.rb and http://www.perlmonks.org/?node_id=506028 also seems promising.
Is there any more complete library out there? I'd like it to handle english and spanish numbers in different formats such as first, 1st, 1, one and even invalid ones like 1nd, and roman numerals like MMXII.