Created
August 29, 2026 08:06
-
-
Save frostu8/914601b2af0d3679e3e7d8999dfa0239 to your computer and use it in GitHub Desktop.
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
| import csv | |
| from itertools import islice | |
| import Levenshtein | |
| # Why are people named Dante and Deante | |
| BAD_DISTANCE = 3 | |
| names = [ | |
| "Ashley", "Grace", "Isaac", "Hannah", "James", "Olivia", "Noah", "Emma", | |
| "Liam", "Ava", "Ethan", "Mia", "Lucas", "Sofia", "Mason", "Amelia", | |
| "Logan", "Harper", "Elijah", "Evelyn", "Henry", "Abigail", "Jack", "Ella", | |
| "Leo", "Scarlett", "Owen", "Luna", "Caleb", "Nora", "Miles", "Chloe", | |
| ] | |
| initial_len = len(names) | |
| with open('./girl_boy_names_1990.csv') as file: | |
| reader = csv.reader(file) | |
| for row in islice(reader, 1, None): | |
| for name in row[1:]: | |
| names.append(name) | |
| # remove names that are too similar | |
| filtered_names = names[:initial_len] | |
| for name in names[initial_len:]: | |
| # Check other names for similarity | |
| accept = True | |
| for accepted_name in filtered_names: | |
| dist = Levenshtein.distance(accepted_name, name) | |
| if dist < BAD_DISTANCE: | |
| #print(f'bad: {accepted_name} > {name}') | |
| accept = False | |
| break | |
| if accept: | |
| filtered_names.append(name) | |
| with open('./ace-id-names.txt', 'w+') as file: | |
| file.writelines(f'{x}\n' for x in filtered_names) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment