What's against just capitalizing the first letter? Of course there exists a lot of different combinations where a capital letter should be, but if names are coming in like MCDONALD or mcdonald, a user would be happy if he sees Mcdonald. If you gonna make such filter that tries to detect this, you probably end up with something that makes even more faults. Tijnema On 3/20/07, Satyam <Satyam@xxxxxxxxxxxxx> wrote:
----- Original Message ----- From: "Jochem Maas" <jochem@xxxxxxxxxxxxx> To: "Leonard Burton" <leonardburton@xxxxxxxxx> Cc: "Chris W. Parker" <cparker@xxxxxxxxxxxx>; "PHP" <php-general@xxxxxxxxxxxxx> Sent: Tuesday, March 20, 2007 11:09 AM Subject: Re: Name Capitalization > Leonard Burton wrote: >> HI Chris, >> >>> Here is one option. Make a long list (array) of search/replace pairs and >>> loop through your text replacing as necessary. >>> >>> 'mcdonald' => 'McDonald' >>> 'mcdowell' => 'McDowell' >>> 'o\'reilly' => 'O\'Reilly' >>> 'de la rosa' => 'De La Rosa' >>> etc ad nauseum... >> >> I think the better solution would be some pregs that would go through >> and look for "mc" then have it turn the name into "Mc" then Capitalize >> the next letter. [same thing for "mac"] >> >> Then Do the same thing with "O'Henry" it would look for "o\' " then it >> would turn it into "O' " and capitalize the "H". >> >>> Let us know when you're done! :) >> >> This project shouldn't be that hard as there are probably only 10 to >> 15 rules for names. > > give or take a few *thousand* variations alot of which will conflict, > take for instance the surname prefix 'de' - in a spanish name (we'll > assume > Chris' example is correct) the 'd' of a 'de' prefix should be capitalized > BUT in a dutch name the 'd' of a 'de' prefix should not capitalized: > > JOSE DE LA ROSA => Jose De La Rosa > FRANK DE BOER => Frank de Boer > > this actual example may not be valid Indeed, it is not. The correct capitalization is José de la Rosa. At least in Spanish the rules are quite simple, unless someone is actually called 'De', neither 'de', ' la' ,'del', 'y', 'e' or 'i' would be capitalized, and there is no such a thing as a capital letter in the middle of a word or name, not in native Spanish names at least. Nevertheless, you would expect the first letter of a sentence to be capitalized so a news heading such as 'De la Rosa won a 3rd place for McLaren' is correct. Satyam >but I guarantee that you'll come > across this kind of conflicting rules that are language/region/culture > based > and that you will have pretty much no chance of determining which rule to > apply > given just the name input. > > Chris' suggestion of a 1 to 1 map using an assoc array is actually > probably > the cleanest and most successful strategy - but rather you than me when it > comes to compiling that list ;-) though please do put it online when you > have completed it :-P > > assuming the correction that is made to the name capitalization is > presented > to the user you could consider asking the user whether it is correct > and/of > offering a number of variations (including an 'other' field) from which > they > could choose - this is based on the idea that you'll probably guess the > capitalization wrong quite a lot of the time but that regardless of that > fact you may still be able to offer an interface that is helpful to the > user - > even if it's not saying much more than > 'HEY CHIEF, ARE YOU SURE YOU WANT YOUR NAME TO LOOK LIKE THIS?' > >> >> Take Care, >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.446 / Virus Database: 268.18.14/727 - Release Date: > 19/03/2007 11:49 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php