-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
How to preserve decimal point and zeros when decimal values are all 0? #2
Comments
I'm not sure if this is a good/safe solution, but I ended up modifying the output with the following:
|
Can you provide the phrase, and the expected numeral output? Otherwise, if you're talking about formatting the output, it's outside the scope of this project. |
I am working with speech recognition api and the phrases passed to WtoN can be things like:
I think my solution posted above works, ie:
There are other phrases, however, that I am trying to make successful in WtoN (jsFiddle test here): Example 01 - Resolved
Example 02 - Unresolved The following phrases do not currently convert as desired:
So I think the issues can be described as: "WtoN can not currently handle spaces between words and numbers" "WtoN can not currently handle spaces between numbers as words and numbers as words" My first instinct is to remove spaces with:
But this will cause errors in phrases like: "one hundred" Hmmm... |
Here is another jsFiddle that resolves the scenarios above (it's not pretty, but it works i think!). My approach was to modify the original phrase before passing it to WtoN. This is done in the function Will need to test with more phrases to make sure it works as intended. |
hm.. I'm not sure WtoN is meant to handle words spoken out digit by digit. If you look under I might have some time next few weeks to add some non-whole numbers like "three hundred point one two" to "300.12" |
Thank you for your reply, I think my modified version of WtoN is doing all that is required (its just not as nicely coded as yours hehe). I realised the "three hundred point one two" scenario is not really important as I can enforce the convention of saying "three hundred dot one two" which Google will translate to something that my modified version of WtoN can convert. Thanks! |
Hello,
How can I preserve the decimal point and zeros in case
b
?jsFiddle for testing here.
The text was updated successfully, but these errors were encountered: