def self.numerize(string)
string = string.dup
string.gsub!(%r +|([^\d])-([^\d])/, '\1 \2')
string.gsub!(%ra half/, 'haAlf')
DIRECT_NUMS.each do |dn|
string.gsub!(%r#{dn[0]}/, '<num>' + dn[1])
end
ORDINALS.each do |on|
string.gsub!(%r#{on[0]}/, '<num>' + on[1] + on[0][-2, 2])
end
TEN_PREFIXES.each do |tp|
string.gsub!(%r(?:#{tp[0]}) *<num>(\d(?=[^\d]|$))*/) { '<num>' + (tp[1] + $1.to_i).to_s }
end
TEN_PREFIXES.each do |tp|
string.gsub!(%r#{tp[0]}/) { '<num>' + tp[1].to_s }
end
BIG_PREFIXES.each do |bp|
string.gsub!(%r(?:<num>)?(\d*) *#{bp[0]}/) { '<num>' + (bp[1] * $1.to_i).to_s}
andition(string)
end
string.gsub!(%r(\d+)(?: | and |-)*haAlf/) { ($1.to_f + 0.5).to_s }
string.gsub(%r<num>/, '')
end