// A customer search that finds "Catherine" when someone types "Kathryn", and a duplicate check.
//
//   quillo run phonetics.qwe      then open http://localhost:8080/customers?name=Kathryn

use "phonetics.qwer"

let customers = ["Catherine Smith", "Katherine", "Kathryn", "Karen", "Smyth", "Schmidt", "Mayr", "Meier", "Robert", "Rupert"]

route GET /customers ? { name: str } = { name, sounds_like: phonetic_find(name, customers)? }

route GET /codes ? { name: str = "Robert" } = {
    soundex: phonetic_code(name, "soundex")?,
    metaphone: phonetic_code(name, "metaphone")?,
    double: phonetic_double_metaphone(name)?,
    nysiis: phonetic_code(name, "nysiis")?,
    cologne: phonetic_code(name, "cologne")?,
}

route GET /same = {
    robert_rupert: phonetic_match("Robert", "Rupert", "soundex")?,
    smith_smyth: phonetic_match("Smith", "Smyth", "double_metaphone")?,
    meier_mayr: phonetic_match("Meier", "Mayr", "cologne")?,
    smith_jones: phonetic_match("Smith", "Jones", "double_metaphone")?,
}
