Thursday, May 29, 2008

Names, Lots of Names

I needed a whole bunch of sample last names for some bogus data for an app I'm working on. Thankfully, we have Google, and of course, this information is just a query away.

I quickly found the Top 1000 most common surnames in the US (as of the 1990 census).

This should be exactly what I need.

Little known fact - Simon is a more common last name than Frank and Clayton. Not to mention Lloyd and Boone. Heck, we just barely beat out Waters.

As a bonus, here's a little PLT-Scheme app I wrote up to grab and fix the case on the names. No claim that it's especially efficient or compact, it just is.

(module name-grabber mzscheme
  (require (lib "url.ss" "net")
           (prefix l: (lib "1.ss" "srfi"))
           (prefix s: (lib "13.ss" "srfi"))
           (planet "sxml.ss" ("lizorkin" "sxml.plt" 1 4))
           (planet "htmlprag.ss" ("neil" "htmlprag.plt" 1 3))
           (lib "26.ss" "srfi"))

  (provide get-names)

  (define (fix-case word)
    (string-append (string-upcase (substring word 0 1)) 
                   (string-downcase (substring word 1))))
  
  (define (get-names)
    (let* ((url (string->url "http://names.mongabay.com/most_common_surnames.htm"))
           (in-port (get-pure-port url))
           (doc (html->sxml in-port)))
      (close-input-port in-port)
      (let ((name-rows ((sxpath '("//table[@style = 'boldtable']/tr")) doc)))
        (l:drop (map (lambda (row)
                     (let ((cols ((sxpath '(// td *text*)) row)))
                       (if (not (null? cols))
                           (fix-case (l:first cols))
                           (void))))
                   name-rows) 1))))
  )

Update: Added a provide clause, thanks Grant!

19 comments:

  1. Thanks Ben. You don't have a provide clause in there; is that intentional?

    ReplyDelete
  2. No it wasn't intentional - and, I just added it.

    But it wasn't completely un-intentional either

    Lately, I've found DrScheme I've been using DrScheme as environment where I can quickly whip up little apps to generate stuff - like this list of names, or bulk sets of INSERT statements.

    Perhaps because Windows has no Shell, I've been finding that DrScheme can fill that niche.

    DrScheme has a "module" mode where the bindings for a given module are visible, which is why what I was using when I wrote the attached code.

    In this case, I wrote up the script, kicked off the REPL, use a couple of list operations to take a slice of the 1000 names. And, I was done.

    Thanks for the suggestion!

    ReplyDelete
  3. I actually blogged about generating random fake names before (7/2006), because I needed some test data. My solution used curl, grep, and sed (all from a cygwin bash shell) to do very, very basic html scraping.

    Of course, we all know what's bound to happen when you rely on html scraping: the html eventually changes, and your scripts no longer work [properly].

    So, I revised it in 11/2006, but apparently never posted the revised version.

    That code no longer works, either, though. I just wanted to share the way I did it, especially the website that I used: www.fakenamegenerator.com

    ReplyDelete
  4. Got to say Dave, FakeNameGenerator.com is impressive. I could do without all the ads, but creating an entire identity is just too cool.

    Actually, the mobile version is pretty clean.

    Nice find!

    -Ben

    ReplyDelete
  5. Anonymous5:03 AM

    hello, I look for people who can make transfers virtual bank to bank.
    We will give accounts .The person will receive 40 to 45% of the sum. To trust is to you to see I know you have our money, because I saw it I hope that we will make money much the same. I look forward to the follow
    j am someone who don't be afraid by anythink j am ready to add your group and meet all hacker who can make money and want to win money . j will be for you serious partner and j will pay you your part .

    j am ready for all trial .
    contact me siazoure@yahoo.fr

    ReplyDelete
  6. Anonymous4:26 AM

    can you give me a credit card number and a fake name?
    oh and a sercurity number? Thanks ben. :)

    ReplyDelete
  7. Anonymous1:51 PM

    I tried one random id from fakenamegenerator for paypal, but it didn't work!

    ReplyDelete
  8. Anonymous5:17 AM

    do yu have security too? i jus need a damn card to see something im not gonna buy nothin

    ReplyDelete
  9. Anonymous11:26 AM

    i can generate a valid credit card number but can't get the security pin, cvv, ssn, name of card owner. please anyone with information's on how to get this info please contact me. chukszzi@hotmail.co.uk

    ReplyDelete
  10. Anonymous5:45 AM

    Ben,i want a visa credit card no. with the security code can you pls help me

    ReplyDelete
  11. Anonymous10:38 PM

    i need the expiry date for the vias number given by ben:).THX u very much

    ReplyDelete
  12. Anonymous11:23 PM

    i want to know to generate valid expiry date of master cards. thanks

    ReplyDelete
  13. Anonymous7:37 PM

    Is it possible to buy stuff with the fake credit card

    ReplyDelete
  14. Anonymous4:28 PM

    It seems so, but I don't know if it is risk since fakenamegenerator creates and identity.

    ReplyDelete
  15. Anonymous2:46 AM

    Banking database should have all those info needed.

    ReplyDelete
  16. Anonymous10:24 AM

    can i get credit card info ?? whole with card no expiry date cvv and holder name plz... i dont understand this java script or html... or email me @ karanjainniceboy@gmail.com thnx

    ReplyDelete
  17. I need fake credit card number to sign up in a porn site. I need cvv2 as well. Would you plz advise if I also need a fake email id?

    ReplyDelete
  18. What About name of card , city , zip and others ..??

    ReplyDelete
  19. Anonymous1:58 PM

    i cant understand anything can u give me a face card no and its details

    ReplyDelete