class NumberParser::EnglishProvider

Defined in:

providers/english_provider.cr

Constant Summary

ALL_FRACTIONS = (ONLY_PLURAL_FRACTIONS.merge(SINGLE_ORDINAL_FRACTIONALS)).merge(DIRECT_ORDINAL_FRACTIONALS)
ALL_ORDINALS = (ORDINALS.merge(SINGLE_ORDINAL_FRACTIONALS)).merge(DIRECT_ORDINAL_FRACTIONALS)
ALL_ORDINALS_REGEX = ALL_ORDINALS.keys.reduce do |a, b| (a + "|") + b end

REGEXP.UNION here breaks insertion into negative Lookbehind

BIG_PREFIXES = {"hundred" => 100, "thousand" => 1000, "million" => 1000000, "billion" => 1000000000, "trillion" => 1000000000000_i64}
DIRECT_NUMS = {"eleven" => "11", "twelve" => "12", "thirteen" => "13", "fourteen" => "14", "fifteen" => "15", "sixteen" => "16", "seventeen" => "17", "eighteen" => "18", "nineteen" => "19", "ninteen" => "19", "zero" => "0", "ten" => "10"}
DIRECT_ORDINAL_FRACTIONALS = {"tenth" => "10", "eleventh" => "11", "twelfth" => "12", "thirteenth" => "13", "fourteenth" => "14", "fifteenth" => "15", "sixteenth" => "16", "seventeenth" => "17", "eighteenth" => "18", "nineteenth" => "19", "twentieth" => "20", "thirtieth" => "30", "fourtieth" => "40", "fiftieth" => "50", "sixtieth" => "60", "seventieth" => "70", "eightieth" => "80", "ninetieth" => "90"}
DIRECT_SINGLE_NUMS = DIRECT_NUMS.merge(SINGLE_NUMS)
FRACTIONS = {"half" => 2, "halves" => 2, "quarter" => 4, "quarters" => 4}
ONLY_PLURAL_FRACTIONS = FRACTIONS.merge((SINGLE_ORDINAL_FRACTIONALS.merge(DIRECT_ORDINAL_FRACTIONALS)).reduce({} of String => Int32 | String) do |h, __arg0| k = __arg0[0] v = __arg0[1] h[k + "s"] = v h end)
ORDINAL_SINGLE = ORDINALS.merge(SINGLE_ORDINAL_FRACTIONALS)
ORDINALS = {"first" => 1, "second" => 2}
PRONOUNS = ["i", "you", "he", "she", "we", "it", "you", "they", "to", "the"].reduce do |a, b| (a + "|") + b end
SINGLE_NUMS = {"one" => 1, "two" => 2, "three" => 3, "four" => 4, "five" => 5, "six" => 6, "seven" => 7, "eight" => 8, "nine" => 9}
SINGLE_ORDINAL_FRACTIONALS = {"third" => 3, "fourth" => 4, "fifth" => 5, "sixth" => 6, "seventh" => 7, "eighth" => 8, "ninth" => 9}
TEN_PREFIXES = {"twenty" => 20, "thirty" => 30, "forty" => 40, "fourty" => 40, "fifty" => 50, "sixty" => 60, "seventy" => 70, "eighty" => 80, "ninety" => 90}

Instance Method Summary

Instance methods inherited from class NumberParser::GenericProvider

parse(str, ignore = [] of String, bias = :noe) parse

Instance Method Detail

def numerize_big_prefixes(string, ignore, bias) #

hundreds, thousands, millions, etc.


[View source]
def numerize_fractions(string, ignore, bias) #

[View source]
def numerize_numerals(string, ignore, bias) #

[View source]
def numerize_ordinals(string, ignore, bias) #

[View source]
def postprocess(string, ignore) #

[View source]
def preprocess(string, ignore) #

[View source]