Looking for a module...

Timothy S. Nelson wayland at smartchat.net.au
Tue Mar 4 16:58:12 CST 2003

On Tue, 25 Feb 2003, David Thomas wrote:

> > What do you mean "in different ways".  Do you want to end up with RanDoMlY
> > capiTalIzED text or Title-cased text or something in between.  If you can
> > give me an example of what you want to get to, I'm sure I can help you
> > find a module that does it, or something similar.
> We are trying to get 'intelligent' title case primarily, enforced at a code
> level.
> eg.
> the title => The Title
> ask for help => Ask for Help
> Thanks for the help :)

	I don't know of any relevant modules, but I don't see this as a regex 
thing.  Basically, you want to follow the following rules:

1.	Capitalise the first letter
2.	Capitalise nouns, verbs, etc

	Unless you intend to do semantic analysis of the text (or find 
something which does), your best bet is probably to make a list of words not 
to capitalise (such as "the", "of", "for"...), in %lower, and then, with the 
title in $_ go:

foreach(split) {
	push @words, (defined($lower{$_})) ? $_ : ucfirst($_);

$words[0] = ucfirst($words[0]);

$_ = join " ", @words;

	Unless you can find a useful semantic parsing module, that's probably 
your best bet.  With no regicies.  


| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayland at smartchat.net.au | I am                           |

Version 3.1
GCS d? s: a-- C++>++++$ US+ P++ L++ E- W+++ N+ w+> M-- V- Y+>++ 
PGP->++ R(+) !tv B++ DI++++ D+ G e>++ h!/* y-

More information about the Melbourne-pm mailing list