Closed jacobp100 closed 9 years ago
good point. will fix
This works with numbers divisible by 10 like: 20, 30, 320. The exceptions if the last number is ten.
I'm new to this project, can you give me some direction where this is failing at? Maybe some example code?
/cc @jacobp100 @spencermountain
hi blaine, welcome aboard. the method is at ./src/parents/value/to_number.js
it's more a matter of knowing when it's appropriate to sum the values together. i think right now i think it refuses to sum two numbers in the 'tens' (0-20), but welcome any alternative interpretation. tests at the bottom of the file
This class already works like you would expect:
to_number("sixteen one")
null
to_number("twenty five")
25
hey guys, just took this one for a dive, here are the tests it now passes.
the big conceptual trick is that (ones/teens) and (twenties/nineties) can only repeat if there is a multiplier in between them. eg. 'five six' is bad, but 'five hundred six' is good. it totally rules now. will push it in next release, later this week. thanks for the help.
["twenty two thousand five hundred",22500],
["two thousand five hundred and sixty",2560],
["a hundred and two",102],
["a hundred",100],
["seven",7],
["seven grand",7000],
["half a million",500000],
["half-million",500000],
["quarter-million",250000],
["a quarter million",250000],
["a quarter-grand",250],
["four and a half",6],
["ten and a half million",15000000],
["104",104],
["13 thousand",13000],
["17,983",17983],
["12:32",null],
["123-1231",null],
["seven eleven",null],
["ten-four",null],
["one seven", null],
["one ten", null],
["one twelve", null],
["one thirty", null],
["nine fifty", null],
["five six", null],
["nine seventy", null],
["nine hundred", 900],
["nine two hundred", null],
["twenty one hundred", 2100],
["ten one", null],
["twelve one", null],
["twenty one", 21],
["seventy two", 72],
["seventy five two", null],
["two hundred two", 202],
["two hundred three hundred", null],
["one thousand one", 1001],
["minus five hundred", -500],
["minus fifteen", -15],
@spencermountain should we return a float?
["four and a half",6],
v. good point
this is fixed in v0.2.3. thanks!
Twenty five should register as one number, Sixteen one should not.