Are Those Names Nicknames?
I recently wrote a piece of code to figure out if two names are nicknames.
I found a
csv file of common nicknames on Github. I wrote a Ruby function that reads the file line by line and if the two names passed as parameters are on the same line, it means they’re nicknames.
def nickname?(name, name2) File.open('nicknames.csv').each do |line| names = line.strip.split(',') return true if names.include?(name) and names.include?(name2) end false end
It’s simple but it works well.
Funnily, this list states that Sion is a nickname of Simon. Nobody ever called me Sion.#ruby