#ABNF 1.0 UTF-8; language es-MX; mode voice; tag-format ; /* * Example 1 (PI): * Input: three point one four one five nine two six * Output: 3.1415926 * * Example 2 (Earth's equatorial circumference in miles) * Input: twenty four thousand nine hundred and two point four * Ouput: 24902.4 * * Example 3 (A prime) * Input: one hundred seventy nine million four hundred twenty four thousand six hundred and seventy three * Outpu: 179424673 */ root $quantity; $quantity = $NatNums { $ = $$.toString(); } (/0.9/ $quantifiers | /0.1/ $NULL); $one = (UN | UNO) {$=1} ; $twotonine = DOS {$=2} | TRES {$=3} | CUATRO {$=4} | CINCO {$=5} | SEIS {$=6} | SIETE {$=7} | OCHO {$=8} | NUEVE {$=9} ; $base = (/0.1/ $one | /0.8/ $twotonine) {$=$$}; $teen = DIEZ {$=10} | ONCE {$=11} | DOCE {$=12} | TRECE {$=13} | CATORCE {$=14} | QUINCE {$=15} | DIECISEIS {$=16} | DIECISIETE {$=17} | DIECIOCHO {$=18} | DIECINUEVE {$=19}; $twenty = VEINTE {$=20} | (VEINTIUNO | VEINTIUN) {$=21} | VEINTIDOS {$=22} | VEINTITRES {$=23} | VEINTICUATRO {$=24} | VEINTICINCO {$=25} | VEINTISEIS {$=26} | VEINTISIETE {$=27} | VEINTIOCHO {$=28} | VEINTINUEVE {$=29}; $thirty = TREINTA {$=30} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $forty = CUARENTA {$=40} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $fifty = CINCUENTA {$=50} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $sixty = SESENTA {$=60} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $seventy = SETENTA {$=70} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $eighty = OCHENTA {$=80} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $ninety = NOVENTA {$=90} (/0.9/ Y $base {$+=$$} | /0.1/ $NULL); $tens = ($teen | $twenty | $thirty | $forty | $fifty | $sixty | $seventy | $eighty | $ninety) {$=$$}; $zero = (CERO) {$=0}; $ohbase = (/0.1/ $zero| /0.9/ $base) {$=$$}; $and = Y; $hundred = (CIENTO | CIEN) {$=100} | DOSCIENTOS {$=200} | TRESCIENTOS {$=300} | CUATROCIENTOS {$=400} | QUINIENTOS {$=500} | SEISCIENTOS {$=600} | SETECIENTOS {$=700} | OCHOCIENTOS {$=800} | NOVECIENTOS {$=900}; $hundreds = $hundred {$=$$} (/0.9/ ($tens | $base) {$+=$$}|$NULL); $thousand = (/0.01/ MIL {$=1000} |/0.8/ $twotonine MIL {$=$$*1000}| /0.15/ $tens MIL {$=$$*1000}| /0.04/ $hundreds MIL {$=$$*1000}); $thousands = /0.95/ $thousand {$=$$} (/0.9/ ( /0.9/ $hundreds | /0.1/ ($tens| $base) ) {$+=$$} | $NULL ); $million = (UN MILLÓN {$=1000000}) | ( $twotonine {$=$$} | $tens {$=$$} | $hundreds {$=$$}) MILLONES {$*=1000000}; $millions = $million {$=$$} [($thousands | $hundreds | ($tens|$base)) {$+=$$}]; $NatNums = ($millions | $thousands | $hundreds | $tens | $base) {$=$$}; $quantifiers = $mass_units | $volume_units | $length_units | $monetary_units | $time_units | $math_units | $calendar_units ; $mass_units = (/.999/ GRAMOS | /.001/ GRAMO) | (/.999/ KILOGRAMOS | /.001/ KILOGRAM) | (/.999/ TONELADAS | /.001/ TONELADA) | (/.999/ LIBRAS | /.001/ LIBRA) | (/.999/ ACRES | /.001/ ACRE) | (/.99/ ONZAS | /.01/ ONZA) ; $volume_units = (/.999/ CUARTOS DE GALÓN | /.001/ CUARTO DE GALÓN) (/.999/ PINTAS | /.001/ PINTA) | (/.999/ LITROS | /.001/ LITRO) | (/.999/ BARRILES | /.001/ BARRIL) | (/.999/ GALÓN | /.001/ GALONES) ; $monetary_units = LIRA | YEN | (/.999/ DÓLARES | /.001/ DÓLAR) | (/.99/ CENTAVOS | /.01/ CENTAVO) | (/.999/ PESOS | /.001/ PESO) | (/.999/ FRANCOS | /.001/ FRANCO) ; $time_units = (/.99/ SEGUNDOS | /.01/ SEGUNDO) | (/.99/ MINUTOS | /.01/ MINUTO) | (/.99/ HORAS | /.01/ HORA) ; $calendar_units = (/.999/ DÍAS | /.001/ DÍA) | (/.999/ SEMANAS | /.001/ SEMANA) | (/.999/ MESES | /.001/ MES) | (/.999/ AÑOS | /.001/ AÑO) ; $length_units = (/.999/ METROS | /.001/ METRO) | (/.99/ DECÍMETROS | /.01/ DECÍMETRO) | (/.99/ CENTÍMETROS | /.01/ CENTÍMETRO) | (/.999/ MILÍMETROS | /.001/ MILÍMETRO) | (/.999/ PULGADAS | /.001/ PULGADA) | (/.999/ PIES | /.001/ PIE) | (/.999/ YARDAS | /.001/ YARDA) | (/.999/ KILÓMETROS | /.001/ KILÓMETRO) | (/.999/ MILLAS | /.001/ MILLA) ; $math_units = (/.999/ GRADOS | /.001/ GRADO) ;