Make split by gender faster
This commit is contained in:
parent
19f25017f0
commit
ea9e65a20b
@ -204,10 +204,10 @@ class Handler
|
||||
if genero
|
||||
DB.open(DB_URL) do |cursor|
|
||||
filtered = Array(Tuple(Int32, String)).new
|
||||
datos.map { |nombre|
|
||||
datos.map { |item|
|
||||
# How feminine is this name?
|
||||
# Yes this database is upper case
|
||||
nombre = nombre.to_s.upcase
|
||||
nombre = item[1].upcase
|
||||
feminidad = 0
|
||||
sql = %(
|
||||
SELECT COALESCE((SELECT frecuencia FROM mujeres WHERE nombre='#{nombre}'), 0) AS mujeres,
|
||||
@ -224,9 +224,9 @@ class Handler
|
||||
end
|
||||
# El overlap en 0.5 es intencional!
|
||||
if feminidad >= 0.5 && genero == "f"
|
||||
filtered << nombre
|
||||
filtered << item
|
||||
elsif feminidad <= 0.5 && genero == "m"
|
||||
filtered << nombre
|
||||
filtered << item
|
||||
end
|
||||
}
|
||||
datos = filtered
|
||||
|
Loading…
Reference in New Issue
Block a user