Re: Name Capitalization
| From: | Satyam | Date: | Tue, 20 Mar 2007 10:41:59 +0000 |
| Subject: | Re: Name Capitalization | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250900@lists.php.net to get a copy of this message | ||
----- Original Message ----- From: "Jochem Maas" <jochem@iamjochem.com>
To: "Leonard Burton" <leonardburton@gmail.com>
Cc: "Chris W. Parker" <cparker@swatgear.com>; "PHP" <php-general@lists.php.net>
Sent: Tuesday, March 20, 2007 11:09 AM
Subject: Re: [PHP] Name Capitalization
Leonard Burton wrote: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. SatyamHI Chris,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 validHere 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.
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