Last active
March 19, 2020 12:44
-
-
Save regilero/e0066e66e2c505f7a0edddf8bf104bb7 to your computer and use it in GitHub Desktop.
hoity-toity french names generator in pure postgreSQL single query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM ( | |
SELECT | |
( | |
SELECT concat('Marie-', string_agg(x,'-')) as name_first_female | |
FROM ( | |
select start_arr[ 1 + ( (random() * 100)::int) % 32 ] | |
FROM | |
( | |
select '{Claude,Thérèse,Géraldine,Sylvie,Sophie,Solange,Vivianne,Cunégonde,Albertine,Charlotte,Caroline,Célestine,Bérangère,Sylvianne,Alphonsine,Claire,Françoise,Chantal,Geneviève,Christine,Louise,Adeline,Céleste,Angélique,Clothilde,Jeanne,Pierre,Valentine,Paule,Noëlle,Lise,Cécile}'::text[] as start_arr | |
) syllarr, | |
-- need 3 syllabes, and force generator interpretation with the '*0' (else 3 same syllabes) | |
generate_series(1, 1 + ( ( (generator::int % 3) * (random() * 0.5))::int % 3)) | |
) AS con_name_female(x) | |
), | |
( | |
SELECT concat('Jean-', string_agg(y,'-')) as name_first_male | |
FROM ( | |
select start_arr[ 1 + ( (random() * 100)::int) % 33 ] | |
FROM | |
( | |
select '{François,Pierre,Michel,Sylvain,Sébastien,Eudes,Raymond,Claude,Régis,Charles,Maxence,Célestin,Baptiste,Grégoire,Hubert,Antonin,Stanislas,Gérald,Albert,Marie,Guy,Yves,Louis,Gabriel,Jérémie,Bartholomé,Mathieu,Vincent,Nicolas,Joachim,Olivier,Daniel,Philippe}'::text[] as start_arr | |
) syllarr, | |
-- need 3 syllabes, and force generator interpretation with the '*0' (else 3 same syllabes) | |
generate_series(1, 1 + ( ( (generator::int % 3) * (random() * 0.5))::int % 3)) | |
) AS con_name_male(y) | |
), | |
( | |
SELECT concat(last_name_part1a,last_char) as last_name_part1 | |
FROM ( | |
SELECT initcap(concat(string_agg(z1,''))) as last_name_part1a | |
FROM ( | |
select last_arr[ 1 + ( (random() * 100 + (generator * 0))::int) %35 ] | |
FROM | |
( | |
select '{cu,char,bar,rau,reau,ban,beau,che,choi,moi,dur,dup,bou,gre,gru,choi,chau,col,ast,ara,ame,aud,souch,chon,bon,cheau,tallo,lio,chau,ron,rency,ramb}'::text[] as last_arr | |
) sub1, | |
generate_series(1, 3 + (generator*0)) | |
) AS con_name_first(z1) | |
) sub2, | |
( | |
select last_last[ 1 + ( (random() * 10 + (generator * 0))::int) % 6] as last_char | |
FROM ( | |
select '{x,t,d,e,s}'::text[] as last_last | |
) sub3 | |
) sub4 | |
), | |
( | |
select part_arr[ 1 + ( (random() * 100 + (generator * 0))::int) % 50 ] as last_name_part2 | |
FROM | |
( | |
select '{II,III,De Loinloin,De Meumeu,De Parloin,De Parlà,De MontLoin,De Vallointain,De Perpète,De Pétaouchnok,De Trifouillis-Les-Oies,De Clochemerle,Du Troupaumé,De Saint-glin-glin,De Berdouille,De Macapète,De Foufnie,De Pamparigouste,De GlinGlin,De Linlin,De Fouillard,D''Apeuprès,D''Icibas,D''Autemps,D''Auloin}'::text[] as part_arr | |
) sub | |
), | |
generator as id | |
FROM generate_series(1,1000) as generator | |
) main_sub | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample results: