Added missing file, refactored normalize_name out

This commit is contained in:
Roberto Alsina 2023-06-03 21:18:50 -03:00
parent cafe5fdce5
commit a62d814aaf
2 changed files with 15 additions and 4 deletions

View File

@ -27,6 +27,14 @@ class Handler
nombres = [] of String nombres = [] of String
def normalize_name(s)
# Remove diacritics, turn lowercase
normalized = s.unicode_normalize(:nfkd).chars
normalized.reject! { |c|
!c.ascii_letter?
}.join("").downcase
end
def run(request : HTTP::Request) def run(request : HTTP::Request)
unless (body = request.body).nil? unless (body = request.body).nil?
query = JSON.parse(body) query = JSON.parse(body)
@ -40,10 +48,7 @@ class Handler
# Remove all diacritics and whatnot # Remove all diacritics and whatnot
nombres = nombres.map { |n| nombres = nombres.map { |n|
normalized = n.unicode_normalize(:nfkd).chars normalize_name n
normalized.reject! { |c|
!c.ascii_letter?
}.join("").downcase
} }
puts "Processing #{nombres}" puts "Processing #{nombres}"

6
c-historico/shard.yml Normal file
View File

@ -0,0 +1,6 @@
name: historico
version: 0.1.0
dependencies:
ishi:
github: toddsundsted/ishi