Generate a nickname from a real name in php
July 3, 2008 3:11 AM   Subscribe

I am looking for a way to generate nicknames from real names, preferably in PHP.

I am setting up a community website that uses facebook for autentication. Facebook sends me the name for every new user but I dont want to show it in full to the whole world so I need to give each user a nickname.

Of course the user could choose a name themselfs but i I would prefer to have the system giving them a name that sounds a bit like their real name but obfuscates it enough to make it non recognisable online. Preferably it will also be human spokable without any numbers or such.

I was toying with the idea to take the first syllable in the users first name and then add something random to it. Extracting syllables though seem pretty hard. Anyone have other ideas or even better a finished class or script for this thing.
posted by ilike to Computers & Internet (10 answers total) 1 user marked this as a favorite
 
Best answer: Hmm... could you roughly approximate symbols by grabbing up to and one past the first vowel? For example: "metafilter" => "met"; "katrielalex" => "kat". Then just choose any word that begins with a vowel and tack that on the end.
posted by katrielalex at 3:30 AM on July 3, 2008


Best answer: I think you'll get a reasonable approximation of the first syllable of a word by taking everything up to the first consonant after a vowel. Thus:

metafilter -> met
leon -> leon

I'm sure there are words that break that pattern (ibuprofen?), plus I think different accents are going to split syllables differently (his-toric or hist-oric), and silent letters are going to be special cases (john) but it's good enough for a website.

(looks like I came to the same solution as katrielalex).
posted by Leon at 4:14 AM on July 3, 2008


Stick with users choosing their own username. The problem with an auto-generatic system like the one proposed above is that lots of people have the same first name. What do you do with Jonathan A vs. Jonathan B? The technical answer is usually, "add another letter", so you wind up with "Jon" and "Jona", but then it becomes difficult for the community to know who's who.
posted by mkultra at 5:40 AM on July 3, 2008


Would it be too much work to use an anagram generator? -- or would that not be cryptic enough?
posted by nnk at 5:51 AM on July 3, 2008


Can you use the first part of their email address (the bit before the email). This is likely to be unique, personalised and relatively anonymous. If you get any clashes, append an ascending number to the username.
posted by maryrosecook at 6:02 AM on July 3, 2008


I agree with the above, but it's worth using a nickname lookup for common names. e.g. Andrew becomes Andy, not And. If you keep your nicknames in a database table, you can clean up any new names & change the proposed name to nickname for tricky & yet common names as a periodic task.

To get started, I googled "Common Nicknames".
http://deron.meranda.us/data/nicknames.txt
http://www.genealogytoday.com/genealogy/enoch/nicknames.html
posted by seanyboy at 6:24 AM on July 3, 2008


Also : If you're not that bothered about making a name which matches the real name, you can use something like this
I assume it uses a hash of your name to seed a pseudo-random number generator.
posted by seanyboy at 6:32 AM on July 3, 2008


What about Sean and Neil and Doug and Beiauan? The first syllable script would just grab their whole name.
posted by thirteenkiller at 8:05 AM on July 3, 2008


I agree somewhat with mkultra. Will be people able to at least choose a new nick if they don't like the one assigned to them?

For the assigned name, what about taking their name and replacing all the vowels with a different randomly chosen one? Love, dunastaperstir
posted by danOstuporStar at 8:56 AM on July 3, 2008


Poking around some hyphenation algorithms might net you some good results, although I think a lookup table as seanyboy suggests is the best solution.

If this is for a commercial project, I would dig into what usage is permitted by those lists. This kind of data often has value. There's no declaration of copyright on his first link, and since it's from census data it theoretically can be reproduced. The second expressly forbids use of the listing.
posted by cCranium at 9:54 AM on July 3, 2008


« Older Amazon search strategy   |   Is there an equivalent of IMDB or Allmusic for... Newer »
This thread is closed to new comments.