compromise
Version:
natural language processing in the browser
133 lines (127 loc) • 2.09 kB
JavaScript
const cardinal = {
ones: {
// 'a': 1,
'zero': 0,
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
'six': 6,
'seven': 7,
'eight': 8,
'nine': 9
},
teens: {
'ten': 10,
'eleven': 11,
'twelve': 12,
'thirteen': 13,
'fourteen': 14,
'fifteen': 15,
'sixteen': 16,
'seventeen': 17,
'eighteen': 18,
'nineteen': 19
},
tens: {
'twenty': 20,
'thirty': 30,
'forty': 40,
'fifty': 50,
'sixty': 60,
'seventy': 70,
'eighty': 80,
'ninety': 90
},
multiples: {
'hundred': 1e2,
'thousand': 1e3,
'grand': 1e3,
'million': 1e6,
'billion': 1e9,
'trillion': 1e12,
'quadrillion': 1e15,
'quintillion': 1e18,
'sextillion': 1e21,
'septillion': 1e24
}
};
const ordinal = {
ones: {
'zeroth': 0,
'first': 1,
'second': 2,
'third': 3,
'fourth': 4,
'fifth': 5,
'sixth': 6,
'seventh': 7,
'eighth': 8,
'ninth': 9
},
teens: {
'tenth': 10,
'eleventh': 11,
'twelfth': 12,
'thirteenth': 13,
'fourteenth': 14,
'fifteenth': 15,
'sixteenth': 16,
'seventeenth': 17,
'eighteenth': 18,
'nineteenth': 19
},
tens: {
'twentieth': 20,
'thirtieth': 30,
'fourtieth': 40,
'fiftieth': 50,
'sixtieth': 60,
'seventieth': 70,
'eightieth': 80,
'ninetieth': 90
},
multiples: {
'hundredth': 1e2,
'thousandth': 1e3,
'millionth': 1e6,
'billionth': 1e9,
'trillionth': 1e12,
'quadrillionth': 1e15,
'quintillionth': 1e18,
'sextillionth': 1e21,
'septillionth': 1e24
}
};
//used for the units
const prefixes = {
'yotta': 1,
'zetta': 1,
'exa': 1,
'peta': 1,
'tera': 1,
'giga': 1,
'mega': 1,
'kilo': 1,
'hecto': 1,
'deka': 1,
'deci': 1,
'centi': 1,
'milli': 1,
'micro': 1,
'nano': 1,
'pico': 1,
'femto': 1,
'atto': 1,
'zepto': 1,
'yocto': 1,
'square': 1,
'cubic': 1,
'quartic': 1
};
module.exports = {
cardinal: cardinal,
ordinal: ordinal,
prefixes: prefixes
};