Title Capitalization
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Title Capitalization
I'm writing a filter that transforms text into title case. I'm doing something more than just ucwords() here because I don't want to capitalize minor words.
I've been looking at this section of an article in Wikipedia on capitalization I've decided that I want to leave "internal articles, prepositions, conjunctions and forms of to be" uncapitalized. I need to find out what those things are. Can anybody tell me? I'll be amazed if anyone can. Or can anyone provide a good resource where I might find complete definitions of what they are.
I've been looking at this section of an article in Wikipedia on capitalization I've decided that I want to leave "internal articles, prepositions, conjunctions and forms of to be" uncapitalized. I need to find out what those things are. Can anybody tell me? I'll be amazed if anyone can. Or can anyone provide a good resource where I might find complete definitions of what they are.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Articles seem a wee bit complicated, prepositions are a little bit tricky, conjunctions are pretty standard fair, to be doesn't appear to difficult.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Thanks Feyd that was great.
In case anyone else needs this here's the magic arrayI've used keys because they are indexed and thus faster
In case anyone else needs this here's the magic array
Code: Select all
$keyword = array('across' => true, 'after' => true, 'at' => true,
'before' => true, 'by' => true, 'during' => true,
'from' => true, 'in' => true, 'into' => true,
'of' => true, 'on' => true, 'to' => true,
'under' => true, 'with' => true, 'without'=> true,
'and' => true, 'but' => true, 'or' => true,
'the' => true, 'a' => true, 'an' => true,
'that' => true, 'is' => true, 'are' => true,
'be' => true, 'am' => true, 'being' => true,
'was' => true, 'were' => true, 'been' => true);- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
err. I've just realised there is no way I can write this properly. English is just too complicated!
For instance this is output from my function:
For instance this is output from my function:
I'm pretty sure been should be capitalized here because its being used in a different form but I'm buggered if I'm going to check for that.The Great Green Man Has been
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Can I ask what's the point of making a script like this?
It's more hassle than it's worth. The amount of characters you'd have to type to make this script perfect (as good as a human could do it) is probably the same amount of characters it would take to type hundreds of thousands of correctly capitalized titles.
When would this script even be used? If the title is not fetched from a database, just type it correctly yourself. If the title is fetched from a database, just type it correctly in the first place.
It's more hassle than it's worth. The amount of characters you'd have to type to make this script perfect (as good as a human could do it) is probably the same amount of characters it would take to type hundreds of thousands of correctly capitalized titles.
When would this script even be used? If the title is not fetched from a database, just type it correctly yourself. If the title is fetched from a database, just type it correctly in the first place.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Now you know why I haven't done one... in a while.