Lingua-EN-NameCase reviews

cpanratings
 

RSS | Module Info | Add a review of Lingua-EN-NameCase

Lingua-EN-NameCase (1.15) ****

I had a long list of names that came in ALL CAPS. I wanted to convert them into their commonly written form. Doing ucfirst ( lc ($first_name) ) and ucfirst( lc ($last_name) ) goes along way to gettng the job done, but it does not address hyphenated names such as Smith-Jones nor does it address names with multiple words.

I could split on space and hyphen and then apply the ucfirst(lc()) to each word for multiple word names but that doesn't handle King James IV or names that start with Mc\U Mac\U O'\*. I searched CPAN for a more general solution and came across this module.

It does all the above case conversions, but has a few drawbacks in part due to the difficult nature of the problem: VAN and VAN DER get converted to van and van der always which may not always be correct.

There is a Spanish configuration option that makes el -> El and la -> La but it doesn't make de -> De or del -> Del. Again the letter case may vary depending on the owner of the name, but it would be nice to have more configuration options to choose to have all one way or the other.

For reference here's a basic function that does a lot of what this module does but not all:

sub name_case_converter {

my $name = shift;

$name = join ' ', map {

join '-', map { ucfirst( lc($_) ) } split /-/;

} split /\s+/, $name;

$name =~ s{^MC(.)}{Mc\U$1}mxsi;

$name =~ s{^O'(.)}{O'\U$1}mxsi;

return $name;
}