finnfiddle / words-to-numbers

JS library to convert textual words to numbers with optional fuzzy text matching
MIT License
248 stars 57 forks source link

'twenty-one thousand five hundred seventy-six' => 1596 #26

Open anton-bot opened 6 years ago

anton-bot commented 6 years ago

wrong conversion as in title

Wol commented 4 years ago

Similar issue with "nine hundred and seventy four thousand" is being turned somehow into "970" and "4000" then being added to return "4970"

It seems to be treating: "nine hundred and seventy four thousand" as "four thousand nine hundred and seventy"

Even more confusingly, running the function on "four thousand nine hundred and seventy" returns undefined.

guomo commented 4 years ago

@Wol I wouldn't call that example a bug. Linguistically the and is in the wrong place if you meant to spell out 974,000.

Wol commented 4 years ago

Maybe everyone I know says numbers wrong then! What do you call 974000?

For the example 987654 I'd say "nine hundred and eighty seven thousand six hundred and fifty four".

"nine hundred and eighty seven" is the amount of thousands and then "six hundred and fifty four".

guomo commented 4 years ago

In America we would say nine hundred seventy four thousand. Following the Chicago manual of Style format. The only time we use the and is when writing cents on a bank check. Such as nine hundred seventy four thousand and 55 cents.

vnaganathan-conga commented 3 years ago

@Wol, with impliedHundreds set to false, i am getting the below translated wrong:

thirty five thousand is coming back as 5030 forty three thousand as 3040

This is pretty standard expression all over the world. What do you think? Will file a new issue, as this seems fundamental