18

Is anyone aware of some code/rules on how to capitalize the names of people correctly?

  • John Smith
  • Johan van Rensburg
  • Derrick von Gogh
  • Ruby de La Fuente
  • Peter Maclaurin
  • Garry McDonald

(these may not be correct, just some sample names and how the capitalization could be/work)

This seems like a losing battle...

If anyone has some code or rules on when and how to capitalize names, let me know :)

Cheers, Albert

Mark Harrison
  • 283,715
  • 120
  • 322
  • 449
Albert
  • 1,002
  • 2
  • 13
  • 20
  • 9
    My bet is on "impossible". – msw Mar 17 '10 at 23:48
  • 3
    Remember, Ian McDonald (from Scotland) has a different capitalization from Ian Mcdonald (from Ireland). – Jonathan Leffler Mar 17 '10 at 23:58
  • @naysayers, everything is possible. – AMissico Mar 18 '10 at 00:08
  • 2
    When in doubt, ALL CAPS. – Juliet Mar 18 '10 at 00:11
  • 4
    @Amissico: Actually, no, it isn't. See http://en.wikipedia.org/wiki/Halting_problem – Billy ONeal Mar 18 '10 at 01:32
  • Actually, it is..."Sometimes, close enough is good enough." http://msdn.microsoft.com/en-us/library/bb263911(VS.85).aspx. From the answers provided, I am sure Albert will find a way. – AMissico Mar 18 '10 at 03:59
  • I'm wondering how it'd be to have a suggestion pop-up when they onblur after entering their last name. If it's all lower case perhaps, they can then choose to correct it. If it's complex, show some options, when they click submit, that is the end of the story... – Albert Mar 18 '10 at 05:00
  • 5
    Stuff like this being closed as off-topic really annoys me. It's the most wrong thing about SO! I got here from google looking for exactly this, and found the answers helpful (and implemented some of them in production code). – brad Nov 10 '13 at 10:36

6 Answers6

19

The only sensible way to handle it, in my opinion, is to let the users tell you how their name should be capitalized. Any automatic scheme is going to annoy someone.

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
7

Just tell them you're OLD SCHOOL. That makes it simple and 100% correct:

- JOHN SMITH
- JOHAN VAN RENSBURG
- DERRICK VON GOGH
- RUBY DE LA FUENTE
- PETER MACLAURIN
- GARRY MCDONALD

The same logic also helps with many i18n problems.

Mark Harrison
  • 283,715
  • 120
  • 322
  • 449
  • 1
    Marc Harisson - agree. people tend to get annoyed when you get their names wrong ... – Rook Mar 18 '10 at 01:35
  • 5
    this is not quite viable in an application though. Imagine your outlook contacts were all UPPER CASE, I think I'd go deaf :\ It could be usefull in some instances though, not this one. – Albert Mar 18 '10 at 04:43
  • 3
    @Albert - Oh, I wish people would stop with that allcaps=loud shouting equality. They're letters like all else. Nothing special about them if they're all caps. – Rook Mar 18 '10 at 15:42
  • 4
    I tell them I'm so old school I don't even use computers. Thus the whole programming problem is circumvented. – Slothario Jan 21 '15 at 16:40
6

Wikipedia seems to have decent coverage of this:

Capitalization - Compound names

Peter Alexander
  • 51,762
  • 11
  • 116
  • 167
3

I'm not sure if Ruby is of use but you might want to take a look at NameCase. Even if you're not working with Ruby, you might be able to port this (it's open source) to your language.

Jaxidian
  • 12,655
  • 8
  • 77
  • 121
2

There's also this implementation in Python which is based on this algorithm. The basic idea is convert the name to title case then check the name against a giant look-up table of exceptions.

But really what Jonathan Leffler said is spot on: unless you have some requirement to convert pre-existing unformatted data, automated capitalization is going to do something wrong (especially as capitalization rules vary across language divides, cultural divides, name changes that result from emigration or people just preferring to capitalize their name in some particular fashion).

ig0774
  • 36,969
  • 3
  • 54
  • 56
  • Without going through the list of exceptions associated with that algorithm, I'd bet on it's being quite incomplete with regards to polish names starting with 'Mac'. – mc0e Jun 25 '13 at 07:32
1

I kept a lookup of names that needed special handling. When a case-insensitive match was found, I used the lookup value. This did not resolve people who used case that did not match the "accepted" capitalization. It allowed me/user to add names as needed. I can't find my code, but I did get the surnames from http://www.census.gov/.

AMissico
  • 21,219
  • 6
  • 74
  • 106