Namey - A Random Name Generator

Recently, I had an idea for a project where I wanted to be able to create random names for people on the fly. It's a fictional schedule for a fictional cable channel, the Not Lifetime Movie Network. Some of the movie titles needed random names. I dug around, and found a few name generators out there, but none of them had an API, or available source code, so I ended up making my own. This quickly turned into a classic project – I spent maybe an hour or two writing some code to generate a list of fake movies, and ten times longer coming up with a generic library for random name generation. it went something like this:

I don't actually like xkcd that much, but this sums things up nicely.

But when I was done, I had Namey – a website where you can quickly generate some random names, as well as an underlying library written in ruby. It uses files generated by the US Census Bureau for the 1990 census to generate whatever sort of name you would like. You can pick a gender, specify if you want a last name or not, and if you would like a common name, rare name, etc.

The data itself looks a lot like this (in fact, this is the data):

JAMES 3.318 3.318 1
JOHN 3.271 6.589 2
ROBERT 3.143 9.732 3
MICHAEL 2.629 12.361 4
WILLIAM 2.451 14.812 5
DAVID 2.363 17.176 6
RICHARD 1.703 18.878 7
CHARLES 1.523 20.401 8
JOSEPH 1.404 21.805 9
THOMAS 1.380 23.185 10

So, the government is big on ALL CAPS. Also, there's no punctuation, so O'Brian is OBRIAN. I've done a bunch of massaging to the data - names are mostly in proper case, with apostrophes where it's fairly obvious, but I'm sure I missed some.

For nerds, the code is open source and available on github, so you can fork it and play around as much as you want. As I worked on this project, I developed certain goals:

  • Write a decent Ruby gem to generate random names – this is the bulk of the project
  • Build a website which can use it – see
  • Play with Twitter's bootstrap library – I built the website with it. It's pretty cool!
  • Generate a Javascript API layer in between. If you wanted to, you could pull the JS onto your own site and generate random names. Still working on this part.

In short, by the time I'm done, I intend to have a ridiculously overbuilt system for generating random names.

Filed under: Code, projects, ruby