-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected number parsing #29
Comments
How unexpected! I'm not sure what's going on there. I can take a look at some point, but will accept a PR too if you want to have a go. I suppose any solution would need a clearly defined set of expected behaviours and exhibited problem behaviours though rather than just solving a subset of simple cases. I'm not sure what may be involved in supporting this type of input though. It looks like for your single specific example ruby's inbuilt |
Hey @markburns I came across another one:
Again my use case might be a bit different than others, I'm basically trying to parse a 4-8 digit pin where I receive the "said" value from speech recognition (so you could argue the speech recognition should be better and I agree 😞 ) I am seeing a few problems here:
I will try to avoid codes with leading 0 and also try to wrap It's almost as if for number parsing we need some kind of mode, e.g. this would be a "PIN mode" where we return a string formatted number as it can have leading 0 and we know there shouldn't be any decimals either. |
Thanks for the extra info. I think one issue you're having here with leading zeros is considering these objects as "numbers". It sounds like they're not but share a lot in common with numbers. People have similar issues if they try to process credit card numbers as numeric values too. I think that aspect of your problem is certainly outside the scope of this project as the way the words are parsed does require treating them mathematically as numbers. It does sound like there's value in providing a layer perhaps on top of this gem that could solve some of the common problems people encounter when they work with voice input. I think it could also make sense to extract some of the work @dimidd added related to parsing pairs of numbers like 1920 (nineteen twenty). Then that would keep the core of this gem simpler and allow for adding more of the fuzzy stuff in an outer layer. Perhaps the outputs of this proposed gem would provide a value object class for things like credit card numbers and pins. They're a bit like numbers and a bit like strings and you'd probably be the best person to determine what the API should look like on these value objects. I'd be happy to brainstorm a little further sometime if you're interested |
Hi!
First of all thanks for this cool gem. I needed exactly this, something that can parse a numeric code - how a human would say it - to a number.
I did notice some quirks of the number parsing in my application:
Maybe it's not designed to also recognize numeric values input, but as I'm using it in combination with speech recognition that's sometimes what I get.
For now I'm simply checking this myself and not pass these values into
NumbersInWords
:The text was updated successfully, but these errors were encountered: