Make split by gender faster
This commit is contained in:
parent
ea9e65a20b
commit
dad3597c1b
@ -177,7 +177,6 @@ class Handler
|
|||||||
DB.open(DB_URL) do |cursor|
|
DB.open(DB_URL) do |cursor|
|
||||||
cursor.query sql do |result_set|
|
cursor.query sql do |result_set|
|
||||||
result_set.each do
|
result_set.each do
|
||||||
puts "loop"
|
|
||||||
valor = result_set.read(Int32)
|
valor = result_set.read(Int32)
|
||||||
nombre = result_set.read(String)
|
nombre = result_set.read(String)
|
||||||
datos.push({valor, nombre})
|
datos.push({valor, nombre})
|
||||||
@ -203,8 +202,7 @@ class Handler
|
|||||||
|
|
||||||
if genero
|
if genero
|
||||||
DB.open(DB_URL) do |cursor|
|
DB.open(DB_URL) do |cursor|
|
||||||
filtered = Array(Tuple(Int32, String)).new
|
datos = datos.find do |item|
|
||||||
datos.map { |item|
|
|
||||||
# How feminine is this name?
|
# How feminine is this name?
|
||||||
# Yes this database is upper case
|
# Yes this database is upper case
|
||||||
nombre = item[1].upcase
|
nombre = item[1].upcase
|
||||||
@ -223,13 +221,13 @@ class Handler
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# El overlap en 0.5 es intencional!
|
# El overlap en 0.5 es intencional!
|
||||||
if feminidad >= 0.5 && genero == "f"
|
if (feminidad >= 0.5 && genero == "f") ||
|
||||||
filtered << item
|
(feminidad <= 0.5 && genero == "m")
|
||||||
elsif feminidad <= 0.5 && genero == "m"
|
true
|
||||||
filtered << item
|
else
|
||||||
|
false
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
datos = filtered
|
|
||||||
puts "Data split by gender"
|
puts "Data split by gender"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user