Make split by gender faster
This commit is contained in:
parent
94f5c3a09a
commit
00d4a7c550
@ -202,15 +202,14 @@ class Handler
|
||||
|
||||
if genero
|
||||
DB.open(DB_URL) do |cursor|
|
||||
datos = datos.find do |item|
|
||||
datos.reject! { |row|
|
||||
# How feminine is this name?
|
||||
# Yes this database is upper case
|
||||
nombre = item[1].to_s.upcase
|
||||
puts "Checking #{nombre}"
|
||||
puts "Checking #{row[0]?.to_s} #{row[1].to_s}"
|
||||
feminidad = 0
|
||||
sql = %(
|
||||
SELECT COALESCE((SELECT frecuencia FROM mujeres WHERE nombre='#{nombre}'), 0) AS mujeres,
|
||||
COALESCE((SELECT frecuencia FROM hombres WHERE nombre='#{nombre}'), 0) AS hombres
|
||||
SELECT COALESCE((SELECT frecuencia FROM mujeres WHERE nombre='#{row[1]?.to_s.upcase}'), 0) AS mujeres,
|
||||
COALESCE((SELECT frecuencia FROM hombres WHERE nombre='#{row[1]?.to_s.upcase}'), 0) AS hombres
|
||||
)
|
||||
cursor.query sql do |result|
|
||||
mujeres = result.read(Int32)
|
||||
@ -224,11 +223,11 @@ class Handler
|
||||
# El overlap en 0.5 es intencional!
|
||||
if (feminidad >= 0.5 && genero == "f") ||
|
||||
(feminidad <= 0.5 && genero == "m")
|
||||
true
|
||||
else
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
}
|
||||
puts "Data split by gender"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user